markdown: support plain (no highlight) code block

Sometimes we want no-highlight code blocks.
For example, log files, languages highlight.js does not know.

``plain
codeblock here won't get highlighted.
``

You can use `text` or `txt`, too.

Using `plain` and `text` as markup is inspired by
[沙渺](http://segmentfault.com/q/1010000000354936)。
This commit is contained in:
Jakukyo Friel 2014-02-09 08:51:53 +08:00
parent 40941a9acc
commit 845138a8b8

View File

@ -130,7 +130,9 @@ for (var i = 0; i < codes.length; i ++) {
}
}
if (!!finalLang) {
if (["plain", "text", "txt"].indexOf(lang) != -1) {
code.className = code.className.replace(/ *\blang-(plain|text|txt)\b/ig, "no-highlight");
} else if (!!finalLang) {
var result = hljs.highlight(finalLang, code.textContent, true);
code.innerHTML = result.value;
highlighted = true;