Skip to content

Commit

Permalink
Use split_parser branch for markdown grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeiml committed Jul 19, 2022
1 parent 791bf7e commit 7a3906c
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 40 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
| lua || || `lua-language-server` |
| make || | | |
| markdown || | | |
| markdown_inline || | | |
| meson || || |
| mint | | | | `mint` |
| nickel || || `nls` |
Expand Down
14 changes: 13 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,19 @@ 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]]
name = "markdown_inline"
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "142a5b4a1b092b64c9f5db8f11558f9dd4009a1b", subpath = "tree-sitter-markdown-inline" }

[[language]]
name = "dart"
Expand Down
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)

((html_block) @injection.content (#set! injection.language "html"))

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

((inline) @injection.content (#set! injection.language "markdown_inline"))
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"))

0 comments on commit 7a3906c

Please sign in to comment.