Support markdown multi line header notation
This commit is contained in:
@@ -16,10 +16,24 @@ function M.handle_markdown()
|
|||||||
is_inside_code_block = not is_inside_code_block
|
is_inside_code_block = not is_inside_code_block
|
||||||
end
|
end
|
||||||
|
|
||||||
header, title = string.match(value, '^(#+)%s+(.*)$')
|
local next_value = lines[line+1]
|
||||||
if header and not is_inside_code_block then
|
local is_emtpy_line = #value:gsub("^%s*(.-)%s*$", "%1") == 0
|
||||||
depth = #header + 1
|
|
||||||
|
|
||||||
|
local header, title = string.match(value, '^(#+)%s+(.*)$')
|
||||||
|
if not header and next_value and not is_emtpy_line then
|
||||||
|
if string.match(next_value, '^===+%s*$') then
|
||||||
|
header = '#'
|
||||||
|
title = value
|
||||||
|
elseif string.match(next_value, '^---+%s*$') then
|
||||||
|
header = '##'
|
||||||
|
title = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if header and not is_inside_code_block then
|
||||||
|
local depth = #header + 1
|
||||||
|
|
||||||
|
local parent
|
||||||
for i = depth - 1, 1, -1 do
|
for i = depth - 1, 1, -1 do
|
||||||
if level_symbols[i] ~= nil then
|
if level_symbols[i] ~= nil then
|
||||||
parent = level_symbols[i].children
|
parent = level_symbols[i].children
|
||||||
@@ -36,7 +50,7 @@ function M.handle_markdown()
|
|||||||
end
|
end
|
||||||
max_level = depth
|
max_level = depth
|
||||||
|
|
||||||
entry = {
|
local entry = {
|
||||||
kind = 13,
|
kind = 13,
|
||||||
name = title,
|
name = title,
|
||||||
selectionRange = {
|
selectionRange = {
|
||||||
|
|||||||
Reference in New Issue
Block a user