Permalink
Browse files

added gitter for codeblocks

  • Loading branch information...
1 parent f6208c1 commit 891cd3124f40545dfc2ccdd07373f4e26ec3f2e3 @lazytyper lazytyper committed Apr 29, 2016
Showing with 29 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +15 −2 browser/lib/markdown.js
  3. +13 −0 browser/styles/mixins/marked.styl
View
@@ -7,3 +7,4 @@ node_modules/*
/dist
/compiled
/secret
+*.log
@@ -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>'
}
@@ -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

0 comments on commit 891cd31

Please sign in to comment.