Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 1612a9d

Browse files
author
Matthew Williams
committed
Fix md parser excluding table headers
1 parent 3d93242 commit 1612a9d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

claat/parser/md/parse.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,10 @@ func table(ds *docState) types.Node {
561561
var rows [][]*types.GridCell
562562
for _, tr := range findChildAtoms(ds.cur, atom.Tr) {
563563
ds.push(tr)
564+
fmt.Println(tr)
564565
r := tableRow(ds)
565566
ds.pop()
567+
fmt.Println(r)
566568
rows = append(rows, r)
567569
}
568570
if len(rows) == 0 {
@@ -573,8 +575,14 @@ func table(ds *docState) types.Node {
573575

574576
func tableRow(ds *docState) []*types.GridCell {
575577
var row []*types.GridCell
576-
for td := findAtom(ds.cur, atom.Td); td != nil; td = td.NextSibling {
577-
if td.DataAtom != atom.Td {
578+
579+
firstChild := findAtom(ds.cur, atom.Td)
580+
// If there is no Td child found, could be table header so look for Th
581+
if firstChild == nil {
582+
firstChild = findAtom(ds.cur, atom.Th)
583+
}
584+
for td := firstChild; td != nil; td = td.NextSibling {
585+
if td.DataAtom != atom.Td && td.DataAtom != atom.Th {
578586
continue
579587
}
580588
ds.push(td)

0 commit comments

Comments
 (0)