nicoulaj / idea-markdown

Markdown language support for IntelliJ IDEA (abandonned).
Apache License 2.0
599 stars 97 forks source link

inject other language fragments into markdown documents #52

Open holgerbrandl opened 12 years ago

holgerbrandl commented 12 years ago

For many custom languages it is possibile to inject other languages into selected code blocks. It would be cool if this would apply to MarkDown documents in Intellij as well, because then it would be possible for instance to use knitr (http://yihui.name/knitr/) by injecting R snippets (using the R-plugin for Intellij) into md-documents.

Tell me if you need help with the implementation, I've done it already for the R-plugin (because I want to inject bash-snippets here and there).

nicoulaj commented 12 years ago

As far as I know this would be possible if we had a proper PSI tree built. idea-markdown is a hack, we have no lexing/parsing, we just use an external annotator to defer syntax highlighting to the underlying library.

It seems to be big work to me, but my knowledge of the IDEA API is pretty limited, so if you want to experiment on this I will be happy to help you !

Did you take a look at idea-markdown implementation ? Do you think it's doable ?

holgerbrandl commented 12 years ago

You're totally right. Once you've a PSI tree it's a snap. But without it's not doable afaik. I've just learned about MarkDown when looking into knitr, so my understanding of it is too limited to write a parser. What helped me a lot to create a psi-parser for R was to use the grammar kit extension (https://github.com/JetBrains/Grammar-Kit)

nicoulaj commented 12 years ago

The difficulty with Markdown is that it does not fit well in ANTLR-style parsing model (because of references/abbreviations/etc). idea-markdown uses a PEG-style parser under the hood, which is difficult to adapt to IntelliJ's PSI building API... I didn't know about their grammar kit, maybe this can make the bridge between both worlds ?

(cc @gregsh)

gregsh commented 12 years ago

Grammar-Kit takes PEG grammar and produces PsiBuilder-based parser and PSI classes. Parboiled-to-BNF conversion should be pretty straightforward but lexer extraction (at least a simple whitespace/word tokenizer) will take some time because unlike other PEG parsers Grammar-Kit requires a lexer which is required by PsiBuilder API actually. Feel free to ask more questions if you decide to take this road.

ronkorving commented 11 years ago

+1 on this. Any status updates? Any chance this will happen some day?

myzone commented 11 years ago

+1

nicoulaj commented 8 years ago

Notice: This plugin is no more maintained and it has been removed from Jetbrains plugins repository. There is a Markdown plugin officially supported by Jetbrains.