1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 18:56:22 +00:00

followed eslintrc

This commit is contained in:
Masahide Morio
2018-02-19 23:02:25 +09:00
parent c43589fe6a
commit 3194a7b1a2

View File

@@ -10,7 +10,7 @@ const katex = window.katex
const config = ConfigManager.get() const config = ConfigManager.get()
function createGutter (str, fc) { function createGutter (str, fc) {
if(Number.isNaN(fc)) fc = 1 if (Number.isNaN(fc)) fc = 1
const lc = (str.match(/\n/g) || []).length + fc - 1 const lc = (str.match(/\n/g) || []).length + fc - 1
const lines = [] const lines = []
for (let i = fc; i <= lc; i++) { for (let i = fc; i <= lc; i++) {
@@ -26,22 +26,22 @@ var md = markdownit({
xhtmlOut: true, xhtmlOut: true,
breaks: true, breaks: true,
highlight: function (str, lang) { highlight: function (str, lang) {
let delimiter = ":"; const delimiter = ':'
let langinfo = lang.split(delimiter); const langInfo = lang.split(delimiter)
let lang = langinfo[0]; const langType = langInfo[0]
let filename = langinfo[1] || ""; const fileName = langInfo[1] || ''
let fc = parseInt(langinfo[2],10); const fc = parseInt(langInfo[2], 10)
if (lang === 'flowchart') { if (langType === 'flowchart') {
return `<pre class="flowchart">${str}</pre>` return `<pre class="flowchart">${str}</pre>`
} }
if (lang === 'sequence') { if (langType === 'sequence') {
return `<pre class="sequence">${str}</pre>` return `<pre class="sequence">${str}</pre>`
} }
return '<pre class="code">' + return '<pre class="code">' +
'<span class="filename">' + filename + '</span>' + '<span class="filename">' + fileName + '</span>' +
createGutter(str, fc) + createGutter(str, fc) +
'<code class="' + lang + '">' + '<code class="' + langType + '">' +
str + str +
'</code></pre>' '</code></pre>'
} }