inject the line break earlier
This commit is contained in:
parent
c2773edb00
commit
4817e23eee
3 changed files with 3 additions and 6 deletions
|
@ -22,10 +22,6 @@ func FormatHeadings(in chan pipe.StreamItem) chan pipe.StreamItem {
|
||||||
if len(sub) > 0 {
|
if len(sub) > 0 {
|
||||||
data = bytes.Replace(data, sub[1], append(sub[1], []byte(" ")...), 1)
|
data = bytes.Replace(data, sub[1], append(sub[1], []byte(" ")...), 1)
|
||||||
}
|
}
|
||||||
// generally if we deal with a heading, add an extra blank line
|
|
||||||
if bytes.HasPrefix(data, []byte("#")) {
|
|
||||||
data = append(data, '\n')
|
|
||||||
}
|
|
||||||
// writeback
|
// writeback
|
||||||
out <- pipe.NewItem(b.Index(), data)
|
out <- pipe.NewItem(b.Index(), data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ func RemoveFrontMatter(in chan pipe.StreamItem) chan pipe.StreamItem {
|
||||||
data = bytes.Replace(data, match[0], []byte(""), 1)
|
data = bytes.Replace(data, match[0], []byte(""), 1)
|
||||||
for _, title := range re2.FindAllSubmatch(match[0], 1) {
|
for _, title := range re2.FindAllSubmatch(match[0], 1) {
|
||||||
// add title
|
// add title
|
||||||
data = []byte(fmt.Sprintf("# %s\n", title[1]))
|
data = []byte(fmt.Sprintf("# %s\n\n", title[1]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out <- pipe.NewItem(b.Index(), data)
|
out <- pipe.NewItem(b.Index(), data)
|
||||||
|
|
|
@ -168,7 +168,8 @@ func fence(m *fsm, data []byte) stateFn {
|
||||||
|
|
||||||
func toFence(m *fsm, data []byte) stateFn {
|
func toFence(m *fsm, data []byte) stateFn {
|
||||||
if needsFence(data) {
|
if needsFence(data) {
|
||||||
m.blockBuffer = append(m.blockBuffer, append(data[4:], '\n')...)
|
data = append(data, '\n')
|
||||||
|
m.blockBuffer = append(m.blockBuffer, data[4:]...)
|
||||||
|
|
||||||
return toFence
|
return toFence
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue