Skip to content

Commit 233c63a

Browse files
committed
Strip all markup inside code blocks
1 parent cb9f529 commit 233c63a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

wattsi2bikeshed.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ function convert(infile, outfile) {
378378

379379
for (const code of document.querySelectorAll('pre > code')) {
380380
const pre = code.parentNode;
381+
if (pre.firstChild !== code || pre.lastChild !== code) {
382+
console.warn('Skipping a <pre><code> with sibling nodes: ' + pre.outerHTML);
383+
continue;
384+
}
381385
if (code.hasAttribute('class')) {
382386
switch (code.className) {
383387
case 'idl':
@@ -395,15 +399,11 @@ function convert(infile, outfile) {
395399
default:
396400
console.warn('Unhandled <pre><code> class:', code.className);
397401
}
398-
code.removeAttribute('class');
399-
}
400-
if (code.getAttribute(kCrossRefAttribute) === '') {
401-
code.removeAttribute(kCrossRefAttribute);
402-
}
403-
if (code.hasAttributes()) {
404-
console.warn('Discarding <code> attributes:', code.outerHTML);
405402
}
406-
replaceWithChildren(code);
403+
// Strip any markup in the code.
404+
// TODO: Indent as much as the <pre> element is indented. This is the
405+
// style in other WHATWG specs using Bikeshed.
406+
pre.textContent = '\n' + pre.textContent.trim() + '\n';
407407
}
408408

409409
// Link <code> to the right thing.

0 commit comments

Comments
 (0)