diff --git a/src/Spec.ts b/src/Spec.ts index 253e1ff2..73babf03 100644 --- a/src/Spec.ts +++ b/src/Spec.ts @@ -1955,9 +1955,7 @@ async function walk(walker: TreeWalker, context: Context) { previousInNoEmd = false; } - if (context.node.nodeType === 3) { - // walked to a text node - + if (context.node.nodeType === 3 /* Node.TEXT_NODE */) { if (context.node.textContent!.trim().length === 0) return; // skip empty nodes; nothing to do! const clause = context.clauseStack[context.clauseStack.length - 1] || context.spec; @@ -1966,13 +1964,19 @@ async function walk(walker: TreeWalker, context: Context) { // new nodes as a result of emd processing should be skipped context.inNoEmd = true; let node = context.node as Node | null; - while (node && !node.nextSibling) { + function nextRealSibling(node: Node | null) { + while (node?.nextSibling?.nodeType === 8 /* Node.COMMENT_NODE */) { + node = node.nextSibling; + } + return node?.nextSibling; + } + while (node && !nextRealSibling(node)) { node = node.parentNode; } if (node) { // inNoEmd will be set to false when we walk to this node - context.followingEmd = node.nextSibling; + context.followingEmd = nextRealSibling(node)!; } // else, there's no more nodes to process and inNoEmd does not need to be tracked diff --git a/test/baselines/generated-reference/ecmarkdown.html b/test/baselines/generated-reference/ecmarkdown.html new file mode 100644 index 00000000..9e9c098d --- /dev/null +++ b/test/baselines/generated-reference/ecmarkdown.html @@ -0,0 +1,14 @@ + +
+
+ +

1 ecmarkdown basics

+

ecmarkdown like v works before and after comments v.

+
+ +
\ No newline at end of file diff --git a/test/baselines/sources/ecmarkdown.html b/test/baselines/sources/ecmarkdown.html new file mode 100644 index 00000000..5412f2a0 --- /dev/null +++ b/test/baselines/sources/ecmarkdown.html @@ -0,0 +1,10 @@ +
+toc: false
+copyright: false
+assets: none
+
+ +

ecmarkdown basics

+

ecmarkdown like _v_ works before and after comments _v_.

+
+