Closed msmsimondean closed 3 years ago
(You can use more ticks around your markdown code, if you'd like to fix your examples)
I think there's such an option in lowlight, so it should be possible and relatively easy to add it here. Interested in a PR?
@msmsimondean Friendly ping!
Here's a bit of context. It seems the intellisense in IntelliJ likes to put $xslt
as the language in Markdown code blocks. Consequently in the README.md documents I'm working with, lots of them contain $xslt
as the language. It causes remark to throw an exception (due to remark-highlight.js) when it encounters such files.
I thought (perhaps naively) that as remark (and Unified) has this great VFile pattern for processor output, it might be worth using that for errors like this where the code language is unknown? I have no idea how difficult / feasible that would be. I've only had a brief look at the code in this module and how it interacts with lowlight
. Thanks!
For the moment, I'm wrapping remark in an try catch to catch this error and presenting that back in my UI
The option is in rehype-highlight.
As the readme for this project says: you should probably use that project.
Great, thanks for the info
Going to close this as this package will soon be deprecated and archived, to make it clearer that rehype-highlight
is the suggested and preferred route
Subject of the feature
Would it be possible to add an option for unknown languages to be ignored rather than raising an error? Alternatively, could such errors be recorded in the vfile output of remark rather than throwing an error?
Problem
I am parsing a number of markdown documents that I don't have direct control of. Some of the documents contain invalid or unknown langauges in their code blocks.
Expected behavior
Input:
Expected behavious: when remark-highlight.js is passed an option call something like
{ ignoreUnknown: true }
it ignores the unknown lanugage rather than throwing an exception.Alternatives
I'm using processSync(). I've considered wrapping it in a try catch.