Browse Source

Demo: updated highlighting style

pull/186/head
Vitaly Puzrin 9 years ago
parent
commit
88c6e0f8e6
  1. 4
      support/demo_template/index.jade
  2. 25
      support/demo_template/index.js
  3. 3
      support/demo_template/index.styl

4
support/demo_template/index.jade

@ -14,8 +14,8 @@ html
script(src='https://cdn.jsdelivr.net/bootstrap/3.2.0/js/bootstrap.min.js')
link(rel='stylesheet' href='https://cdn.jsdelivr.net/bootstrap/3.2.0/css/bootstrap.css')
script(src='https://cdn.jsdelivr.net/highlight.js/8.5.0/highlight.min.js')
link(rel='stylesheet' href='https://cdn.jsdelivr.net/highlight.js/8.5.0/styles/solarized_light.min.css')
script(src='https://cdn.jsdelivr.net/highlight.js/9.0.0/highlight.min.js')
link(rel='stylesheet' href='https://cdn.jsdelivr.net/highlight.js/9.0.0/styles/monokai-sublime.min.css')
script(src='markdown-it.js')
script(src='https://twemoji.maxcdn.com/twemoji.min.js')

25
support/demo_template/index.js

@ -90,6 +90,31 @@ function mdInit() {
return window.twemoji.parse(token[idx].content);
};
mdHtml.renderer.rules.fence = function (tokens, idx, options, env, slf) {
var escapeHtml = mdHtml.utils.escapeHtml,
unescapeAll = mdHtml.utils.unescapeAll,
token = tokens[idx],
info = token.info ? unescapeAll(token.info).trim() : '',
langName = '',
highlighted;
if (info) {
langName = info.split(/\s+/g)[0];
token.attrPush([ 'class', options.langPrefix + langName ]);
}
if (options.highlight) {
highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
} else {
highlighted = escapeHtml(token.content);
}
return '<pre class="hljs"><code' + slf.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
};
//
// Inject line numbers for sync scroll. Notes:
//

3
support/demo_template/index.styl

@ -77,9 +77,10 @@ body
a:last-child
padding-right 30px
.hljs
/*.hljs
background none
padding 0
*/
.footnotes
-moz-column-count 2

Loading…
Cancel
Save