diff --git a/src/block.ts b/src/block.ts index 7df45e4..7ffb864 100644 --- a/src/block.ts +++ b/src/block.ts @@ -642,7 +642,7 @@ class EventParser { if (colons.length >= container.extra.colons) { container.extra.endFenceStartpos = m.startpos; container.extra.endFenceEndpos = m.startpos + colons.length - 1; - this.pos = m.endpos; // before newline + this.pos = this.starteol; // before newline (CRLF-safe, see #113) return false; } } diff --git a/src/html.spec.ts b/src/html.spec.ts index 2ea00ba..e83a775 100644 --- a/src/html.spec.ts +++ b/src/html.spec.ts @@ -36,4 +36,19 @@ rendering the light markup format djot.

); }); + it("closes a fenced div with CRLF line endings", () => { + // Regression test for issue #113: with CRLF line endings the closing + // ::: fence must close the div, so following content ("after") lands + // outside the div rather than being swallowed inside an unclosed div. + const expected = +`
+

hello

+
+

after

+`; + expect(renderHTML(parse(":::\r\nhello\r\n:::\r\nafter\r\n"))).toEqual(expected); + // The LF equivalent is unchanged and produces byte-identical HTML. + expect(renderHTML(parse(":::\nhello\n:::\nafter\n"))).toEqual(expected); + }); + });