Replies: 3 comments 1 reply
-
That's an interesting idea. There's no reason why Topiary couldn't take the language from a |
Beta Was this translation helpful? Give feedback.
-
This would be interesting for org-mode code blocks as well. |
Beta Was this translation helpful? Give feedback.
-
For future reference, these things are often called "injections" in the tree-sitter community: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection |
Beta Was this translation helpful? Give feedback.
-
I don't remember, maybe we've had this conversation already. Or maybe not. But at any rate, now it's public, so all the better. Not making an issue, because it's just a silly half-baked idea.
Is it plausible to use Topiary to format the code blocks in a Markdown file, using a grammar that would recognise which grammar to delegate each code block?
There are two existing Markdown grammars referenced on the Tree-Sitter website https://github.com/ikatyang/tree-sitter-markdown and https://github.com/MDeiml/tree-sitter-markdown . I don't know if either of them deals with code blocks.
Even if they did, there would be an interesting challenge in using the appropriate Topiary query file to deal with the code block: we're not going to copy them in the query file for Markdown.
Editors that support syntax colouring inside Markdown tend to do so by switching mode (Emacs terminology) between code block fence. In our world, it would mean that, instead of using Topiary to format a Markdown file, we'd use a different executable (possibly Topiary, but maybe another, like Gofmt) for each code block. How do the approaches compare?
Beta Was this translation helpful? Give feedback.
All reactions