mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Merge branch 'master'
Conflicts: package.json
This commit is contained in:
@@ -3,6 +3,15 @@ import emoji from 'markdown-it-emoji'
|
||||
import math from '@rokt33r/markdown-it-math'
|
||||
import hljs from 'highlight.js'
|
||||
|
||||
function createGutter (str) {
|
||||
let lc = (str.match(/\n/g) || []).length
|
||||
let lines = []
|
||||
for (let i = 1; i <= lc; i++) {
|
||||
lines.push('<span>' + i + '</span>')
|
||||
}
|
||||
return '<span class="lineNumber">' + lines.join('') + '</span>'
|
||||
}
|
||||
|
||||
var md = markdownit({
|
||||
typographer: true,
|
||||
linkify: true,
|
||||
@@ -11,12 +20,16 @@ var md = markdownit({
|
||||
highlight: function (str, lang) {
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
try {
|
||||
return '<pre class="hljs"><code>' +
|
||||
return '<pre class="hljs">' +
|
||||
createGutter(str) +
|
||||
'<code>' +
|
||||
hljs.highlight(lang, str).value +
|
||||
'</code></pre>'
|
||||
} catch (e) {}
|
||||
}
|
||||
return '<pre class="hljs"><code>' +
|
||||
return '<pre class="hljs">' +
|
||||
createGutter(str) +
|
||||
'<code>' +
|
||||
str.replace(/\&/g, '&').replace(/\</g, '<').replace(/\>/g, '>').replace(/\"/g, '"') +
|
||||
'</code></pre>'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user