Beispiel #1
0
func parse(t Topic, level int) {
	PARTS = append(PARTS, fmt.Sprintf("%s %s", strings.Repeat("#", level+1), t.Title))
	if RICHTEXT {
		var (
			o   string
			err error
		)
		if o, err = pandoc.Launch(t.Html, "html"); err != nil {
			panic(err)
		}
		o = replaceStyles(o)
		if o, err = pandoc.Launch(o, "markdown"); err != nil {
			panic(err)
		}

		PARTS = append(PARTS, o)
	} else {
		PARTS = append(PARTS, t.Content)
	}

	for _, ch := range t.Children {
		parse(ch, level+1)
	}
}
Beispiel #2
0
func write(n *Node, level int) {

	PARTS = append(PARTS, fmt.Sprintf("%s %s", strings.Repeat("#", level+1), n.Text))
	if n.Content != "" {
		o, err := pandoc.Launch(n.Content, "markdown")
		if err != nil {
			panic(err)
		}
		PARTS = append(PARTS, o)
	}

	if len(n.Nodes) > 0 {
		for _, n := range n.Nodes {
			write(&n, level+1)
		}
	}

}