Giter Site home page Giter Site logo

kelvinpraises / vscode-fenced-code-block-grammar-injection-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mjbvz/vscode-fenced-code-block-grammar-injection-example

0.0 0.0 0.0 13 KB

Example of injecting a new grammar into VSCode's builtin markdown syntax highlighting for fenced code blocks

License: MIT License

vscode-fenced-code-block-grammar-injection-example's Introduction

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.

vscode-fenced-code-block-grammar-injection-example's People

Contributors

mjbvz avatar pzhlkj6612 avatar kobarity avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.