Added syntax highlighting

This commit is contained in:
Elio Struyf
2020-09-23 12:15:15 +02:00
parent bc734df109
commit a278dc7d88
6 changed files with 85 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
# Change Log
## [1.6.0] - 2020-09-23
- Syntax highlighting for Hugo shortcodes has been added
## [1.5.0] - 2020-09-10
- [#17](https://github.com/estruyf/vscode-front-matter/issues/17): Make front matter be indentation `tabSize` aware

View File

@@ -10,6 +10,10 @@ The extension will automatically verify if your title and description are SEO co
> If you see something missing in your article creation flow, please feel free to reach out.
## Syntax highlighting for Hugo Shortcodes
![Shortcode syntax highlighting](./assets/syntax-highlighting.png)
## Available commands:
**Front Matter: Create <tag | category>**

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -134,7 +134,14 @@
"command": "frontMatter.generateSlug",
"title": "Front Matter: Generate slug based on article title"
}
]
],
"grammars": [
{
"path": "./syntaxes/hugo.tmLanguage.json",
"scopeName": "frontmatter.markdown.hugo",
"injectTo": [ "text.html.markdown" ]
}
]
},
"scripts": {
"vscode:prepublish": "webpack --mode production",

View File

@@ -0,0 +1,63 @@
{
"scopeName": "frontmatter.markdown.hugo",
"injectionSelector": "L:text.html.markdown",
"patterns": [
{
"include": "#shortcodes"
}
],
"repository": {
"string-double-quoted": {
"begin": "\"",
"beginCaptures": {
"0": { "name": "punctuation.definition.string.begin.hugo" }
},
"end": "\"",
"endCaptures": {
"0": { "name": "punctuation.definition.string.end.hugo" }
},
"name": "string.quoted.double.hugo",
"patterns": [
]
},
"unquoted-attribute": {
"match": "(?<==)(?:[^\\s<>/'\"]|/(?!>))+",
"name": "string.unquoted.hugo"
},
"tag-generic-attribute": {
"match": "(?<=[^=])\\b([a-zA-Z0-9:-]+)",
"name": "entity.other.attribute-name.hugo"
},
"shortcode-name": {
"match": "(\\s[\\w\\-\\_]+\\s)",
"name": "hugo.shortcode.name",
"captures": {
"1": { "name": "keyword.other.important.hugo" }
}
},
"shortcodes": {
"begin": "{{<|{{%",
"end": ">}}|%}}",
"beginCaptures": {
"0": { "name": "punctuation.definition.tag.begin.hugo" }
},
"endCaptures": {
"0": { "name": "punctuation.definition.tag.end.hugo" }
},
"patterns": [
{
"include": "#shortcode-name"
},
{
"include": "#tag-generic-attribute"
},
{
"include": "#string-double-quoted"
},
{
"include": "#unquoted-attribute"
}
]
}
}
}

View File

@@ -40,3 +40,9 @@
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/testing-extension).
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace.
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
## Usefull links
https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#injection-grammars
https://github.com/microsoft/vscode-textmate/blob/e8f439d613afa00674e83b3b3ae382fc774665e1/test-cases/themes/syntaxes/html.json