1
1
--- @class OrgDatesHighlighter : OrgMarkupHighlighter
2
2
--- @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
+ }
4
11
5
12
--- @param opts { markup : OrgMarkupHighlighter }
6
13
function OrgDates :new (opts )
@@ -13,8 +20,12 @@ function OrgDates:new(opts)
13
20
end
14
21
15
22
--- @param node TSNode
23
+ --- @param name string
16
24
--- @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
18
29
local type = node :type ()
19
30
if type == ' [' or type == ' <' then
20
31
return self :_parse_start_node (node )
@@ -93,8 +104,9 @@ function OrgDates:_parse_end_node(node)
93
104
local prev_sibling = node :prev_sibling ()
94
105
local next_sibling = node :next_sibling ()
95
106
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 () ~= ' [' )
98
110
if is_prev_sibling_valid and is_next_sibling_valid then
99
111
local id = table.concat ({ ' date' , node_type }, ' _' )
100
112
local seek_id = table.concat ({ ' date' , node_type == ' ]' and ' [' or ' <' }, ' _' )
0 commit comments