Hi!
Is there any way to restore the parsed ast.Node to raw markdown?
I need to extract the table from the markdown and convert it into structured data. I wrote the following code to parse the ast node, but I am having trouble extracting the text from the cell.
ast.Walk(doc, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
if !entering {
return ast.WalkContinue, nil
}
if table, ok := n.(*ast2.Table); ok {
for row := table.FirstChild(); row != nil; row = row.NextSibling() {
if tableRow, ok := row.(*ast2.TableRow); ok {
var rowData []string
for cell := tableRow.FirstChild(); cell != nil; cell = cell.NextSibling() {
// get raw markdown in cell
}
fmt.Println(rowData)
}
}
}
return ast.WalkContinue, nil
})
Can you give me some advice or demo code?
Hi!
Is there any way to restore the parsed ast.Node to raw markdown?
I need to extract the table from the markdown and convert it into structured data. I wrote the following code to parse the ast node, but I am having trouble extracting the text from the cell.
Can you give me some advice or demo code?