Skip to content

Commit

Permalink
Merge branch 'develop' into gh-pages
Browse files Browse the repository at this point in the history
* develop:
  v9.1.0
  feat(core/markdown): allow syntax highlight off main thread (#1066)
  • Loading branch information
marcoscaceres committed Feb 2, 2017
2 parents aa7846c + 0e83cae commit ae2bd05
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 50 deletions.
2 changes: 1 addition & 1 deletion builds/respec-w3c-common.build.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions builds/respec-w3c-common.js

Large diffs are not rendered by default.

36 changes: 1 addition & 35 deletions js/core/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,15 @@
define([
"deps/marked",
"core/utils",
"deps/highlight",
"deps/beautify-html",
"core/beautify-options",
], function(marked, utils, hljs, beautify, beautifyOps) {
var defaultLanguages = Object.freeze([
"css",
"html",
"http",
"js",
"json",
"markdown",
"xml",
]);

hljs.configure({
tabReplace: " ", // 2 spaces
});
], function(marked, utils, beautify, beautifyOps) {

marked.setOptions({
sanitize: false,
gfm: true,
highlight: makeHighlightHelper(),
});

function makeHighlightHelper() {
var div = document.createElement("div");
return function(code, language) {
var leftPadding = utils.calculateLeftPad(code);
var normalizedCode;
if (leftPadding) {
var leftPaddingMatcher = new RegExp("^ {" + leftPadding + "}", "gm");
normalizedCode = code.replace(leftPaddingMatcher, "");
} else {
normalizedCode = code;
}
div.innerHTML = normalizedCode;
var cleanCode = div.textContent;
var possibleLanguages = [].concat(language || defaultLanguages);
var highlightedCode = hljs.highlightAuto(cleanCode, possibleLanguages);
return highlightedCode.value;
};
}

function toHTML(text) {
var normalizedLeftPad = utils.normalizePadding(text);
// As markdown is pulled from HTML, > is already escaped and
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "respec",
"version": "9.0.0",
"version": "9.1.0",
"license": "W3C",
"description": "A technical specification pre-processor.",
"engines": {
Expand Down

0 comments on commit ae2bd05

Please sign in to comment.