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

added gitter for codeblocks

This commit is contained in:
Egon schmid
2016-04-29 18:30:52 +02:00
parent f6208c1324
commit 891cd3124f
3 changed files with 29 additions and 2 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ node_modules/*
/dist
/compiled
/secret
*.log

View File

@@ -3,6 +3,15 @@ import emoji from 'markdown-it-emoji'
import math from '@rokt33r/markdown-it-math'
import hljs from 'highlight.js'
var createGutter = function (str) {
var lc = (str.match(/\n/g) || []).length;
var lines = [];
for (var i=1; i <= lc; i++) {
lines.push('<span>'+i+'</span>');
}
return '<span>' + 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, '&amp;').replace(/\</g, '&lt;').replace(/\>/g, '&gt;').replace(/\"/g, '&quot;') +
'</code></pre>'
}

View File

@@ -135,6 +135,19 @@ marked()
&>pre
border none
margin -5px
&>span
font-family Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace
display block
float left
margin 0 0.5em 0 -0.5em
border-right 1px solid
text-align right
&>span
display block
padding 0 .5em 0 1em
&>.cl
display block
clear both
table
width 100%
margin 15px 0 25px