Add support for COMMENT headlines
https://orgmode.org/manual/Comment-Lines.html
This commit is contained in:
parent
7bc6100fc7
commit
6cfae31132
4 changed files with 14 additions and 1 deletions
|
@ -23,6 +23,7 @@ type Headline struct {
|
|||
Index int
|
||||
Lvl int
|
||||
Status string
|
||||
IsComment bool
|
||||
Priority string
|
||||
Properties *PropertyDrawer
|
||||
Title []Node
|
||||
|
@ -59,7 +60,10 @@ func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
|||
headline.Priority = text[2:3]
|
||||
text = strings.TrimSpace(text[4:])
|
||||
}
|
||||
|
||||
if strings.HasPrefix(text, "COMMENT ") {
|
||||
headline.IsComment = true
|
||||
text = strings.TrimPrefix(text, "COMMENT ")
|
||||
}
|
||||
if m := tagRegexp.FindStringSubmatch(text); m != nil {
|
||||
text = m[1]
|
||||
headline.Tags = strings.FieldsFunc(m[2], func(r rune) bool { return r == ':' })
|
||||
|
@ -104,6 +108,9 @@ func (h Headline) ID() string {
|
|||
}
|
||||
|
||||
func (h Headline) IsExcluded(d *Document) bool {
|
||||
if h.IsComment {
|
||||
return true
|
||||
}
|
||||
for _, excludedTag := range strings.Fields(d.Get("EXCLUDE_TAGS")) {
|
||||
for _, tag := range h.Tags {
|
||||
if tag == excludedTag {
|
||||
|
|
2
org/testdata/headlines.org
vendored
2
org/testdata/headlines.org
vendored
|
@ -28,6 +28,8 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo
|
|||
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:=.
|
||||
|
||||
* TODO [#A] COMMENT commented headline
|
||||
this headline is commented out. see [[https://orgmode.org/manual/Comment-Lines.html][comment lines]]
|
||||
* malformed property drawer
|
||||
:PROPERTIES:
|
||||
not a property
|
||||
|
|
2
org/testdata/headlines.pretty_org
vendored
2
org/testdata/headlines.pretty_org
vendored
|
@ -28,6 +28,8 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo
|
|||
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:=.
|
||||
|
||||
* TODO [#A] commented headline
|
||||
this headline is commented out. see [[https://orgmode.org/manual/Comment-Lines.html][comment lines]]
|
||||
* malformed property drawer
|
||||
:PROPERTIES:
|
||||
not a property
|
||||
|
|
2
org/testdata/misc.html
vendored
2
org/testdata/misc.html
vendored
|
@ -171,6 +171,8 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains th
|
|||
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:=.
|
||||
|
||||
* TODO [#A] COMMENT commented headline
|
||||
this headline is commented out. see [[https://orgmode.org/manual/Comment-Lines.html][comment lines]]
|
||||
* malformed property drawer
|
||||
:PROPERTIES:
|
||||
not a property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue