When I write down a code block without specifying any language but put line numbers for highlighting like below:
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
lang starts with "{"
- if the
meta is null then copy the content of the lang into the meta and make the lang is "unknown" or null,
- if the
meta is not null then prepend the lang into the meta and make the lang again "unknown" or null,
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.
When I write down a code block without specifying any language but put line numbers for highlighting like below:
it is interpreted as the language is
language-{2}.I know the documentation says that :
I see in the playground that the above code produces the below AST (the rest is omitted)
Is it possible to put a logic in the plugin like below as a pseudo code:
langstarts with "{"metais null then copy the content of thelanginto themetaand make thelangis "unknown" or null,metais not null then prepend thelanginto themetaand make thelangagain "unknown" or null,Here is two AST examples before and after :
Then maybe we can highlight any line without specifying any language or without the text
unknownas a dummy language.