mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
A better fix for counting columns
This commit is contained in:
parent
289c7041c7
commit
3259c6dc4b
11
block.go
11
block.go
|
@ -818,7 +818,7 @@ func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags)
|
||||||
if data[0] == '|' {
|
if data[0] == '|' {
|
||||||
colCount--
|
colCount--
|
||||||
}
|
}
|
||||||
lastPipe := backupWindowsNewline(i, data)
|
lastPipe := backtrackAnyNewlines(data, i)
|
||||||
if lastPipe < len(data) && data[lastPipe] == '|' && !isBackslashEscaped(data, lastPipe) {
|
if lastPipe < len(data) && data[lastPipe] == '|' && !isBackslashEscaped(data, lastPipe) {
|
||||||
colCount--
|
colCount--
|
||||||
}
|
}
|
||||||
|
@ -1652,3 +1652,12 @@ func backupWindowsNewline(i int, data []byte) int {
|
||||||
}
|
}
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// backtrackAnyNewlines decrements i until it hits any non-newline character or
|
||||||
|
// becomes zero.
|
||||||
|
func backtrackAnyNewlines(data []byte, i int) int {
|
||||||
|
for i > 0 && i < len(data) && iseol(data[i]) {
|
||||||
|
i--
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user