mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
feat(web): syntax highlighting via highlight.js
download from https://highlightjs.org/download/ place `highlight/` directory next to `css/` style needs adapting for Neovim colors
This commit is contained in:
parent
952f19ba38
commit
9e1187e489
@ -35,6 +35,7 @@ local spell_dict = {
|
|||||||
lua = 'Lua',
|
lua = 'Lua',
|
||||||
VimL = 'Vimscript',
|
VimL = 'Vimscript',
|
||||||
}
|
}
|
||||||
|
local language = nil
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@ -489,7 +490,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
|
|||||||
end
|
end
|
||||||
return string.format('<div class="help-para">\n%s\n</div>\n', text)
|
return string.format('<div class="help-para">\n%s\n</div>\n', text)
|
||||||
elseif node_name == 'line' then
|
elseif node_name == 'line' then
|
||||||
if parent ~= 'code' and (is_blank(text) or is_noise(text, stats.noise_lines)) then
|
if (parent ~= 'codeblock' or parent ~= 'code') and (is_blank(text) or is_noise(text, stats.noise_lines)) then
|
||||||
return '' -- Discard common "noise" lines.
|
return '' -- Discard common "noise" lines.
|
||||||
end
|
end
|
||||||
-- XXX: Avoid newlines (too much whitespace) after block elements in old (preformatted) layout.
|
-- XXX: Avoid newlines (too much whitespace) after block elements in old (preformatted) layout.
|
||||||
@ -535,16 +536,23 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
|
|||||||
return s
|
return s
|
||||||
elseif node_name == 'argument' then
|
elseif node_name == 'argument' then
|
||||||
return ('%s<code>{%s}</code>'):format(ws(), text)
|
return ('%s<code>{%s}</code>'):format(ws(), text)
|
||||||
-- TODO: use language for proper syntax highlighted code blocks
|
|
||||||
elseif node_name == 'codeblock' then
|
elseif node_name == 'codeblock' then
|
||||||
return text
|
return text
|
||||||
elseif node_name == 'language' then
|
elseif node_name == 'language' then
|
||||||
|
language = node_text(root)
|
||||||
return ''
|
return ''
|
||||||
elseif node_name == 'code' then
|
elseif node_name == 'code' then
|
||||||
if is_blank(text) then
|
if is_blank(text) then
|
||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
return ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
|
local code
|
||||||
|
if language then
|
||||||
|
code = ('<pre><code class="language-%s">%s</code></pre>'):format(language,trim(trim_indent(text), 2))
|
||||||
|
language = nil
|
||||||
|
else
|
||||||
|
code = ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
|
||||||
|
end
|
||||||
|
return code
|
||||||
elseif node_name == 'tag' then -- anchor
|
elseif node_name == 'tag' then -- anchor
|
||||||
if root:has_error() then
|
if root:has_error() then
|
||||||
return text
|
return text
|
||||||
@ -690,6 +698,9 @@ local function gen_one(fname, to_fname, old, commit)
|
|||||||
<link href="/css/bootstrap.css" rel="stylesheet">
|
<link href="/css/bootstrap.css" rel="stylesheet">
|
||||||
<link href="/css/main.css" rel="stylesheet">
|
<link href="/css/main.css" rel="stylesheet">
|
||||||
<link href="help.css" rel="stylesheet">
|
<link href="help.css" rel="stylesheet">
|
||||||
|
<link href="/highlight/styles/neovim.min.css" rel="stylesheet">
|
||||||
|
<script src="/highlight/highlight.min.js"></script>
|
||||||
|
<script>hljs.highlightAll();</script>
|
||||||
<title>%s - Neovim docs</title>
|
<title>%s - Neovim docs</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user