Simplification
This commit is contained in:
parent
eab602b092
commit
ad8452c77c
18
vimdoc.go
18
vimdoc.go
@ -88,18 +88,6 @@ func VimDocRenderer(filename, desc string, cols, tabs, flags int) blackfriday.Re
|
|||||||
tocPos: -1}
|
tocPos: -1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *vimDoc) pushl() {
|
|
||||||
v.lists = append(v.lists, &list{1})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *vimDoc) popl() {
|
|
||||||
v.lists = v.lists[:len(v.lists)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *vimDoc) getl() *list {
|
|
||||||
return v.lists[len(v.lists)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *vimDoc) fixupCode(input []byte) []byte {
|
func (v *vimDoc) fixupCode(input []byte) []byte {
|
||||||
r := regexp.MustCompile(`(?m)^\s*([<>])$`)
|
r := regexp.MustCompile(`(?m)^\s*([<>])$`)
|
||||||
return r.ReplaceAll(input, []byte("$1"))
|
return r.ReplaceAll(input, []byte("$1"))
|
||||||
@ -241,15 +229,15 @@ func (v *vimDoc) HRule(out *bytes.Buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *vimDoc) List(out *bytes.Buffer, text func() bool, flags int) {
|
func (v *vimDoc) List(out *bytes.Buffer, text func() bool, flags int) {
|
||||||
v.pushl()
|
v.lists = append(v.lists, &list{1})
|
||||||
text()
|
text()
|
||||||
v.popl()
|
v.lists = v.lists[:len(v.lists)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *vimDoc) ListItem(out *bytes.Buffer, text []byte, flags int) {
|
func (v *vimDoc) ListItem(out *bytes.Buffer, text []byte, flags int) {
|
||||||
marker := out.Len()
|
marker := out.Len()
|
||||||
|
|
||||||
list := v.getl()
|
list := v.lists[len(v.lists)-1]
|
||||||
if flags&blackfriday.LIST_TYPE_ORDERED == blackfriday.LIST_TYPE_ORDERED {
|
if flags&blackfriday.LIST_TYPE_ORDERED == blackfriday.LIST_TYPE_ORDERED {
|
||||||
out.WriteString(fmt.Sprintf("%d. ", list.index))
|
out.WriteString(fmt.Sprintf("%d. ", list.index))
|
||||||
list.index++
|
list.index++
|
||||||
|
Loading…
Reference in New Issue
Block a user