Skip to content

Commit

Permalink
Add support for Hack language markdown blocks (#100)
Browse files Browse the repository at this point in the history
* Better names for the syntax highlighting tests; add some new cases for validation

* This is really a constructor

* Add support for hack language embedded highlighting within markdown

Add test for the same

* Properly format my changes to the package json file

* Properly format codeblock.json
  • Loading branch information
Ted Spence authored Jul 15, 2020
1 parent ed20126 commit 273a6fe
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
"language": "hack",
"scopeName": "source.hack",
"path": "./syntaxes/hack.json"
},
{
"scopeName": "markdown.hack.codeblock",
"path": "./syntaxes/codeblock.json",
"injectTo": [
"text.html.markdown"
],
"embeddedLanguages": {
"meta.embedded.block.hack": "hack"
}
}
],
"snippets": [
Expand Down
22 changes: 22 additions & 0 deletions syntaxes/codeblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"fileTypes": [],
"injectionSelector": "L:markup.fenced_code.block.markdown",
"patterns": [
{
"include": "#hack-code-block"
}
],
"repository": {
"hack-code-block": {
"begin": "hack",
"end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
"contentName": "meta.embedded.block.hack",
"patterns": [
{
"include": "source.hack"
}
]
}
},
"scopeName": "markdown.hack.codeblock"
}
7 changes: 7 additions & 0 deletions syntaxes/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ This folder contains interesting examples of hack code that can be used to demon
To report a bug for syntax highlighting, please submit a file that demonstrates a snippet of code that is colored incorrectly.

To test updates to syntax coloring, open this folder and verify the examples.

```hack
// This embedded code block within the markdown should also be properly highlighted in the manner of a hack file.
function f() {
return;
}
```

0 comments on commit 273a6fe

Please sign in to comment.