diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-08 03:32:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-08 03:32:33 -0700 |
commit | 0cfbc6eafff731d2d2ecce1f6ceb40be340473f3 (patch) | |
tree | fb78aa344c45a9be7f2b88927378267c050621a1 /runtime/lua | |
parent | b40ec083ae30eb64ddfec2b238c909116e936e99 (diff) | |
parent | 95b65a7554f1b1041e4f1e7427e540993b68e47e (diff) | |
download | rneovim-0cfbc6eafff731d2d2ecce1f6ceb40be340473f3.tar.gz rneovim-0cfbc6eafff731d2d2ecce1f6ceb40be340473f3.tar.bz2 rneovim-0cfbc6eafff731d2d2ecce1f6ceb40be340473f3.zip |
Merge #30105 fix(tohtml): quote font-family names
Diffstat (limited to 'runtime/lua')
-rw-r--r-- | runtime/lua/tohtml.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/runtime/lua/tohtml.lua b/runtime/lua/tohtml.lua index 6a5bd6de9d..ed42b28725 100644 --- a/runtime/lua/tohtml.lua +++ b/runtime/lua/tohtml.lua @@ -1293,9 +1293,25 @@ local function opt_to_global_state(opt, title) local fonts = {} if opt.font then fonts = type(opt.font) == 'string' and { opt.font } or opt.font --[[@as (string[])]] + for i, v in pairs(fonts) do + fonts[i] = ('"%s"'):format(v) + end elseif vim.o.guifont:match('^[^:]+') then - table.insert(fonts, vim.o.guifont:match('^[^:]+')) + -- Example: + -- Input: "Font,Escape\,comma, Ignore space after comma" + -- Output: { "Font","Escape,comma","Ignore space after comma" } + local prev = '' + for name in vim.gsplit(vim.o.guifont:match('^[^:]+'), ',', { trimempty = true }) do + if vim.endswith(name, '\\') then + prev = prev .. vim.trim(name:sub(1, -2) .. ',') + elseif vim.trim(name) ~= '' then + table.insert(fonts, ('"%s%s"'):format(prev, vim.trim(name))) + prev = '' + end + end end + -- Generic family names (monospace here) must not be quoted + -- because the browser recognizes them as font families. table.insert(fonts, 'monospace') --- @type vim.tohtml.state.global local state = { |