Add support for EXCLUDE_TAGS and :noexport:
This commit is contained in:
parent
c3d635eacb
commit
beff0c0d8a
7 changed files with 24 additions and 1 deletions
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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%d id="%s">`, h.Lvl, id) + "\n")
|
||||
|
|
1
org/testdata/headlines.html
vendored
1
org/testdata/headlines.html
vendored
|
@ -55,5 +55,6 @@ it's possible to use <code class="verbatim">#+SETUPFILE</code> - in this cas
|
|||
<div class="highlight">
|
||||
<pre>
|
||||
#+TODO: TODO DONE CUSTOM
|
||||
#+EXCLUDE_TAGS: noexport custom_noexport
|
||||
</pre>
|
||||
</div>
|
||||
|
|
4
org/testdata/headlines.org
vendored
4
org/testdata/headlines.org
vendored
|
@ -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:=.
|
||||
|
||||
|
|
4
org/testdata/headlines.pretty_org
vendored
4
org/testdata/headlines.pretty_org
vendored
|
@ -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:=.
|
||||
|
||||
|
|
3
org/testdata/misc.html
vendored
3
org/testdata/misc.html
vendored
|
@ -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:=.
|
||||
</pre>
|
||||
</div>
|
||||
</li>
|
||||
|
|
1
org/testdata/setup_file_org
vendored
1
org/testdata/setup_file_org
vendored
|
@ -1 +1,2 @@
|
|||
#+TODO: TODO DONE CUSTOM
|
||||
#+EXCLUDE_TAGS: noexport custom_noexport
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue