processRawBlocks: simplify appending of lists
This commit is contained in:
parent
4995379a8e
commit
42e0bf557e
14
markdown.go
14
markdown.go
@ -73,7 +73,6 @@ func (d *Doc) parseMarkdown(text string) *element {
|
||||
* of parent elements. The result should be a tree of elements without any RAWs.
|
||||
*/
|
||||
func (d *Doc) processRawBlocks(input *element) *element {
|
||||
var last_child *element
|
||||
|
||||
for current := input; current != nil; current = current.next {
|
||||
if current.key == RAW {
|
||||
@ -83,17 +82,14 @@ func (d *Doc) processRawBlocks(input *element) *element {
|
||||
*/
|
||||
current.key = LIST
|
||||
current.children = nil
|
||||
listEnd := ¤t.children
|
||||
for _, contents := range strings.Split(current.contents.str, "\001", -1) {
|
||||
list := d.parseMarkdown(contents)
|
||||
if current.children == nil {
|
||||
current.children = list
|
||||
last_child = list
|
||||
} else {
|
||||
last_child.next = list
|
||||
}
|
||||
for last_child.next != nil {
|
||||
last_child = last_child.next
|
||||
*listEnd = list
|
||||
for list.next != nil {
|
||||
list = list.next
|
||||
}
|
||||
listEnd = &list.next
|
||||
}
|
||||
current.contents.str = ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user