11--- @class OrgDatesHighlighter : OrgMarkupHighlighter
22--- @field private markup OrgMarkupHighlighter
3- local OrgDates = {}
3+ local OrgDates = {
4+ valid_capture_names = {
5+ [' date_active.start' ] = true ,
6+ [' date_active.end' ] = true ,
7+ [' date_inactive.start' ] = true ,
8+ [' date_inactive.end' ] = true ,
9+ },
10+ }
411
512--- @param opts { markup : OrgMarkupHighlighter }
613function OrgDates :new (opts )
@@ -13,8 +20,12 @@ function OrgDates:new(opts)
1320end
1421
1522--- @param node TSNode
23+ --- @param name string
1624--- @return OrgMarkupNode | false
17- function OrgDates :parse_node (node )
25+ function OrgDates :parse_node (node , name )
26+ if not self .valid_capture_names [name ] then
27+ return false
28+ end
1829 local type = node :type ()
1930 if type == ' [' or type == ' <' then
2031 return self :_parse_start_node (node )
@@ -93,8 +104,9 @@ function OrgDates:_parse_end_node(node)
93104 local prev_sibling = node :prev_sibling ()
94105 local next_sibling = node :next_sibling ()
95106 local is_prev_sibling_valid = not prev_sibling or prev_sibling :type () == ' str' or prev_sibling :type () == ' num'
96- -- Ensure it's not a link
97- local is_next_sibling_valid = not next_sibling or (node_type == ' ]' and next_sibling :type () ~= ' ]' )
107+ -- Ensure it's not a link or a link alias
108+ local is_next_sibling_valid = not next_sibling
109+ or (node_type == ' ]' and next_sibling :type () ~= ' ]' and next_sibling :type () ~= ' [' )
98110 if is_prev_sibling_valid and is_next_sibling_valid then
99111 local id = table.concat ({ ' date' , node_type }, ' _' )
100112 local seek_id = table.concat ({ ' date' , node_type == ' ]' and ' [' or ' <' }, ' _' )
0 commit comments