Commit dc9bfb2d authored by Siong-Ui Te's avatar Siong-Ui Te

set urlpath of xml

parent 51d9df74
package main
import (
"strings"
"github.com/siongui/gopalilib/lib"
"github.com/siongui/gopalilib/lib/tipitaka"
)
func traverse(tree lib.Tree, indent int) {
println(strings.Repeat(" ", indent) + tipitaka.TrimTreeText2(tree.Text))
for _, subtree := range tree.SubTrees {
traverse(subtree, indent+2)
type ToCTree struct {
lib.Tree
ChildTrees []ToCTree
UrlPath string
}
func CopyTreeToToCTree(t lib.Tree, toc *ToCTree) {
toc.Text = t.Text
toc.Src = t.Src
toc.Action = t.Action
if subpath := tipitaka.TrimTreeText2(t.Text); subpath != "" {
if subpath == "tipiṭaka (mūla)" {
subpath = "canon"
}
toc.UrlPath = toc.UrlPath + "/" + subpath
}
for _, subtree := range t.SubTrees {
st := ToCTree{UrlPath: toc.UrlPath}
CopyTreeToToCTree(subtree, &st)
toc.ChildTrees = append(toc.ChildTrees, st)
}
toc.UrlPath += "/"
println(toc.UrlPath)
}
func SetupTipitakaUrl(tree lib.Tree) {
traverse(tree, 0)
toctree := ToCTree{}
CopyTreeToToCTree(tree, &toctree)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment