Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language support while editing code blocks within a markdown file #1

Closed
kieferrm opened this issue May 10, 2016 · 3 comments
Closed

Comments

@kieferrm
Copy link
Owner

kieferrm commented May 10, 2016

From microsoft/vscode#6106

we need to investigate how to support embedded languages in the markdown editor (not for the preview, this is for the source) so that code blocks get colored properly. according to @aeschli TM supports the notion of referencing other grammars from within a grammar. ideally we could reference our installed TM bundles for any code block that is being used in the markdown source

In addition to syntax highlighting this includes code folding and simple intellisense.

@kieferrm
Copy link
Owner Author

@aeschli do you have an example of how a TM grammar referencing another TM grammar?

@aeschli
Copy link

aeschli commented May 11, 2016

In your language's grammar you can include grammars of other languages.
See https://manual.macromates.com/en/language_grammars, 12.3 Rule Keys, 'include'.

You can see that in action in a jade.file:

p #[code samp] — Regular text. #[samp This is sample text] more text.

-if(typeof(info) !== 'undefined')
  p Conditional text.

The coloring of the 'if' clause is driven by the javascript grammar. To see the scopes each token gets, use the developer tools: Inspect HTML element.

image

You can see that the token contains js in the scope. It comes from a rule that is defined in vscode/extensions/javascript/syntaxes/JavaScript.tmLanguage

To see how this is done in the Jade grammar, check the Jade grammar vscode/extensions/jade/syntaxes/Jade.tmLanguage and look for include source.js in the Unbuffered code block rule

@kieferrm
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants