From 6cfae311326bd57fd54eb2ffbca76b8861443b72 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Tue, 20 Aug 2024 15:26:31 +0200 Subject: [PATCH] Add support for COMMENT headlines https://orgmode.org/manual/Comment-Lines.html --- org/headline.go | 9 ++++++++- org/testdata/headlines.org | 2 ++ org/testdata/headlines.pretty_org | 2 ++ org/testdata/misc.html | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/org/headline.go b/org/headline.go index beb772b..b8b7b94 100644 --- a/org/headline.go +++ b/org/headline.go @@ -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 { diff --git a/org/testdata/headlines.org b/org/testdata/headlines.org index ee02735..2613825 100644 --- a/org/testdata/headlines.org +++ b/org/testdata/headlines.org @@ -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 diff --git a/org/testdata/headlines.pretty_org b/org/testdata/headlines.pretty_org index 5c6c940..2fc26c2 100644 --- a/org/testdata/headlines.pretty_org +++ b/org/testdata/headlines.pretty_org @@ -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 diff --git a/org/testdata/misc.html b/org/testdata/misc.html index 6c79fbd..4be094c 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -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