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.
|
* of parent elements. The result should be a tree of elements without any RAWs.
|
||||||
*/
|
*/
|
||||||
func (d *Doc) processRawBlocks(input *element) *element {
|
func (d *Doc) processRawBlocks(input *element) *element {
|
||||||
var last_child *element
|
|
||||||
|
|
||||||
for current := input; current != nil; current = current.next {
|
for current := input; current != nil; current = current.next {
|
||||||
if current.key == RAW {
|
if current.key == RAW {
|
||||||
@ -83,17 +82,14 @@ func (d *Doc) processRawBlocks(input *element) *element {
|
|||||||
*/
|
*/
|
||||||
current.key = LIST
|
current.key = LIST
|
||||||
current.children = nil
|
current.children = nil
|
||||||
|
listEnd := ¤t.children
|
||||||
for _, contents := range strings.Split(current.contents.str, "\001", -1) {
|
for _, contents := range strings.Split(current.contents.str, "\001", -1) {
|
||||||
list := d.parseMarkdown(contents)
|
list := d.parseMarkdown(contents)
|
||||||
if current.children == nil {
|
*listEnd = list
|
||||||
current.children = list
|
for list.next != nil {
|
||||||
last_child = list
|
list = list.next
|
||||||
} else {
|
|
||||||
last_child.next = list
|
|
||||||
}
|
|
||||||
for last_child.next != nil {
|
|
||||||
last_child = last_child.next
|
|
||||||
}
|
}
|
||||||
|
listEnd = &list.next
|
||||||
}
|
}
|
||||||
current.contents.str = ""
|
current.contents.str = ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user