forked from kenkeiras/org-rw
feat: Add base support for tables.
This commit is contained in:
parent
7b7c186b83
commit
c2968283f3
3 changed files with 113 additions and 3 deletions
18
tests/10-tables.org
Normal file
18
tests/10-tables.org
Normal file
|
@ -0,0 +1,18 @@
|
|||
#+TITLE: 10-Tables
|
||||
#+DESCRIPTION: Table test
|
||||
#+TODO: TODO(t) PAUSED(p) | DONE(d)
|
||||
|
||||
|
||||
* Simple table
|
||||
:PROPERTIES:
|
||||
:ID: 10-table-test-id
|
||||
:CREATED: [2020-01-01 Wed 01:01]
|
||||
:END:
|
||||
|
||||
Content just before the table.
|
||||
| Header1 | Header2 | Header3 |
|
||||
|------------+------------+------------|
|
||||
| Content1-1 | Content1-2 | Content1-3 (last cell unclosed)
|
||||
| Content2-1 | Content2-2 | Content2-3 |
|
||||
Content after the table.
|
||||
|
|
@ -634,3 +634,27 @@ class TestSerde(unittest.TestCase):
|
|||
MarkerToken(closing=True, tok_type=MarkerType.UNDERLINED_MODE),
|
||||
' markup',
|
||||
])
|
||||
|
||||
def test_mimic_write_file_10(self):
|
||||
with open(os.path.join(DIR, "10-tables.org")) as f:
|
||||
orig = f.read()
|
||||
doc = loads(orig)
|
||||
|
||||
self.assertEqual(dumps(doc), orig)
|
||||
|
||||
def test_tables_file_10(self):
|
||||
with open(os.path.join(DIR, "10-tables.org")) as f:
|
||||
doc = load(f)
|
||||
|
||||
hl = doc.getTopHeadlines()[0]
|
||||
|
||||
tables = hl.get_tables()
|
||||
first_table = tables[0]
|
||||
self.assertEqual(len(first_table), 4)
|
||||
|
||||
print(first_table[0])
|
||||
self.assertEqual(len(first_table[0].cells), 3)
|
||||
self.assertEqual(first_table[0].cells[0].strip(), 'Header1')
|
||||
self.assertEqual(first_table[0].cells[1].strip(), 'Header2')
|
||||
self.assertEqual(first_table[0].cells[2].strip(), 'Header3')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue