-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Highlight lines without specifying a language #55
Comments
I created a new npm package remark-flexible-code-titles to add title element or container element or both for the code nodes in markdown. It supports to use the For example, you can write markdown code blocks like follows: ```:title
lines...
``` ```{ 1, 3 - 6 }
lines...
``` ```showLineNumbers
lines...
``` ```:title {2}
lines...
``` ```:title showLineNumbers
lines...
``` It has options for not adding title or container or for not adding both, just for usage of rehype-prism-plus without specifying language. For more explanation, you can have a look at the documentation here |
Great work @talatkuyuk! Was looking for a solution with support for not explicit language. I'll definitely give it a try. |
@talatkuyuk sorry for the late reply, but congrats on publishing a workaround that support titles as well. The current approach tries to follow GFM syntax, namely:
So my preference would be to still reserve the first word for the language and go with the dummy language approach:
where |
Thanks for yor reply @timlrx, Those who want to go with a dummy language, I am planning to set another option in the import remarkCodeTitles from "remark-flexible-code-titles";
...
.use(remarkCodeTitles, {
handleMissingLanguageAs: "unknown", // "dummy" what so ever
}) And the user will be able to continue the markdown code block without language, or without dummy language. Of course it is a preference if a user write down explicitly the language as "unknown" for the code blocks, but the |
I added an option in So, the https://github.com/ipikuka/remark-flexible-code-titles/releases/tag/v1.1.3 |
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:
lang
starts with "{"meta
is null then copy the content of thelang
into themeta
and make thelang
is "unknown" or null,meta
is not null then prepend thelang
into themeta
and make thelang
again "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
unknown
as a dummy language.The text was updated successfully, but these errors were encountered: