From 36d5efc7c49dc2d85d0e67b4e1ba4f43b7159937 Mon Sep 17 00:00:00 2001 From: Jonas Holst Damtoft Date: Mon, 1 May 2023 21:56:41 +0200 Subject: [PATCH] fix(html): add additional html entities Aligns with https://github.com/neovim/neovim/blob/26cc946226d96bf6b474d850b961e1060346c96f/runtime/lua/vim/lsp/util.lua#L1382 Fixes #447 --- lua/noice/text/markdown.lua | 2 +- tests/text/markdown_spec.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/noice/text/markdown.lua b/lua/noice/text/markdown.lua index 132755a..aa8293b 100644 --- a/lua/noice/text/markdown.lua +++ b/lua/noice/text/markdown.lua @@ -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 diff --git a/tests/text/markdown_spec.lua b/tests/text/markdown_spec.lua index 409808c..29efb8e 100644 --- a/tests/text/markdown_spec.lua +++ b/tests/text/markdown_spec.lua @@ -172,5 +172,24 @@ local b { code = { "local b" }, lang = "text" }, }, }, + { + input = [[ + +1 < 2 +3 > 2 +"quoted" +'apos' +  indented +& + ]], + output = { + { line = "1 < 2" }, + { line = "3 > 2" }, + { line = '"quoted"' }, + { line = "'apos'" }, + { line = " indented" }, + { line = "&" }, + }, + }, } M.test()