Skip to content

Commit 7e3e958

Browse files
committed
feat: replace html entities. Fixes #168
1 parent a202a22 commit 7e3e958

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lua/noice/text/markdown.lua

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function M.is_empty(line)
1717
return line and line:find("^%s*$")
1818
end
1919

20+
---@param text string
21+
function M.html_entities(text)
22+
local entities = { nbsp = "", lt = "<", gt = ">", amp = "&", quot = '"' }
23+
for entity, char in pairs(entities) do
24+
text = text:gsub("&" .. entity .. ";", char)
25+
end
26+
return text
27+
end
28+
2029
function M.trim(lines)
2130
local ret = {}
2231
local l = 1
@@ -45,6 +54,7 @@ end
4554
---@param message NoiceMessage
4655
---@param text string
4756
function M.format(message, text)
57+
text = M.html_entities(text)
4858
local lines = vim.split(vim.trim(text), "\n")
4959
lines = M.trim(lines)
5060

0 commit comments

Comments
 (0)