Skip to content

Commit

Permalink
Merge pull request #76 from observablehq/differentiable-pre
Browse files Browse the repository at this point in the history
Differentiate marked-generated pre elements by adding a class to them.
  • Loading branch information
tmcw authored Nov 27, 2018
2 parents 37996d8 + 340921f commit 5d188ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/md.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ export default function(require) {
var root = document.createElement("div");
root.innerHTML = marked(string, {langPrefix: ""}).trim();
var code = root.querySelectorAll("pre code[class]");
if (code.length > 0) require("@observablehq/[email protected]/highlight.min.js").then(function(hl) { code.forEach(hl.highlightBlock); });
if (code.length > 0) {
require("@observablehq/[email protected]/highlight.min.js").then(function(hl) {
code.forEach(function (block) {
hl.highlightBlock(block);
block.parentNode.classList.add('observablehq--md-pre');
});
});
}
return root;
}, function() {
return document.createElement("div");
Expand Down

0 comments on commit 5d188ac

Please sign in to comment.