mirror of
https://github.com/danog/blackfriday.git
synced 2024-11-30 04:29:13 +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
|
var body bytes.Buffer
|
||||||
|
|
||||||
for i < len(data) {
|
body.Write(p.r.CaptureWrites(func() {
|
||||||
pipes, rowStart := 0, i
|
for i < len(data) {
|
||||||
for ; data[i] != '\n'; i++ {
|
pipes, rowStart := 0, i
|
||||||
if data[i] == '|' {
|
for ; data[i] != '\n'; i++ {
|
||||||
pipes++
|
if data[i] == '|' {
|
||||||
|
pipes++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if pipes == 0 {
|
if pipes == 0 {
|
||||||
i = rowStart
|
i = rowStart
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// include the newline in data sent to tableRow
|
// include the newline in data sent to tableRow
|
||||||
i++
|
i++
|
||||||
p.tableRow(&body, data[rowStart:i], columns, false)
|
p.tableRow(data[rowStart:i], columns, false)
|
||||||
}
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
p.r.Table(header.Bytes(), body.Bytes(), columns)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p.tableRow(out, header, columns, true)
|
out.Write(p.r.CaptureWrites(func() {
|
||||||
|
p.tableRow(header, columns, true)
|
||||||
|
}))
|
||||||
size = i + 1
|
size = i + 1
|
||||||
return
|
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
|
i, col := 0, 0
|
||||||
var rowWork bytes.Buffer
|
var rowWork bytes.Buffer
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user