From 47e99ea04804c6bb5f7a296ff96ce5a60de5520f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 23 Jul 2024 14:14:53 +0200 Subject: [PATCH] Syntax: Add Groovy highlighting to fenced code blocks --- messages/next.md | 2 ++ syntaxes/Markdown.sublime-syntax | 21 +++++++++++++++++++++ tests/syntax_test_markdown.md | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/messages/next.md b/messages/next.md index 0dd8c1db..730f4729 100644 --- a/messages/next.md +++ b/messages/next.md @@ -11,6 +11,8 @@ feedback you can use [GitHub issues][issues]. ## New Features +* syntax highlighting for Groovy in fenced code blocks (#768) + ## Changes [issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index 3b3f6eef..ecf50ff4 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -1038,6 +1038,7 @@ contexts: - include: fenced-erlang - include: fenced-graphviz - include: fenced-golang + - include: fenced-groovy - include: fenced-haskell - include: fenced-html-php - include: fenced-html @@ -1323,6 +1324,26 @@ contexts: 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown + fenced-groovy: + - match: |- + (?x) + {{fenced_code_block_start}} + (?i:\s*(groovy)) + {{fenced_code_block_trailing_infostring_characters}} + captures: + 0: meta.code-fence.definition.begin.groovy.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 5: constant.other.language-name.markdown + 6: comment.line.infostring.markdown + 7: meta.fold.code-fence.begin.markdown + embed: scope:source.groovy + embed_scope: markup.raw.code-fence.groovy.markdown-gfm + escape: '{{fenced_code_block_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.groovy.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown + 2: meta.fold.code-fence.end.markdown + fenced-golang: - match: |- (?x) diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 0690b940..79cdade7 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -1610,6 +1610,16 @@ graph n {} |^^ meta.code-fence.definition.end.graphviz.markdown-gfm punctuation.definition.raw.code-fence.end.markdown | ^ meta.code-fence.definition.end.graphviz.markdown-gfm meta.fold.code-fence.end - punctuation +```groovy +| ^^^^^^^ meta.code-fence.definition.begin.groovy.markdown-gfm - meta.fold +| ^ meta.code-fence.definition.begin.groovy.markdown-gfm meta.fold.code-fence.begin.markdown + +| <- markup.raw.code-fence.groovy.markdown-gfm source.groovy +``` +| <- meta.code-fence.definition.end.groovy.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +|^^ meta.code-fence.definition.end.groovy.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +| ^ meta.code-fence.definition.end.groovy.markdown-gfm meta.fold.code-fence.end - punctuation + ```haskell |^^^^^^^^^ meta.code-fence.definition.begin - meta.fold | ^ meta.code-fence.definition.begin meta.fold.code-fence.begin