diff --git a/org/document.go b/org/document.go index eb630e5..8432e5e 100644 --- a/org/document.go +++ b/org/document.go @@ -80,7 +80,8 @@ func NewDocument() *Document { MaxEmphasisNewLines: 1, BufferSettings: map[string]string{}, DefaultSettings: map[string]string{ - "TODO": "TODO | DONE", + "TODO": "TODO | DONE", + "EXCLUDE_TAGS": "noexport", }, Log: log.New(os.Stderr, "go-org: ", 0), } diff --git a/org/html.go b/org/html.go index 5eda58e..c628dd2 100644 --- a/org/html.go +++ b/org/html.go @@ -16,6 +16,7 @@ type HTMLWriter struct { HighlightCodeBlock func(source, lang string) string FootnotesHeadingTitle string htmlEscape bool + excludeTags []string log *log.Logger } @@ -65,6 +66,7 @@ func (w *HTMLWriter) nodesAsString(nodes ...Node) string { } func (w *HTMLWriter) before(d *Document) { + w.excludeTags = strings.Fields(d.Get("EXCLUDE_TAGS")) w.log = d.Log } @@ -207,6 +209,13 @@ func (w *HTMLWriter) writeHeadline(h Headline) { if h.Lvl == 1 && title == w.FootnotesHeadingTitle { return } + for _, excludeTag := range w.excludeTags { + for _, tag := range h.Tags { + if excludeTag == tag { + return + } + } + } if id, ok := h.Properties.Get("CUSTOM_ID"); ok { w.WriteString(fmt.Sprintf(``, h.Lvl, id) + "\n") diff --git a/org/testdata/headlines.html b/org/testdata/headlines.html index b29cf48..814a27e 100644 --- a/org/testdata/headlines.html +++ b/org/testdata/headlines.html @@ -55,5 +55,6 @@ it's possible to use #+SETUPFILE - in this cas
 #+TODO: TODO DONE CUSTOM
+#+EXCLUDE_TAGS: noexport custom_noexport
 
diff --git a/org/testdata/headlines.org b/org/testdata/headlines.org index cb03899..1909921 100644 --- a/org/testdata/headlines.org +++ b/org/testdata/headlines.org @@ -23,3 +23,7 @@ Still outside the drawer it's possible to use =#+SETUPFILE= - in this case the setup file contains the following #+INCLUDE: "setup_file_org" src org +* excluded headline :custom_noexport: +this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. +By default =EXCLUDE_TAGS= is just =:noexport:=. + diff --git a/org/testdata/headlines.pretty_org b/org/testdata/headlines.pretty_org index b0209f0..0f22cac 100644 --- a/org/testdata/headlines.pretty_org +++ b/org/testdata/headlines.pretty_org @@ -23,3 +23,7 @@ Still outside the drawer it's possible to use =#+SETUPFILE= - in this case the setup file contains the following #+INCLUDE: "setup_file_org" src org +* excluded headline :custom_noexport: +this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. +By default =EXCLUDE_TAGS= is just =:noexport:=. + diff --git a/org/testdata/misc.html b/org/testdata/misc.html index f5f50b3..9cb5566 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -68,6 +68,9 @@ Still outside the drawer it's possible to use =#+SETUPFILE= - in this case the setup file contains the following #+INCLUDE: "setup_file_org" src org +* excluded headline :custom_noexport: +this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag. +By default =EXCLUDE_TAGS= is just =:noexport:=. diff --git a/org/testdata/setup_file_org b/org/testdata/setup_file_org index c9a4436..78378be 100644 --- a/org/testdata/setup_file_org +++ b/org/testdata/setup_file_org @@ -1 +1,2 @@ #+TODO: TODO DONE CUSTOM +#+EXCLUDE_TAGS: noexport custom_noexport