Add support for EXCLUDE_TAGS and :noexport:

This commit is contained in:
Niklas Fasching 2018-12-26 15:25:38 +01:00
parent c3d635eacb
commit beff0c0d8a
7 changed files with 24 additions and 1 deletions

View file

@ -80,7 +80,8 @@ func NewDocument() *Document {
MaxEmphasisNewLines: 1, MaxEmphasisNewLines: 1,
BufferSettings: map[string]string{}, BufferSettings: map[string]string{},
DefaultSettings: map[string]string{ DefaultSettings: map[string]string{
"TODO": "TODO | DONE", "TODO": "TODO | DONE",
"EXCLUDE_TAGS": "noexport",
}, },
Log: log.New(os.Stderr, "go-org: ", 0), Log: log.New(os.Stderr, "go-org: ", 0),
} }

View file

@ -16,6 +16,7 @@ type HTMLWriter struct {
HighlightCodeBlock func(source, lang string) string HighlightCodeBlock func(source, lang string) string
FootnotesHeadingTitle string FootnotesHeadingTitle string
htmlEscape bool htmlEscape bool
excludeTags []string
log *log.Logger log *log.Logger
} }
@ -65,6 +66,7 @@ func (w *HTMLWriter) nodesAsString(nodes ...Node) string {
} }
func (w *HTMLWriter) before(d *Document) { func (w *HTMLWriter) before(d *Document) {
w.excludeTags = strings.Fields(d.Get("EXCLUDE_TAGS"))
w.log = d.Log w.log = d.Log
} }
@ -207,6 +209,13 @@ func (w *HTMLWriter) writeHeadline(h Headline) {
if h.Lvl == 1 && title == w.FootnotesHeadingTitle { if h.Lvl == 1 && title == w.FootnotesHeadingTitle {
return return
} }
for _, excludeTag := range w.excludeTags {
for _, tag := range h.Tags {
if excludeTag == tag {
return
}
}
}
if id, ok := h.Properties.Get("CUSTOM_ID"); ok { if id, ok := h.Properties.Get("CUSTOM_ID"); ok {
w.WriteString(fmt.Sprintf(`<h%d id="%s">`, h.Lvl, id) + "\n") w.WriteString(fmt.Sprintf(`<h%d id="%s">`, h.Lvl, id) + "\n")

View file

@ -55,5 +55,6 @@ it&#39;s possible to use <code class="verbatim">#+SETUPFILE</code> - in this cas
<div class="highlight"> <div class="highlight">
<pre> <pre>
#+TODO: TODO DONE CUSTOM #+TODO: TODO DONE CUSTOM
#+EXCLUDE_TAGS: noexport custom_noexport
</pre> </pre>
</div> </div>

View file

@ -23,3 +23,7 @@ Still outside the drawer
it's possible to use =#+SETUPFILE= - in this case the setup file contains the following it's possible to use =#+SETUPFILE= - in this case the setup file contains the following
#+INCLUDE: "setup_file_org" src org #+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:=.

View file

@ -23,3 +23,7 @@ Still outside the drawer
it's possible to use =#+SETUPFILE= - in this case the setup file contains the following it's possible to use =#+SETUPFILE= - in this case the setup file contains the following
#+INCLUDE: "setup_file_org" src org #+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:=.

View file

@ -68,6 +68,9 @@ Still outside the drawer
it&#39;s possible to use =#+SETUPFILE= - in this case the setup file contains the following it&#39;s possible to use =#+SETUPFILE= - in this case the setup file contains the following
#+INCLUDE: &#34;setup_file_org&#34; src org #+INCLUDE: &#34;setup_file_org&#34; src org
* excluded headline :custom_noexport:
this headline and it&#39;s content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
By default =EXCLUDE_TAGS= is just =:noexport:=.
</pre> </pre>
</div> </div>
</li> </li>

View file

@ -1 +1,2 @@
#+TODO: TODO DONE CUSTOM #+TODO: TODO DONE CUSTOM
#+EXCLUDE_TAGS: noexport custom_noexport