diff --git a/org_dom/org_dom.py b/org_dom/org_dom.py index 8993eba..8394505 100644 --- a/org_dom/org_dom.py +++ b/org_dom/org_dom.py @@ -47,6 +47,9 @@ KEYWORDS_RE = re.compile( PROPERTY_DRAWER_RE = re.compile( r"^(?P\s*):PROPERTIES:(?P\s*)$" ) +LOGBOOK_DRAWER_RE = re.compile( + r"^(?P\s*):LOGBOOK:(?P\s*)$" +) DRAWER_END_RE = re.compile(r"^(?P\s*):END:(?P\s*)$") NODE_PROPERTIES_RE = re.compile( r"^(?P\s*):(?P[^+:]+)(?P\+)?:(?P\s*)(?P.*)$" @@ -742,6 +745,7 @@ class OrgDomReader: "children": [], "keywords": [], "properties": [], + "logbook": [], "structural": [], } @@ -782,6 +786,10 @@ class OrgDomReader: self.current_drawer = self.headline_hierarchy[-1]["properties"] self.headline_hierarchy[-1]["structural"].append((linenum, line)) + def add_logbook_drawer_line(self, linenum: int, line: str, match: re.Match) -> int: + self.current_drawer = self.headline_hierarchy[-1]["logbook"] + self.headline_hierarchy[-1]["structural"].append((linenum, line)) + def add_drawer_end_line(self, linenum: int, line: str, match: re.Match) -> int: self.current_drawer = None self.headline_hierarchy[-1]["structural"].append((linenum, line)) @@ -815,6 +823,8 @@ class OrgDomReader: self.add_keyword_line(linenum, m) elif m := PROPERTY_DRAWER_RE.match(line): self.add_property_drawer_line(linenum, line, m) + elif m := LOGBOOK_DRAWER_RE.match(line): + self.add_logbook_drawer_line(linenum, line, m) elif m := DRAWER_END_RE.match(line): self.add_drawer_end_line(linenum, line, m) elif m := NODE_PROPERTIES_RE.match(line):