add typst export
This commit is contained in:
32
pkg/cat/entry.go
Normal file
32
pkg/cat/entry.go
Normal file
@ -0,0 +1,32 @@
|
||||
package cat
|
||||
|
||||
type entry struct {
|
||||
name string
|
||||
fqname string
|
||||
content string
|
||||
children []entry
|
||||
}
|
||||
|
||||
func (e entry) filter(ok func(e entry) bool) entry {
|
||||
children := make([]entry, 0, len(e.children))
|
||||
for _, entry := range e.children {
|
||||
if !ok(entry) {
|
||||
continue
|
||||
}
|
||||
children = append(children, entry.filter(ok))
|
||||
}
|
||||
|
||||
return entry{
|
||||
name: e.name,
|
||||
fqname: e.fqname,
|
||||
content: e.content,
|
||||
children: children,
|
||||
}
|
||||
}
|
||||
|
||||
func (e entry) traverse(lvl int, do func(e entry, lvl int)) {
|
||||
do(e, lvl)
|
||||
for _, entry := range e.children {
|
||||
entry.traverse(lvl+1, do)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user