Add support for parsing hyperlinks (#133)

pull/813/head
Patrick Förster 2024-06-22 09:50:56 +07:00 committed by GitHub
parent 6b572f0f70
commit d06c6a24f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 67 additions and 0 deletions

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add support for hyperlinks: `\url`, `\href` ([#130](https://github.com/latex-lsp/tree-sitter-latex/issues/130))
### Fixed
- Add missing citation commands: `\citeA`, `\citeR`, `\citeS`, `\citeyearR` ([#94](https://github.com/latex-lsp/tree-sitter-latex/issues/94))

@ -577,6 +577,7 @@ module.exports = grammar({
$.color_set_definition,
$.color_reference,
$.tikz_library_import,
$.hyperlink,
$.generic_command,
),
@ -1114,5 +1115,14 @@ module.exports = grammar({
field('command', choice('\\text', '\\intertext', '\\shortintertext')),
field('content', $.curly_group),
),
hyperlink: $ =>
prec.right(
seq(
field('command', choice('\\url', '\\href')),
field('url', $.curly_group_text),
field('label', optional($.curly_group)),
),
),
},
});

@ -174,3 +174,56 @@ Text commands
(text
(word)
(word)))))
================================================================================
Hyperlinks
================================================================================
\url{https://github.com/latex-lsp/tree-sitter-latex}
\href{https://github.com/latex-lsp/tree-sitter-latex}{tree-sitter-latex}
--------------------------------------------------------------------------------
(source_file
(hyperlink
(curly_group_text
(text
(word)
(operator)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word))))
(hyperlink
(curly_group_text
(text
(word)
(operator)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)
(operator)
(word)))
(curly_group
(text
(word)
(operator)
(word)
(operator)
(word)))))