Skip to content

Commit

Permalink
Fix md code block bug (#1369)
Browse files Browse the repository at this point in the history
* Fix #1288

* Changelog

* Use `[[:space:]]` instead of `\\s`
  • Loading branch information
dlesbre authored Jan 30, 2024
1 parent c6ef578 commit 5f4be19
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Unreleased

- Fix non-ocaml markdown code block syntax highlighting being influenced (issue #1288, #1369)

## 1.16.1

- No longer color comments starting three stars or more as ocamldoc comments (#1355)
Expand Down
19 changes: 14 additions & 5 deletions syntaxes/ocaml-markdown-codeblock.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{
"fileTypes": [],
"injectionSelector": "L:markup.fenced_code.block.markdown",
"injectionSelector": "L:text.html.markdown",
"patterns": [{ "include": "#ocaml-code-block" }],
"repository": {
"ocaml-code-block": {
"begin": "(ml|ocaml)(\\s+[^`~]*)?$",
"end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
"begin": "(^|\\G)([[:space:]]*)(\\`{3,}|~{3,})[[:space:]]*(?i:(ml|ocaml)([[:space:]]+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|[[:space:]]{0,3})(\\3)[[:space:]]*$",
"beginCaptures": {
"3": { "name": "punctuation.definition.markdown" },
"4": { "name": "fenced_code.block.language.markdown" },
"5": { "name": "fenced_code.block.language.attributes.markdown" }
},
"endCaptures": {
"3": { "name": "punctuation.definition.markdown" }
},
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"begin": "(^|\\G)([[:space:]]*)(.*)",
"while": "(^|\\G)(?![[:space:]]*([`~]{3,})[[:space:]]*$)",
"contentName": "meta.embedded.block.ocaml",
"patterns": [
{
Expand Down
19 changes: 14 additions & 5 deletions syntaxes/reason-markdown-codeblock.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{
"fileTypes": [],
"injectionSelector": "L:markup.fenced_code.block.markdown",
"injectionSelector": "L:text.html.markdown",
"patterns": [{ "include": "#reason-code-block" }],
"repository": {
"reason-code-block": {
"begin": "(re|reason|reasonml)(\\s+[^`~]*)?$",
"end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
"begin": "(^|\\G)([[:space:]]*)(\\`{3,}|~{3,})[[:space:]]*(?i:(re|reason|reasonml)([[:space:]]+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|[[:space:]]{0,3})(\\3)[[:space:]]*$",
"beginCaptures": {
"3": { "name": "punctuation.definition.markdown" },
"4": { "name": "fenced_code.block.language.markdown" },
"5": { "name": "fenced_code.block.language.attributes.markdown" }
},
"endCaptures": {
"3": { "name": "punctuation.definition.markdown" }
},
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"begin": "(^|\\G)([[:space:]]*)(.*)",
"while": "(^|\\G)(?![[:space:]]*([`~]{3,})[[:space:]]*$)",
"contentName": "meta.embedded.block.reason",
"patterns": [
{
Expand Down

0 comments on commit 5f4be19

Please sign in to comment.