Skip to content
Permalink
Browse files

feat: highlight code fence block at build time

  • Loading branch information...
ulivz committed Feb 8, 2019
1 parent 3d04c0b commit 475448b232e1433d7226211cb6135a3e09fb7d31
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/html.js
@@ -27,7 +27,8 @@ const transformHeaders = compose(
})
return $
}
)
),
highlight
)

function getHash(i) {
@@ -49,3 +50,14 @@ function prune(html) {
.replace(/<p><br\s\/><\/p>/g, '')
.replace(/<p><span><br\s\/><\/span><\/p>/g, '')
}

const CODE_FENCE = '```'

function highlight($) {
$('pre').replaceWith((i, el) => {
const lang = $(el).attr('data-lang')
const code = $(el).children('code').text()
return `\n\n ${CODE_FENCE} ${lang} \n ${code} \n ${CODE_FENCE} \n\n`
})
return $
}

0 comments on commit 475448b

Please sign in to comment.
You can’t perform that action at this time.