@@ -284,6 +284,51 @@ public function testParseTableWithEqualsHeaderNoSeparatorNeeded(): void
284284 $ this ->assertFalse ($ rows [2 ]->isHeader ());
285285 }
286286
287+ public function testParseTableWithEqualsHeaderAlignmentPropagates (): void
288+ {
289+ // Header alignment should propagate to data cells when no separator row
290+ $ doc = $ this ->parser ->parse ("|=> Right |=< Left |=~ Center | \n| A | B | C | \n| D | E | F | " );
291+
292+ $ table = $ doc ->getChildren ()[0 ];
293+ $ rows = $ table ->getChildren ();
294+
295+ // Header row alignments
296+ $ headerCells = $ rows [0 ]->getChildren ();
297+ $ this ->assertSame (TableCell::ALIGN_RIGHT , $ headerCells [0 ]->getAlignment ());
298+ $ this ->assertSame (TableCell::ALIGN_LEFT , $ headerCells [1 ]->getAlignment ());
299+ $ this ->assertSame (TableCell::ALIGN_CENTER , $ headerCells [2 ]->getAlignment ());
300+
301+ // Data rows should inherit column alignment from header
302+ $ dataCells1 = $ rows [1 ]->getChildren ();
303+ $ this ->assertSame (TableCell::ALIGN_RIGHT , $ dataCells1 [0 ]->getAlignment ());
304+ $ this ->assertSame (TableCell::ALIGN_LEFT , $ dataCells1 [1 ]->getAlignment ());
305+ $ this ->assertSame (TableCell::ALIGN_CENTER , $ dataCells1 [2 ]->getAlignment ());
306+
307+ $ dataCells2 = $ rows [2 ]->getChildren ();
308+ $ this ->assertSame (TableCell::ALIGN_RIGHT , $ dataCells2 [0 ]->getAlignment ());
309+ $ this ->assertSame (TableCell::ALIGN_LEFT , $ dataCells2 [1 ]->getAlignment ());
310+ $ this ->assertSame (TableCell::ALIGN_CENTER , $ dataCells2 [2 ]->getAlignment ());
311+ }
312+
313+ public function testParseTableSeparatorRowOverridesHeaderAlignment (): void
314+ {
315+ // Separator row alignment takes precedence over header |= alignment
316+ $ doc = $ this ->parser ->parse ("|=> Right |=< Left | \n|:--------|------:| \n| A | B | " );
317+
318+ $ table = $ doc ->getChildren ()[0 ];
319+ $ rows = $ table ->getChildren ();
320+
321+ // Header cells get alignment from separator row, not from |= markers
322+ $ headerCells = $ rows [0 ]->getChildren ();
323+ $ this ->assertSame (TableCell::ALIGN_LEFT , $ headerCells [0 ]->getAlignment ());
324+ $ this ->assertSame (TableCell::ALIGN_RIGHT , $ headerCells [1 ]->getAlignment ());
325+
326+ // Data row also uses separator row alignment
327+ $ dataCells = $ rows [1 ]->getChildren ();
328+ $ this ->assertSame (TableCell::ALIGN_LEFT , $ dataCells [0 ]->getAlignment ());
329+ $ this ->assertSame (TableCell::ALIGN_RIGHT , $ dataCells [1 ]->getAlignment ());
330+ }
331+
287332 public function testParseBlockAttributes (): void
288333 {
289334 $ doc = $ this ->parser ->parse ("{.highlight} \n# Heading " );
0 commit comments