GitXplorerGitXplorer
m

vscode-fenced-code-block-grammar-injection-example

public
100 stars
29 forks
2 issues

Commits

List of commits on branch master.
Verified
a121ca350a5565561c0e77bc8d80ba1241661acb

Merge pull request #13 from pzhlkj6612/begin-capture-group-fix

mmjbvz committed 4 years ago
Verified
e18f7ce2d34558f2cc317bdee157e388988b773d

Merge branch 'master' into begin-capture-group-fix

mmjbvz committed 4 years ago
Verified
3c6cda9a3e08772ad606c63ae4ad5cb7d45057da

Merge pull request #12 from pzhlkj6612/begin-capture-scope-fix

mmjbvz committed 4 years ago
Verified
c0021a187aa087757f9a8586d15a92759190d44f

Merge pull request #14 from pzhlkj6612/remove-tasks_json

mmjbvz committed 4 years ago
Unverified
39a46dde086ec00846dde4895ab2865301df495a

refactor: remove useless VS Code task

ppzhlkj6612 committed 4 years ago
Unverified
9f9205bedc6e95d8388bf3519c1b985aeed20b4f

fix: correct the group indexes in beginCaptures

ppzhlkj6612 committed 4 years ago

README

The README file for this repository.

VSCode Markdown Fenced Code Block Grammar Injection Example

Demonstrates how an extension can inject support for a new grammar in VSCode's builtin markdown grammar for fenced code blocks. This extension injects an alias for JavaScript called superjs so support editor highlighting of blocks that look like:

```superjs
someJsCode
```

Structure

  • package.json - VS Code extension manifest file. The contributes.grammars section registers the injected grammar.
  • syntaxes/codeblock.json - The injected grammar itself

How to modify this repo to support a new language in fenced code blocks

  1. In syntaxes/codeblock.json, change the begin rule from superjs to the identifier of your target language. This identifier is what people will write in markdown.
  2. In syntaxes/codeblock.json, change the inner include rule from "source.js" to the scope of your target language. This scope can be found by looking at the target language's grammar.
  3. In syntaxes/codeblock.json, change the contentName from using superjs to using a identifier for your language. This identifier may only contain letters but does not have to match the identifier from step 1.
  4. In syntaxes/codeblock.json, change the scopeName from using superjs to using a identifier for your language. This identifier may only contain letters but does not have to match the identifier from step 1.
  5. In package.json, change the scopeName to match the scopeName from step 4.
  6. In package.json, change embeddedLanguages to map between the contentName from step 3 and the VS Code identifier for your language.
  7. In package.json, change the id from using superjs-injection to using an identifier for your grammar injection. This identifier does not have to match the identifier from step 1.
  8. In package.json, change the language from using superjs-injection to using an identifier for your grammar injection. This identifier has to match the identifier from step 7.