Add support for COMMENT headlines

https://orgmode.org/manual/Comment-Lines.html
This commit is contained in:
Niklas Fasching 2024-08-20 15:26:31 +02:00
parent 7bc6100fc7
commit 6cfae31132
4 changed files with 14 additions and 1 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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