diff --git a/src/Renderer/HtmlRenderer.php b/src/Renderer/HtmlRenderer.php index 3eea16d..7df6ba6 100644 --- a/src/Renderer/HtmlRenderer.php +++ b/src/Renderer/HtmlRenderer.php @@ -768,7 +768,9 @@ protected function renderListItem(ListItem $node, bool $tight = true): string // This handles both: // 1. Single paragraph:
text
-> text // 2. Paragraph followed by nested list:text
\n(.+?)<\/p>(\n)?/s', '$1$2', $content) ?? $content; + // A data-source-line-only wrapper is stripped too (the source-line + // option must never change structure; the
(.+?)<\/p>(\n)?/s', '$1$2', $content) ?? $content; } // Handle task list items diff --git a/tests/TestCase/SourceLineTrackingTest.php b/tests/TestCase/SourceLineTrackingTest.php index 74b3704..dc7be52 100644 --- a/tests/TestCase/SourceLineTrackingTest.php +++ b/tests/TestCase/SourceLineTrackingTest.php @@ -88,7 +88,9 @@ public function testListSyntheticSeparatorDoesNotBecomeSourceLine(): void $converter = new DjotConverter(sourceLines: true); $html = $converter->convert("- first\n {.note}\n second\n"); - $this->assertStringContainsString('
first
', $html); + // The tight item's lead stays unwrapped (anchor-onlywrappers are + // stripped like plain ones); the li carries the anchor. + $this->assertMatchesRegularExpression('/
second
', $html); $this->assertStringNotContainsString('data-source-line="0"', $html); } @@ -99,11 +101,9 @@ public function testListInsideBlockquoteComposesLineMap(): void $html = $converter->convert("> - quoted item\n> - nested item\n"); $this->assertMatchesRegularExpression('/quoted item
', $html); + $this->assertMatchesRegularExpression('/nested item
', $html); + $this->assertMatchesRegularExpression('/nested
', $html); } + + public function testEnabledOutputIsStructureIdenticalToDisabled(): void + { + // The option is attribute-only: stripping the stamped attributes must + // reproduce the default output byte for byte. Regression: tight list + // items used to growwrappers because the stamped paragraph no + // longer matched the renderer's tight-strip pattern. + $doc = "> - quoted item\n\n- a\n- b\n\n1. loose\n\n para\n\n:: nope\n"; + $off = (new DjotConverter())->convert($doc); + $on = (new DjotConverter(sourceLines: true))->convert($doc); + + $this->assertSame($off, preg_replace('/ data-source-line="\d+"/', '', $on)); + } }