Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core/highlight): allow highlighting code blocks #1061

Merged
merged 2 commits into from Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/highlight.js
Expand Up @@ -45,7 +45,7 @@ export async function run(conf, doc, cb) {

const promisesToHighlight = Array
.from(
doc.querySelectorAll("pre:not(.idl):not(.highlightdone)")
doc.querySelectorAll("pre:not(.idl):not(.nohighlight),code.highlight")
)
.map(element => {
return new Promise((resolve, reject) => {
Expand All @@ -66,7 +66,9 @@ export async function run(conf, doc, cb) {
}
worker.removeEventListener("message", listener);
element.innerHTML = ev.data.value;
element.classList.add("hljs");
if (element.localName === "pre") {
element.classList.add("hljs");
}
resolve();
});
setTimeout(() => {
Expand Down
4 changes: 2 additions & 2 deletions worker/respec-worker.js
Expand Up @@ -26,8 +26,8 @@ self.addEventListener("message", function(e) {
} catch (err) {
console.error("Could not transform some code?", err);
// Post back the original unhighlighted code.
const fallbackData = Object.assign({}, e.data, {value: e.data.code});
self.postMessage(data);
const fallbackData = Object.assign({}, e.data, { value: e.data.code });
self.postMessage(fallbackData);
}
}
});