diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 7c6d931..52257f9 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -2284,6 +2284,10 @@ class OrgDoc: return kw.value.strip(':').split(':') return [] + @property + def shallow_tags(self) -> list[str]: + return self.tags + ## Querying def get_links(self): for headline in self.headlines: diff --git a/tests/test_org.py b/tests/test_org.py index c17f9d2..d515168 100644 --- a/tests/test_org.py +++ b/tests/test_org.py @@ -889,6 +889,23 @@ class TestSerde(unittest.TestCase): h1_2_h2 = h1_2.children[0] self.assertEqual(sorted(h1_2_h2.tags), ['filetag', 'otherh1tag', 'otherh2tag']) + def test_shallow_tag_property_read_13(self): + with open(os.path.join(DIR, "13-tags.org")) as f: + orig = f.read() + doc = loads(orig) + + self.assertEqual(doc.shallow_tags, ['filetag']) + + h1_1, h1_2 = doc.getTopHeadlines() + self.assertEqual(sorted(h1_1.shallow_tags), ['h1tag']) + self.assertEqual(sorted(h1_2.shallow_tags), ['otherh1tag']) + + h1_1_h2 = h1_1.children[0] + self.assertEqual(sorted(h1_1_h2.shallow_tags), ['h2tag']) + + h1_2_h2 = h1_2.children[0] + self.assertEqual(sorted(h1_2_h2.shallow_tags), ['otherh2tag']) + def print_tree(tree, indentation=0, headline=None): for element in tree: print(" " * indentation * 2, "EL:", element)