Skip to content

Commit

Permalink
experiment: remove cspell directives from code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pdaoust committed Nov 28, 2024
1 parent e3be354 commit 699af44
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 11ty-extensions/eleventy-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default function(eleventyConfig) {
pre.className += ' hljs-container';
const code = pre.querySelector('code');
const maybeLanguage = code.className.match(/(?<=\blanguage-)[A-Za-z0-9_-]+/);
const blockText = he.decode(code.textContent);
let blockText = he.decode(code.textContent);
// Erase cspell directives from sample code.
blockText = blockText.replace(/(#|\/\/|\/\*)\s+(cspell|spell-?checker):\s*[a-z-]+(\s+\*\/)?/i, "");
if (maybeLanguage) {
code.innerHTML = hljs.highlight(blockText, {language: maybeLanguage[0]}).value;
} else {
Expand Down

0 comments on commit 699af44

Please sign in to comment.