Skip to content

Commit

Permalink
feat: replace html entities. Fixes #168
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 29, 2022
1 parent a202a22 commit 7e3e958
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lua/noice/text/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ function M.is_empty(line)
return line and line:find("^%s*$")
end

---@param text string
function M.html_entities(text)
local entities = { nbsp = "", lt = "<", gt = ">", amp = "&", quot = '"' }
for entity, char in pairs(entities) do
text = text:gsub("&" .. entity .. ";", char)
end
return text
end

function M.trim(lines)
local ret = {}
local l = 1
Expand Down Expand Up @@ -45,6 +54,7 @@ end
---@param message NoiceMessage
---@param text string
function M.format(message, text)
text = M.html_entities(text)
local lines = vim.split(vim.trim(text), "\n")
lines = M.trim(lines)

Expand Down

0 comments on commit 7e3e958

Please sign in to comment.