mirror of
https://github.com/danog/blackfriday.git
synced 2024-11-26 20:14:43 +01:00
Fix rendering of tables
Add proper capture groups to fix the order of bits and pieces.
This commit is contained in:
parent
d1b544e278
commit
f8378658c0
36
block.go
36
block.go
@ -689,23 +689,25 @@ func (p *parser) table(data []byte) int {
|
||||
|
||||
var body bytes.Buffer
|
||||
|
||||
for i < len(data) {
|
||||
pipes, rowStart := 0, i
|
||||
for ; data[i] != '\n'; i++ {
|
||||
if data[i] == '|' {
|
||||
pipes++
|
||||
body.Write(p.r.CaptureWrites(func() {
|
||||
for i < len(data) {
|
||||
pipes, rowStart := 0, i
|
||||
for ; data[i] != '\n'; i++ {
|
||||
if data[i] == '|' {
|
||||
pipes++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if pipes == 0 {
|
||||
i = rowStart
|
||||
break
|
||||
}
|
||||
if pipes == 0 {
|
||||
i = rowStart
|
||||
break
|
||||
}
|
||||
|
||||
// include the newline in data sent to tableRow
|
||||
i++
|
||||
p.tableRow(&body, data[rowStart:i], columns, false)
|
||||
}
|
||||
// include the newline in data sent to tableRow
|
||||
i++
|
||||
p.tableRow(data[rowStart:i], columns, false)
|
||||
}
|
||||
}))
|
||||
|
||||
p.r.Table(header.Bytes(), body.Bytes(), columns)
|
||||
|
||||
@ -819,12 +821,14 @@ func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns
|
||||
return
|
||||
}
|
||||
|
||||
p.tableRow(out, header, columns, true)
|
||||
out.Write(p.r.CaptureWrites(func() {
|
||||
p.tableRow(header, columns, true)
|
||||
}))
|
||||
size = i + 1
|
||||
return
|
||||
}
|
||||
|
||||
func (p *parser) tableRow(out *bytes.Buffer, data []byte, columns []int, header bool) {
|
||||
func (p *parser) tableRow(data []byte, columns []int, header bool) {
|
||||
i, col := 0, 0
|
||||
var rowWork bytes.Buffer
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user