1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

CommonMark

This commit is contained in:
Rokt33r
2016-01-06 04:41:19 +09:00
parent 15560a3bce
commit c8337c7287
11 changed files with 69 additions and 27 deletions

View File

@@ -1,23 +1,20 @@
import markdownit from 'markdown-it'
import hljs from 'highlight.js'
import emoji from 'markdown-it-emoji'
import math from 'markdown-it-math'
import hljs from 'highlight.js'
var md = markdownit({
typographer: true,
linkify: true,
html: true,
xhtmlOut: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value
} catch (__) {}
} catch (e) {}
}
try {
return hljs.highlightAuto(str).value
} catch (__) {}
return ''
return str
}
})
md.use(emoji)
@@ -33,6 +30,7 @@ md.use(math, {
let originalRenderToken = md.renderer.renderToken
md.renderer.renderToken = function renderToken (tokens, idx, options) {
let token = tokens[idx]
let result = originalRenderToken.call(md.renderer, tokens, idx, options)
if (token.map != null) {
return result + '<a class=\'lineAnchor\' data-key=\'' + token.map[0] + '\'></a>'