|
@@ -13,16 +13,8 @@ global.Prism = Prism
|
|
|
require('prismjs/components/')()
|
|
|
delete global.Prism
|
|
|
|
|
|
-const rawInlineCodeRx = /<code>([^\n]+?)<\/code>/ig
|
|
|
const unhighlightedCodeRx = /<pre><code class="([^"]*)?">([\s\S]*?)<\/code><\/pre>/igm
|
|
|
|
|
|
-function escapeInlineCodeBlocks (data) {
|
|
|
- data.content = data.content.replace(rawInlineCodeRx, (_, code) => {
|
|
|
- return `<code>${entities.encode(code)}</code>`
|
|
|
- })
|
|
|
- return data
|
|
|
-}
|
|
|
-
|
|
|
function highlight (lang, code) {
|
|
|
const startTag = `<figure class="highlight ${lang}"><table><tr><td class="code"><pre>`
|
|
|
const endTag = `</pre></td></tr></table></figure>`
|
|
@@ -69,7 +61,6 @@ hexo.extend.tag.register('codeblock', code, true)
|
|
|
hexo.extend.tag.register('include_code', includeCode, { async: true })
|
|
|
hexo.extend.tag.register('include-code', includeCode, { async: true })
|
|
|
|
|
|
-hexo.extend.filter.register('after_post_render', escapeInlineCodeBlocks)
|
|
|
// Hexo includes its own code block handling by default which may
|
|
|
// cause the above to miss some things, so do another pass when the page
|
|
|
// is done rendering to pick up any code blocks we may have missed.
|