From 4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 22 Nov 2020 15:55:57 +0100 Subject: Update vendor (#1297) --- .../github.com/gomarkdown/markdown/parser/block.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/gomarkdown/markdown/parser') diff --git a/vendor/github.com/gomarkdown/markdown/parser/block.go b/vendor/github.com/gomarkdown/markdown/parser/block.go index a0b80991..5ef55e98 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/block.go +++ b/vendor/github.com/gomarkdown/markdown/parser/block.go @@ -1074,10 +1074,14 @@ func isBackslashEscaped(data []byte, i int) bool { func (p *Parser) tableHeader(data []byte) (size int, columns []ast.CellAlignFlags, table ast.Node) { i := 0 colCount := 1 + headerIsUnderline := true for i = 0; i < len(data) && data[i] != '\n'; i++ { if data[i] == '|' && !isBackslashEscaped(data, i) { colCount++ } + if data[i] != '-' && data[i] != ' ' && data[i] != ':' && data[i] != '|' { + headerIsUnderline = false + } } // doesn't look like a table header @@ -1097,10 +1101,18 @@ func (p *Parser) tableHeader(data []byte) (size int, columns []ast.CellAlignFlag colCount-- } + // if the header looks like a underline, then we omit the header + // and parse the first line again as underline + if headerIsUnderline { + header = nil + i = 0 + } else { + i++ // move past newline + } + columns = make([]ast.CellAlignFlags, colCount) // move on to the header underline - i++ if i >= len(data) { return } @@ -1175,8 +1187,10 @@ func (p *Parser) tableHeader(data []byte) (size int, columns []ast.CellAlignFlag table = &ast.Table{} p.addBlock(table) - p.addBlock(&ast.TableHeader{}) - p.tableRow(header, columns, true) + if header != nil { + p.addBlock(&ast.TableHeader{}) + p.tableRow(header, columns, true) + } size = skipCharN(data, i, '\n', 1) return } -- cgit v1.2.3