Skip to content

Commit cb263bc

Browse files
committed
chore: Base for adding list support
1 parent 69226e4 commit cb263bc

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

lua/markview/parsers/asciidoc.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,29 @@ asciidoc.toc = function (_, _, text, range)
148148
});
149149
end
150150

151+
---@param buffer integer
152+
---@param TSNode TSNode
153+
---@param text string[]
154+
---@param range markview.parsed.asciidoc.tocs.range
155+
asciidoc.unordered_list_item = function (buffer, TSNode, text, range)
156+
local _marker = TSNode:child(0);
157+
158+
if not _marker then
159+
return;
160+
end
161+
162+
local marker = vim.treesitter.get_node_text(_marker, buffer, {});
163+
range.marker_end = range.col_start + #( string.match(text[1] or "", "^[%*%s]+") or "" );
164+
165+
asciidoc.insert({
166+
class = "asciidoc_unordered_list_item",
167+
marker = marker,
168+
169+
text = text,
170+
range = range
171+
});
172+
end
173+
151174
--- HTML parser
152175
---@param buffer integer
153176
---@param TSTree table
@@ -178,6 +201,8 @@ asciidoc.parse = function (buffer, TSTree, from, to)
178201
(block_macro_name) @toc_pos_name
179202
(#eq? @toc_pos_name "toc")
180203
)) @asciidoc.toc_pos
204+
205+
(unordered_list_item) @asciidoc.unordered_list_item
181206
]]);
182207

183208
if not can_scan then

test/asciidoc.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ devel@discuss.example.org
6262
mailto:devel@discuss.example.org[Discuss]
6363

6464
mailto:join@discuss.example.org[Subscribe,Subscribe me,I want to join!]
65+
66+
* List item
67+
** Nested list item
68+
*** Deeper nested list item
69+
* List item
70+
*** Another nested list item
71+
* List item
72+

0 commit comments

Comments
 (0)