From 42e0bf557ea93b9cbdb40285d8fad56e1669330e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Teichgr=C3=A4ber?= Date: Wed, 24 Nov 2010 18:59:08 +0100 Subject: [PATCH] processRawBlocks: simplify appending of lists --- markdown.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/markdown.go b/markdown.go index 4639dec..cc32873 100644 --- a/markdown.go +++ b/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 = "" }