-
Notifications
You must be signed in to change notification settings - Fork 302
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
[WIP] Add support for Pandoc's generic raw attributes #226
base: master
Are you sure you want to change the base?
Conversation
- See https://pandoc.org/MANUAL.html#generic-raw-attribute - LaTeX still isn't included correctly. It might have something to do with InjectionsSelector
Could you also add tests for this? |
@kylebarron Thought this through a bit. How widely used is this syntax? Fenced code blocks already have the widely used syntax
and special attributes from Markdown Extra
if I remember correctly, don't use them myself. Moving the language (detection) inside the curly brackets makes it quite a bit more complicated. Since the list of supported languages is dynamic (see https://github.com/burodepeper/language-markdown/blob/master/lib/GrammarCompiler.js#L82-L112 and https://github.com/burodepeper/language-markdown/blob/master/grammars/fixtures/fenced-code.cson), and is part of the grammar that is compiled, this change might be a tad more complicated than it seems. |
...the dreaded
I don't know if a solution is possible. The issue is less noticeable with my On a different note, the |
Taking capture groups and putting them in scope names is actually supported. I believe I've even seen a "to lower case" transformation (but can't confirm that). So you could capture the name in the braces, and use This relies on the other language declaring itself with an More on that here (I think; it's been a while since I've read it). As for the note about spell checking with scopes: I need to follow up on that. I raised an issue, but nothing else has happened. I guess that's a while off, and you can ignore this comment for the time being. |
I've seen that as well. Found it in language-todo. Only works if all grammars use the same |
@Aerijo Did you write that guide? Never seen it before. I've just been hacking stuff together over the years. |
@burodepeper I wrote it at some point as a personal reference, but decided to make it a full guide. I've left some things unfinished, but I'm happy with it on the whole (and have referred back to it a couple of times). |
@Aerijo 👍 I'll give it a read when I have some more time. |
My main motivations for this change are that I often have sections of LaTeX, especially tables, within a Markdown document that I then use Pandoc to convert to PDF. The current highlighting of embedded latex is especially bad. Here's an example (copy-pastable text at the bottom): Note that the HTML injection incorrectly colors all text after the table because it thinks a tag has been opened. With Pandoc allows raw TeX either openly within the document or within raw attribute blocks, i.e.
There is no functional difference in Pandoc; it's just that for the syntax highlighting, the raw attribute blocks should be easier to color. Ideally, there would also be injections for common LaTeX environments like
I'm not moving the language detection inside the curly brackets. Instead I'm doing earlier detection for three specific rules. That's why
the block won't match any rule in You could argue that there's a cleaner way to add the code, but I don't see yet how this specific addition makes the language detection more complicated.
Can you enlighten me on why
What's the benefit of
|
Have you seen #190? Additionally, if I use your testcase and fenced the latex with I get the idea that you want to add it for just these three 'selectors'. Is that as far as it will go? Or will extra options have to be added in the future? |
I hadn't looked at #190 in a while. I'll take a look at it again. Note that there is a difference between
Here's what I (and probably you) see: At the beginning at least, LaTeX is correctly colored. That's why Here's what I see when I change all the occurences of That's the correct syntax highlighting. |
Right, my bad... If you could add some tests to the PR, I think I'm okay with adding it when all other issues have been ruled out. Would be nice to also add the attributes for inline code spans, if you haven't already. |
I have added highlighting for the inline spans as well. It doesn't sound like I'll be able to write correct tests until we have a resolution of |
Your But you still use Any chance your edits will make it back into |
Everything should be fixed when my PR to language-latex gets merged. |
See #225 and https://pandoc.org/MANUAL.html#generic-raw-attribute.
Pandoc added support for Inline and Block raw attributes with version 2.0.
LaTeX still isn't included perfectly. It might have something to do with the injectionsSelector property of the LaTeX grammars file.
With this branch of language-markdown:
With language-latex highlighting:
@Aerijo Your gist detailing injections is super helpful, and I see you've also worked on the language-latex package. Do you happen to quickly see the issue?
This is the relevant portion of the grammars file
The scopes for the incorrectly-colored
\begin{tabular}
are:and the scopes for the correctly-colored
begin{center}
are:When the file's scope is set to
text.tex.latex
, the scopes for\begin{tabular}
are:I don't understand how the scopes are so different for the same text.