Skip to content

Commit

Permalink
fix(markdown): replace additional html entities (folke#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomik authored and willothy committed Aug 19, 2023
1 parent 8efb8dc commit 30870cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/noice/text/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end

---@param text string
function M.html_entities(text)
local entities = { nbsp = "", lt = "<", gt = ">", amp = "&", quot = '"' }
local entities = { nbsp = "", lt = "<", gt = ">", amp = "&", quot = '"', apos = "'", ensp = " ", emsp = " " }
for entity, char in pairs(entities) do
text = text:gsub("&" .. entity .. ";", char)
end
Expand Down
19 changes: 19 additions & 0 deletions tests/text/markdown_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,24 @@ local b
{ code = { "local b" }, lang = "text" },
},
},
{
input = [[
1 &lt; 2
3 &gt; 2
&quot;quoted&quot;
&apos;apos&apos;
&ensp;&emsp;indented
&amp;
]],
output = {
{ line = "1 < 2" },
{ line = "3 > 2" },
{ line = '"quoted"' },
{ line = "'apos'" },
{ line = " indented" },
{ line = "&" },
},
},
}
M.test()

0 comments on commit 30870cb

Please sign in to comment.