Skip to content

Commit

Permalink
Add markdown code block support json textmate
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCMD committed Feb 5, 2024
1 parent bcb5d10 commit d57b1a9
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@ Syntax Highlighting for JSON based TextMate Language and Regex
## Features
Now features basic Intellisense, ctrl+click definitions, breadcrumbs and right click => formatting

```json textmate
{
"$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json",
"scopeName": "source.languageId",
"name": "languageId",
"patterns": [
{ "include": "#repo-item" },
{ "include": "#string" },
{ "include": "#boolean" }
],
"repository": {
"repo-item": { },
"boolean": {
"comment": "`\\b` is a 0-width word boundary. `$1` references capture group 1",
"match": "\\b(true|false)\\b",
"name": "constant.language.$1.languageId"
},
"string": {
"comment": "\"begin\" & \"end\" can create a multi-line region",
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.languageId",
"patterns": [
{
"comment": "Quad backslash required to match one literal backslash",
"match": "\\\\.",
"name": "constant.character.escape.languageId"
}
]
}
}
}
```

Example code:
![example-code](https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/blob/main/images/Example%20Code%20V1.2.png?raw=true)

Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@
"balancedBracketScopes": [
"replace.capture"
]
},
{
"scopeName": "markdown.json.textmate.codeblock",
"path": "./syntaxes/markdown-textmate.tmLanguage.json",
"injectTo": [
"text.html.markdown"
],
"embeddedLanguages": {
"meta.embedded.block.json.textmate": "json-textmate"
}
}
],
"snippets": [
Expand Down
30 changes: 30 additions & 0 deletions syntaxes/markdown-textmate.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json",
"scopeName": "markdown.json.textmate.codeblock",
"name": "JSON TextMate Markdown codeblock",
"injectionSelector": "L:text.html.markdown -meta.embedded.block.json.textmate",
"patterns": [
{ "include": "#fenced_code_block_json-textmate" }
],
"repository": {
"fenced_code_block_json-textmate": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(json)((\\s+|:|,|\\{|\\?)textmate[^`]*)?$)",
"name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"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*$)",
"contentName": "meta.embedded.block.json.textmate",
"patterns": [ { "include": "source.json.textmate" } ]
}
]
}
}
}
2 changes: 1 addition & 1 deletion vscode.tmLanguage.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"scopeName": {
"description": "The `scope-name` for your language\nIt is the same value as \"scopeName\" under \"grammars\" in your `package.json` file",
"type": "string",
"pattern": "^(source|text)(\\.[\\w-]+)+$",
"pattern": "^(source|text|markdown)(\\.[\\w-]+)+$",
"suggestSortText": "!!scopeName"
},
"comment": { "$ref": "#/definitions/comment" },
Expand Down

0 comments on commit d57b1a9

Please sign in to comment.