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

Markdown syntax highlighting should ignore math inside $$ #27865

Closed
slochower opened this issue Jun 1, 2017 · 4 comments
Closed

Markdown syntax highlighting should ignore math inside $$ #27865

slochower opened this issue Jun 1, 2017 · 4 comments
Assignees
Labels
*extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality markdown Markdown support issues

Comments

@slochower
Copy link

  • VSCode Version: 1.12.2
  • OS Version: macOS Sierra 10.12.5

Steps to Reproduce:

  1. Create a markdown document and use inline LaTeX (e.g. $a_{b}$) for math.
  2. VSCode interprets the markdown underscore to mean italic text -- instead of math subscript -- and will make the markdown text italic until it sees a matching underscore delimiter.

I think this is behavior is theme dependent, but I'm not sure. Changing themes just changes how the text between the underscores is rendered (italic or colored or whatever). I believe that markdown delimiters (_ and *) in math mode should be ignored the way they are in code blocks.

markdown_latex

@mjbvz mjbvz added *extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality markdown Markdown support issues labels Jun 1, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Jun 1, 2017

The builtin markdown extension targets commonmark which does not support that syntax.

An extension may be able to extend the builtin markdown grammar using an injection similar to https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example or the extension could provide its own markdown grammar that includes math support in its grammar

@mjbvz mjbvz closed this as completed Jun 1, 2017
@slochower
Copy link
Author

slochower commented Jun 1, 2017

I'm not sure I see how the injection can be used in the example you linked. (It looks like it calls source.js to change what happens inside superjs code blocks, AFAICT, but I don't see an example of source.js.) In lieu of an extension, is there a way to turn off syntax highlighting _ in the theme? That may be simpler for now.

@mjbvz
Copy link
Contributor

mjbvz commented Jun 1, 2017

Instead of injecting to the fenced code block rules like in the linked example, you would want to add an injection for the latex grammar to #paragraph in this case.

The syntax highlighting is up to the grammar. You can customize the grammar if you want to handle _ specially for markdown

@slochower
Copy link
Author

I think I can figure out how to do this with a couple more clues. If I use your codeblock.json as a template, I assume I'll have to change the injectionSelector to something for inline LaTeX. Where are the list of these grammars (i.e., where did you get markup.fenced_code.block.markdown)? Also, I'm still not clear what happens with "include": "source.js". Is this the file that controls syntax highlighting for the injected grammar inside the begin and end patterns? Would I have to pull this from an extension for LaTeX?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality markdown Markdown support issues
Projects
None yet
Development

No branches or pull requests

2 participants