Skip to content

Commit

Permalink
added gitter for codeblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lazytyper committed Apr 29, 2016
1 parent f6208c1 commit 891cd31
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ node_modules/*
/dist
/compiled
/secret
*.log
17 changes: 15 additions & 2 deletions browser/lib/markdown.js
Expand Up @@ -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,
Expand All @@ -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>'
}
Expand Down
13 changes: 13 additions & 0 deletions browser/styles/mixins/marked.styl
Expand Up @@ -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
Expand Down

0 comments on commit 891cd31

Please sign in to comment.