Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions parser/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,24 @@ func matchTableCellTokens(tokens []*tokenizer.Token) (int, bool) {
}

pipes := 0
for _, token := range tokens {
escapeNextPipe := false
for i, token := range tokens {
if token.Type == tokenizer.Backslash {
escapeNextPipe = true
continue
}
if token.Type == tokenizer.Pipe {
pipes++
if escapeNextPipe {
tokens[i].Type = ""
tokens[i].Value = "|"
tokens[i-1].Type = ""
tokens[i-1].Value = ""
escapeNextPipe = false
} else {
pipes++
}
} else {
escapeNextPipe = false
}
}
cells := tokenizer.Split(tokens, tokenizer.Pipe)
Expand Down
22 changes: 22 additions & 0 deletions parser/tests/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ func TestTableParser(t *testing.T) {
},
},
},
{
text: "| header |\n| --- |\n| cell\\|\\|cell |\n",
node: &ast.Table{
Header: []ast.Node{
&ast.Paragraph{
Children: []ast.Node{
&ast.Text{Content: "header"},
},
},
},
Delimiter: []string{"---"},
Rows: [][]ast.Node{
{
&ast.Paragraph{
Children: []ast.Node{
&ast.Text{Content: "cell||cell"},
},
},
},
},
},
},
}

for _, test := range tests {
Expand Down