mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Render codefence by codemirror rather than by hljs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import CodeMirror from 'codemirror'
|
||||
import _ from 'lodash'
|
||||
|
||||
CodeMirror.modeInfo.push({name: 'Stylus', mime: 'text/x-styl', mode: 'stylus', ext: ['styl']})
|
||||
CodeMirror.modeInfo.push({name: 'Stylus', mime: 'text/x-styl', mode: 'stylus', ext: ['styl'], alias: ['styl']})
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
const hljsThemeList = [
|
||||
{caption: 'Default', name: 'default'},
|
||||
{caption: 'Agate', name: 'agate'},
|
||||
{caption: 'Androidstudio', name: 'androidstudio'},
|
||||
{caption: 'Arduino Light', name: 'arduino-light'},
|
||||
{caption: 'Arta', name: 'arta'},
|
||||
{caption: 'Ascetic', name: 'ascetic'},
|
||||
{caption: 'Atelier Cave Dark', name: 'atelier-cave-dark'},
|
||||
{caption: 'Atelier Cave Light', name: 'atelier-cave-light'},
|
||||
{caption: 'Atelier Dune Dark', name: 'atelier-dune-dark'},
|
||||
{caption: 'Atelier Dune Light', name: 'atelier-dune-light'},
|
||||
{caption: 'Atelier Estuary Dark', name: 'atelier-estuary-dark'},
|
||||
{caption: 'Atelier Estuary Light', name: 'atelier-estuary-light'},
|
||||
{caption: 'Atelier Forest Dark', name: 'atelier-forest-dark'},
|
||||
{caption: 'Atelier Forest Light', name: 'atelier-forest-light'},
|
||||
{caption: 'Atelier Heath Dark', name: 'atelier-heath-dark'},
|
||||
{caption: 'Atelier Heath Light', name: 'atelier-heath-light'},
|
||||
{caption: 'Atelier Lakeside Dark', name: 'atelier-lakeside-dark'},
|
||||
{caption: 'Atelier Lakeside Light', name: 'atelier-lakeside-light'},
|
||||
{caption: 'Atelier Plateau Dark', name: 'atelier-plateau-dark'},
|
||||
{caption: 'Atelier Plateau Light', name: 'atelier-plateau-light'},
|
||||
{caption: 'Atelier Savanna Dark', name: 'atelier-savanna-dark'},
|
||||
{caption: 'Atelier Savanna Light', name: 'atelier-savanna-light'},
|
||||
{caption: 'Atelier Seaside Dark', name: 'atelier-seaside-dark'},
|
||||
{caption: 'Atelier Seaside Light', name: 'atelier-seaside-light'},
|
||||
{caption: 'Atelier Sulphurpool Dark', name: 'atelier-sulphurpool-dark'},
|
||||
{caption: 'Atelier Sulphurpool Light', name: 'atelier-sulphurpool-light'},
|
||||
{caption: 'Brown Paper', name: 'brown-paper'},
|
||||
{caption: 'Codepen Embed', name: 'codepen-embed'},
|
||||
{caption: 'Color Brewer', name: 'color-brewer'},
|
||||
{caption: 'Dark', name: 'dark'},
|
||||
{caption: 'Darkula', name: 'darkula'},
|
||||
{caption: 'Docco', name: 'docco'},
|
||||
{caption: 'Dracula', name: 'dracula'},
|
||||
{caption: 'Far', name: 'far'},
|
||||
{caption: 'Foundation', name: 'foundation'},
|
||||
{caption: 'Github Gist', name: 'github-gist'},
|
||||
{caption: 'Github', name: 'github'},
|
||||
{caption: 'Googlecode', name: 'googlecode'},
|
||||
{caption: 'Grayscale', name: 'grayscale'},
|
||||
{caption: 'Gruvbox Dark', name: 'gruvbox.dark'},
|
||||
{caption: 'Gruvbox Light', name: 'gruvbox.light'},
|
||||
{caption: 'Hopscotch', name: 'hopscotch'},
|
||||
{caption: 'Hybrid', name: 'hybrid'},
|
||||
{caption: 'Idea', name: 'idea'},
|
||||
{caption: 'Ir Black', name: 'ir-black'},
|
||||
{caption: 'Kimbie Dark', name: 'kimbie.dark'},
|
||||
{caption: 'Kimbie Light', name: 'kimbie.light'},
|
||||
{caption: 'Magula', name: 'magula'},
|
||||
{caption: 'Mono Blue', name: 'mono-blue'},
|
||||
{caption: 'Monokai Sublime', name: 'monokai-sublime'},
|
||||
{caption: 'Monokai', name: 'monokai'},
|
||||
{caption: 'Obsidian', name: 'obsidian'},
|
||||
{caption: 'Paraiso Dark', name: 'paraiso-dark'},
|
||||
{caption: 'Paraiso Light', name: 'paraiso-light'},
|
||||
{caption: 'Pojoaque', name: 'pojoaque'},
|
||||
{caption: 'Qtcreator Dark', name: 'qtcreator_dark'},
|
||||
{caption: 'Qtcreator Light', name: 'qtcreator_light'},
|
||||
{caption: 'Railscasts', name: 'railscasts'},
|
||||
{caption: 'Rainbow', name: 'rainbow'},
|
||||
{caption: 'School Book', name: 'school-book'},
|
||||
{caption: 'Solarized Dark', name: 'solarized-dark'},
|
||||
{caption: 'Solarized Light', name: 'solarized-light'},
|
||||
{caption: 'Sunburst', name: 'sunburst'},
|
||||
{caption: 'Tomorrow Night Blue', name: 'tomorrow-night-blue'},
|
||||
{caption: 'Tomorrow Night Bright', name: 'tomorrow-night-bright'},
|
||||
{caption: 'Tomorrow Night Eighties', name: 'tomorrow-night-eighties'},
|
||||
{caption: 'Tomorrow Night', name: 'tomorrow-night'},
|
||||
{caption: 'Tomorrow', name: 'tomorrow'},
|
||||
{caption: 'Vs', name: 'vs'},
|
||||
{caption: 'Xcode', name: 'xcode'},
|
||||
{caption: 'Xt 256', name: 'xt256'},
|
||||
{caption: 'Zenburn', name: 'zenburn'}
|
||||
]
|
||||
|
||||
export default function hljsTheme () {
|
||||
return hljsThemeList
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import markdownit from 'markdown-it'
|
||||
import emoji from 'markdown-it-emoji'
|
||||
import math from '@rokt33r/markdown-it-math'
|
||||
import hljs from 'highlight.js'
|
||||
import _ from 'lodash'
|
||||
|
||||
const katex = window.katex
|
||||
@@ -10,9 +9,9 @@ function createGutter (str) {
|
||||
let lc = (str.match(/\n/g) || []).length
|
||||
let lines = []
|
||||
for (let i = 1; i <= lc; i++) {
|
||||
lines.push('<span>' + i + '</span>')
|
||||
lines.push('<span class="CodeMirror-linenumber">' + i + '</span>')
|
||||
}
|
||||
return '<span class="lineNumber">' + lines.join('') + '</span>'
|
||||
return '<span class="lineNumber CodeMirror-gutters">' + lines.join('') + '</span>'
|
||||
}
|
||||
|
||||
var md = markdownit({
|
||||
@@ -21,19 +20,10 @@ var md = markdownit({
|
||||
html: true,
|
||||
xhtmlOut: true,
|
||||
highlight: function (str, lang) {
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
try {
|
||||
return '<pre class="hljs">' +
|
||||
createGutter(str) +
|
||||
'<code>' +
|
||||
hljs.highlight(lang, str).value +
|
||||
'</code></pre>'
|
||||
} catch (e) {}
|
||||
}
|
||||
return '<pre class="hljs">' +
|
||||
return '<pre class="code">' +
|
||||
createGutter(str) +
|
||||
'<code>' +
|
||||
str.replace(/\&/g, '&').replace(/\</g, '<').replace(/\>/g, '>').replace(/\"/g, '"') +
|
||||
'<code class="' + lang + '">' +
|
||||
str +
|
||||
'</code></pre>'
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user