aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2020-06-13 14:05:31 +0900
committerHirokazu Hata <h.hata.ai.t@gmail.com>2020-06-13 14:33:47 +0900
commit50f3f48ea07aecbca53089193ce56b372609324c (patch)
tree2046379c82d8d5c4307fb0430a568b4e119a4ed9 /scripts
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar.gz
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar.bz2
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar.lz
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar.xz
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.tar.zst
nvim-lspconfig-50f3f48ea07aecbca53089193ce56b372609324c.zip
docgen: escape GitHub Flavored Markdown punctuation characters
https://github.github.com/gfm/#backslash-escapes
Diffstat (limited to 'scripts')
-rw-r--r--scripts/docgen.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/docgen.lua b/scripts/docgen.lua
index 331f0723..fb373f9e 100644
--- a/scripts/docgen.lua
+++ b/scripts/docgen.lua
@@ -161,6 +161,13 @@ local function make_lsp_sections()
make_section(0, '\n\n', sorted_map_table(default_settings.properties, function(k, v)
local function tick(s) return string.format("`%s`", s) end
local function bold(s) return string.format("**%s**", s) end
+
+ -- https://github.github.com/gfm/#backslash-escapes
+ local function excape_markdown_punctuations(str)
+ local pattern = "\\(\\*\\|\\.\\|?\\|!\\|\"\\|#\\|\\$\\|%\\|'\\|(\\|)\\|,\\|-\\|\\/\\|:\\|;\\|<\\|=\\|>\\|@\\|\\[\\|\\\\\\|\\]\\|\\^\\|_\\|`\\|{\\|\\\\|\\|}\\)"
+ return fn.substitute(str, pattern, "\\\\\\0", "g")
+ end
+
-- local function pre(s) return string.format("<pre>%s</pre>", s) end
-- local function code(s) return string.format("<code>%s</code>", s) end
return make_section(0, '\n', {
@@ -179,7 +186,7 @@ local function make_lsp_sections()
make_section(2, '\n\n', {
{v.default and "Default: "..tick(inspect(v.default, {newline='';indent=''}))};
{v.items and "Array items: "..tick(inspect(v.items, {newline='';indent=''}))};
- {v.description};
+ {excape_markdown_punctuations(v.description)};
});
})
end));