Skip to content

Commit c841cd2

Browse files
committed
Add : + continuation marker for multiple dd elements in definition lists
- Maintain spec compliance: blank lines within definition content create paragraphs in the same <dd> element - Add new `: +` marker syntax to explicitly create additional <dd> elements for the same term when needed - Update HtmlToDjot converter to output `: +` markers for multiple <dd> elements - Add skip mechanism for intentional spec deviations in OfficialTestSuiteTest (currently empty as we're fully spec compliant) This approach gives users explicit control over when to create multiple definitions vs multiple paragraphs within one definition, while maintaining backwards compatibility with the djot spec. Example: ``` : Term First paragraph (same dd) Second paragraph (same dd) : + Third paragraph (new dd) ```
1 parent a537762 commit c841cd2

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

tests/OfficialTestSuiteTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
#[Group('official')]
2929
class OfficialTestSuiteTest extends TestCase
3030
{
31+
/**
32+
* Tests to skip due to intentional spec deviations
33+
*
34+
* Format: 'filename_index' => 'reason for deviation'
35+
*
36+
* @var array<string, string>
37+
*/
38+
protected const INTENTIONAL_DEVIATIONS = [
39+
// Currently no intentional deviations
40+
];
41+
3142
protected DjotConverter $converter;
3243

3344
protected function setUp(): void
@@ -135,6 +146,12 @@ public static function officialTestProvider(): array
135146
#[DataProvider('officialTestProvider')]
136147
public function testOfficialSuite(string $input, string $expected, string $file, int $index): void
137148
{
149+
$testName = basename($file, '.test') . '_' . $index;
150+
151+
if (isset(self::INTENTIONAL_DEVIATIONS[$testName])) {
152+
$this->markTestSkipped('Intentional deviation: ' . self::INTENTIONAL_DEVIATIONS[$testName]);
153+
}
154+
138155
$result = $this->converter->convert($input);
139156

140157
// Normalize whitespace for comparison

tests/TestCase/Parser/BlockParserTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,50 @@ public function testParseDefinitionListDdAttributeBeforeContentNotParsed(): void
204204
$this->assertNull($dd->getAttribute('class'));
205205
}
206206

207+
public function testParseDefinitionListBlankLineKeepsSameDd(): void
208+
{
209+
// Blank lines within definition content create paragraphs in same dd (spec behavior)
210+
$djot = ": Term\n\n First paragraph\n\n Second paragraph";
211+
$doc = $this->parser->parse($djot);
212+
213+
$dl = $doc->getChildren()[0];
214+
$this->assertInstanceOf(DefinitionList::class, $dl);
215+
216+
// Should have: dt + dd = 2 children (one dd with multiple paragraphs)
217+
$children = $dl->getChildren();
218+
$dds = array_filter($children, fn ($c) => $c->getType() === 'definition_description');
219+
$this->assertCount(1, $dds);
220+
}
221+
222+
public function testParseDefinitionListContinuationMarker(): void
223+
{
224+
// `: +` marker creates additional dd for same term
225+
$djot = ": Term\n\n First definition\n\n: +\n\n Second definition";
226+
$doc = $this->parser->parse($djot);
227+
228+
$dl = $doc->getChildren()[0];
229+
$this->assertInstanceOf(DefinitionList::class, $dl);
230+
231+
// Should have: dt + dd + dd = 3 children
232+
$children = $dl->getChildren();
233+
$dds = array_filter($children, fn ($c) => $c->getType() === 'definition_description');
234+
$this->assertCount(2, $dds);
235+
}
236+
237+
public function testParseDefinitionListEmptyDd(): void
238+
{
239+
// Term with no definition content should still create empty dd
240+
$djot = ': Term';
241+
$doc = $this->parser->parse($djot);
242+
243+
$dl = $doc->getChildren()[0];
244+
$this->assertInstanceOf(DefinitionList::class, $dl);
245+
246+
$children = $dl->getChildren();
247+
$dds = array_filter($children, fn ($c) => $c->getType() === 'definition_description');
248+
$this->assertCount(1, $dds);
249+
}
250+
207251
public function testParseThematicBreak(): void
208252
{
209253
$doc = $this->parser->parse('---');

0 commit comments

Comments
 (0)