Closed MarkusWendorf closed 2 years ago
Does your remark plugin change the code node into another type of node? If that's the case, if you put your plugin before code-hike's, code-hike should ignore that node.
@pomber it's a rehype plugin, so it's always after codehike I guess.
Regardless, I think it would be better to not transform unsupported languages and change the warning, what do you think?
console.warn(
"[Code Hike warning]",
`${lang} is not a valid language. You can use language "text" instead, but you will lose syntax highlighting.`
)
I was thinking of another approach (that isn't a breaking change). Adding a ignoreLanguages
config. Something like:
remarkPlugins: [
[
remarkCodeHike,
{
theme: someTheme,
lineNumbers: true,
ignoreLanguages: ["", "mermaid"]
},
],
],
That should also work with mermaid.
Does that work for you?
Yes that would work.
Changed the name from the example from ignoreLanguages
to skipLanguages
@pomber tested the pre-release 0.6.2-next.1
. Works as intended, thank you.
:rocket: Issue was released in v0.6.2
:rocket:
Hello, and thanks again for all the work.
I have a private rehype plugin that relies on code blocks with a specific language to be set (think
bla-bla-blub
, more like a private api). It also relies on the fact that these code blocks are not manipulated by remark plugins (expecting a specific node/tree structure).Right now a warning is displayed for unsupported languages, but the transform is happening regardless (with lang=text).
I would like to have the option to disable this behaviour and not do any transformations on unsupported languages.
Another option would be to not highlight unsupported languages and tell the user to use
lang=text
.https://github.com/code-hike/codehike/blob/3e61df61aa5ffa833093694e11bae1c523297e51/packages/mdx/src/highlighter/index.tsx#L60-L64