Support more general URIs in hyperlinks (#134) (#135)

Signed-off-by: Jonas Dujava <jonas.dujava@gmail.com>
pull/813/head
Jonáš Dujava 2024-06-23 16:03:58 +07:00 committed by GitHub
parent 5a1b4165ad
commit 08d8b885a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 28 deletions

@ -323,6 +323,8 @@ module.exports = grammar({
curly_group_path_list: $ =>
seq('{', sepBy(field('path', $.path), ','), '}'),
curly_group_uri: $ => seq('{', field('uri', $.uri), '}'),
curly_group_command_name: $ =>
seq('{', field('command', $.command_name), '}'),
@ -381,6 +383,8 @@ module.exports = grammar({
path: $ => /[^\*\"\[\]:;,\|\{\}<>]+/,
uri: $ => /[^\[\]\{\}]+/,
argc: $ => /\d/,
glob_pattern: $ => repeat1($._glob_pattern_fragment),
@ -1120,7 +1124,7 @@ module.exports = grammar({
prec.right(
seq(
field('command', choice('\\url', '\\href')),
field('url', $.curly_group_text),
field('uri', $.curly_group_uri),
field('label', optional($.curly_group)),
),
),

@ -183,47 +183,38 @@ Hyperlinks
\href{https://github.com/latex-lsp/tree-sitter-latex}{tree-sitter-latex}
\href{https://github.com/latex-lsp/tree-sitter-latex/issues?q=hyperlink}
{search ``hyperlink''}
\href{file:///path/to/file_containing spaces, and also commas}{file URI}
--------------------------------------------------------------------------------
(source_file
(hyperlink
(curly_group_text
(curly_group_uri
(uri)))
(hyperlink
(curly_group_uri
(uri))
(curly_group
(text
(word)
(operator)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word))))
(hyperlink
(curly_group_text
(curly_group_uri
(uri))
(curly_group
(text
(word)
(operator)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)))
(word))))
(hyperlink
(curly_group_uri
(uri))
(curly_group
(text
(word)
(operator)
(word)
(operator)
(word)))))