-
-
Notifications
You must be signed in to change notification settings - Fork 894
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
代码高亮不指定语言时使用 hljs.defaultLang
进行渲染
#1382
Comments
加一个 ignore 是否够用了? |
嗯能够解决主要问题,谢谢啦,以后有机会可以再完善。 |
好像可以用 enable
|
啊不是,原来的enable我知道…是这样,markdown里既有不指定语言的代码块,又有指定语言的,如果 例:
|
不太会pull request,我觉得在 if(hljsOption.defaultLang && !block.matches("[class*=language-]")) {
// no language specified
if(hljsOption.defaultLang === "nohighlight") block.classList.add("nohighlight"); // hljs supports this and will skip; alternatively, just "return;"
else if(hljsOption.defaultLang !== "auto") block.classList.add("language-" + hljsOption.defaultLang); // deals with everything else
} 就完全ok了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你在什么场景下需要该功能?
现在如果代码块里不指定语言,代码高亮器会猜一个语言,而如果指定一个不存在的语言,会fallback到不高亮模式。
因为不少自然的md code里都会有不指定语言的代码块,依照情境有时会希望在不指定语言的时候也不高亮,或是当成plaintext处理。大概就是每次parse到一个纯的代码块,在传给hljs之前可以预处理一下。
描述最优的解决方案
在options.preview.hljs里增加一个类似defaultLang的项,可选值最好可以包括
```plaintext
)描述候选的解决方案
因为目前如果要(对部分代码块)跳过hljs,得故意指定一个不存在的语言,希望至少可以有一个无warning实现nohighlight的方法。
The text was updated successfully, but these errors were encountered: