-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
When I write down a code block without specifying any language but put line numbers for highlighting like below:
```{2}it is interpreted as the language is language-{2}.
I know the documentation says that :
Note: This will wrongly assign a language class and the class might appear as language-{1,3} or language-showLineNumbers, but allow the language highlighting and line number function to work. An possible approach would be to add a placeholder like unknown so the div will have class="language-unknown"
I see in the playground that the above code produces the below AST (the rest is omitted)
{
"type": "code",
"lang": "{2}",
"meta": null,
}Is it possible to put a logic in the plugin like below as a pseudo code:
- Check if the
langstarts with "{"- if the
metais null then copy the content of thelanginto themetaand make thelangis "unknown" or null, - if the
metais not null then prepend thelanginto themetaand make thelangagain "unknown" or null,
- if the
Here is two AST examples before and after :
// ```{2}
// before
{
"type": "code",
"lang": "{2}",
"meta": null,
}
// after
{
"type": "code",
"lang": "unknown", // or null, I could not figure out which is better
"meta": "{2}",
}// ```{2} showLineNumbers
// before
{
"type": "code",
"lang": "{2}",
"meta":"showLineNumbers,
}
// after
{
"type": "code",
"lang": "unknown", // or null, I could not figure out which is better
"meta": "{2} showLineNumbers",
}Then maybe we can highlight any line without specifying any language or without the text unknown as a dummy language.