From 0cbfa7b920b89f4bfa4208e988732dd0b1fce139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Teichgr=C3=A4ber?= Date: Sat, 21 Apr 2012 23:08:33 +0200 Subject: [PATCH] parser.leg: print_tree: write to an io.Writer --- parser.leg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parser.leg b/parser.leg index a7af8de..7d0ac0b 100644 --- a/parser.leg +++ b/parser.leg @@ -22,6 +22,7 @@ package markdown import ( "fmt" + "io" "strings" "log" "sync" @@ -992,24 +993,24 @@ func (d *Doc) find_note(label string) (*element, bool) { /* print tree of elements, for debugging only. */ -func print_tree(elt *element, indent int) { +func print_tree(w io.Writer, elt *element, indent int) { var key string for elt != nil { for i := 0; i < indent; i++ { - fmt.Print("\t") + fmt.Fprint(w, "\t") } key = keynames[elt.key] if key == "" { key = "?" } if elt.key == STR { - fmt.Printf("%p:\t%s\t'%s'\n", elt, key, elt.contents.str) + fmt.Fprintf(w, "%p:\t%s\t'%s'\n", elt, key, elt.contents.str) } else { - fmt.Printf("%p:\t%s %p\n", elt, key, elt.next) + fmt.Fprintf(w, "%p:\t%s %p\n", elt, key, elt.next) } if elt.children != nil { - print_tree(elt.children, indent+1) + print_tree(w, elt.children, indent+1) } elt = elt.next }