Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use split_parser branch for markdown grammar #3108

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use split_parser branch for markdown grammar
MDeiml committed Aug 6, 2022
commit 3005c689c9a823bb218f56090ceb93d3baefc542
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@
| lua || || `lua-language-server` |
| make || | | |
| markdown || | | |
| markdown.inline || | | |
| meson || || |
| mint | | | | `mint` |
| nickel || || `nls` |
15 changes: 14 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
@@ -884,7 +884,20 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "markdown"
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "ab15701d8f3f68aeb74e30573b7d669a6ef2a7ed" }
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "142a5b4a1b092b64c9f5db8f11558f9dd4009a1b", subpath = "tree-sitter-markdown" }

[[language]]
name = "markdown.inline"
scope = "source.markdown.inline"
injection-regex = "markdown\\.inline"
file-types = []
roots = []
indent = { tab-width = 2, unit = " " }
grammar = "markdown_inline"

[[grammar]]
name = "markdown_inline"
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "142a5b4a1b092b64c9f5db8f11558f9dd4009a1b", subpath = "tree-sitter-markdown-inline" }

[[language]]
name = "dart"
37 changes: 37 additions & 0 deletions runtime/queries/markdown.inline/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;; From nvim-treesitter/nvim-treesitter
[
(code_span)
(link_title)
] @markup.raw.inline

[
(emphasis_delimiter)
(code_span_delimiter)
] @punctuation.bracket

(emphasis) @markup.italic

(strong_emphasis) @markup.bold

[
(link_destination)
(uri_autolink)
] @markup.link.url

[
(link_text)
(image_description)
] @markup.link.text

(link_label) @markup.link.label

[
(backslash_escape)
(hard_line_break)
] @constant.character.escape

(image ["[" "]" "(" ")"] @punctuation.bracket)
(image "!" @punctuation.special)
(inline_link ["[" "]" "(" ")"] @punctuation.bracket)
(shortcut_link ["[" "]"] @punctuation.bracket)

2 changes: 2 additions & 0 deletions runtime/queries/markdown.inline/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

((html_tag) @injection.content (#set! injection.language "html"))
61 changes: 30 additions & 31 deletions runtime/queries/markdown/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
(setext_heading (heading_content) @markup.heading.1 (setext_h1_underline) @markup.heading.marker)
(setext_heading (heading_content) @markup.heading.2 (setext_h2_underline) @markup.heading.marker)

(atx_heading (atx_h1_marker) @markup.heading.marker (heading_content) @markup.heading.1)
(atx_heading (atx_h2_marker) @markup.heading.marker (heading_content) @markup.heading.2)
(atx_heading (atx_h3_marker) @markup.heading.marker (heading_content) @markup.heading.3)
(atx_heading (atx_h4_marker) @markup.heading.marker (heading_content) @markup.heading.4)
(atx_heading (atx_h5_marker) @markup.heading.marker (heading_content) @markup.heading.5)
(atx_heading (atx_h6_marker) @markup.heading.marker (heading_content) @markup.heading.6)
(setext_heading (paragraph) @markup.heading.1 (setext_h1_underline) @markup.heading.marker)
(setext_heading (paragraph) @markup.heading.2 (setext_h2_underline) @markup.heading.marker)

(atx_heading (atx_h1_marker) @markup.heading.marker (inline) @markup.heading.1)
(atx_heading (atx_h2_marker) @markup.heading.marker (inline) @markup.heading.2)
(atx_heading (atx_h3_marker) @markup.heading.marker (inline) @markup.heading.3)
(atx_heading (atx_h4_marker) @markup.heading.marker (inline) @markup.heading.4)
(atx_heading (atx_h5_marker) @markup.heading.marker (inline) @markup.heading.5)
(atx_heading (atx_h6_marker) @markup.heading.marker (inline) @markup.heading.6)

[
(indented_code_block)
(code_fence_content)
(fenced_code_block)
] @markup.raw.block

(block_quote) @markup.quote

(code_span) @markup.raw.inline

(emphasis) @markup.italic

(strong_emphasis) @markup.bold
(info_string) @label

(link_destination) @markup.link.url
(link_label) @markup.link.label
[
(fenced_code_block_delimiter)
] @punctuation.bracket

(info_string) @label
[
(link_destination)
] @markup.link.url

[
(link_text)
(image_description)
] @markup.link.text
(link_label)
] @markup.link.label

[
(list_marker_plus)
(list_marker_minus)
(list_marker_star)
] @markup.list.numbered
] @markup.list.unnumbered

[
(list_marker_dot)
(list_marker_parenthesis)
] @markup.list.unnumbered
] @markup.list.numbered

(thematic_break) @punctuation.delimiter

[
(backslash_escape)
(hard_line_break)
] @constant.character.escape
(block_continuation)
(block_quote_marker)
] @punctuation.special

(thematic_break) @punctuation.delimiter
[
(backslash_escape)
] @string.escape

(inline_link ["[" "]" "(" ")"] @punctuation.bracket)
(image ["[" "]" "(" ")"] @punctuation.bracket)
(fenced_code_block_delimiter) @punctuation.bracket
(block_quote) @markup.quote
22 changes: 14 additions & 8 deletions runtime/queries/markdown/injections.scm
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
; From nvim-treesitter/nvim-treesitter

(fenced_code_block
(info_string) @injection.language
(code_fence_content) @injection.content
(#set! injection.include-children))

((html_block) @injection.content
(#set! injection.language "html"))
((html_tag) @injection.content
(#set! injection.language "html"))
(info_string
(language) @injection.language)
(code_fence_content) @injection.content (#set! injection.include-unnamed-children))

((html_block) @injection.content (#set! injection.language "html") (#set! injection.include-unnamed-children))

([
(minus_metadata)
(plus_metadata)
] @injection.content (#set! injection.language "yaml") (#set! injection.include-unnamed-children))

((inline) @injection.content (#set! injection.language "markdown.inline") (#set! injection.include-unnamed-children))