mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(lsp): render <pre>{lang} code blocks and set separator default to false (#21271)
This commit is contained in:
@@ -1261,7 +1261,7 @@ function M.stylize_markdown(bufnr, contents, opts)
|
|||||||
-- when ft is nil, we get the ft from the regex match
|
-- when ft is nil, we get the ft from the regex match
|
||||||
local matchers = {
|
local matchers = {
|
||||||
block = { nil, '```+([a-zA-Z0-9_]*)', '```+' },
|
block = { nil, '```+([a-zA-Z0-9_]*)', '```+' },
|
||||||
pre = { '', '<pre>', '</pre>' },
|
pre = { nil, '<pre>([a-z0-9]*)', '</pre>' },
|
||||||
code = { '', '<code>', '</code>' },
|
code = { '', '<code>', '</code>' },
|
||||||
text = { 'text', '<text>', '</text>' },
|
text = { 'text', '<text>', '</text>' },
|
||||||
}
|
}
|
||||||
@@ -1286,8 +1286,6 @@ function M.stylize_markdown(bufnr, contents, opts)
|
|||||||
-- Clean up
|
-- Clean up
|
||||||
contents = M._trim(contents, opts)
|
contents = M._trim(contents, opts)
|
||||||
|
|
||||||
-- Insert blank line separator after code block?
|
|
||||||
local add_sep = opts.separator == nil and true or opts.separator
|
|
||||||
local stripped = {}
|
local stripped = {}
|
||||||
local highlights = {}
|
local highlights = {}
|
||||||
-- keep track of lnums that contain markdown
|
-- keep track of lnums that contain markdown
|
||||||
@@ -1315,7 +1313,7 @@ function M.stylize_markdown(bufnr, contents, opts)
|
|||||||
finish = #stripped,
|
finish = #stripped,
|
||||||
})
|
})
|
||||||
-- add a separator, but not on the last line
|
-- add a separator, but not on the last line
|
||||||
if add_sep and i < #contents then
|
if opts.separator and i < #contents then
|
||||||
table.insert(stripped, '---')
|
table.insert(stripped, '---')
|
||||||
markdown_lines[#stripped] = true
|
markdown_lines[#stripped] = true
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user