html: Hide excluded headlines from TOC

emacs org mode did it first
This commit is contained in:
Niklas Fasching 2021-07-13 20:32:47 +02:00
parent e5ae608865
commit abb81851be
3 changed files with 14 additions and 9 deletions

View file

@ -89,6 +89,17 @@ func (h Headline) ID() string {
return fmt.Sprintf("headline-%d", h.Index)
}
func (h Headline) IsExcluded(d *Document) bool {
for _, excludedTag := range strings.Fields(d.Get("EXCLUDE_TAGS")) {
for _, tag := range h.Tags {
if tag == excludedTag {
return true
}
}
}
return false
}
func (parent *Section) add(current *Section) {
if parent.Headline == nil || parent.Headline.Lvl < current.Headline.Lvl {
parent.Children = append(parent.Children, current)