Basic table rendering.

This commit is contained in:
Oliver Marks 2018-11-05 21:59:35 +00:00
parent 76cc5f78c5
commit 760b0b0913
2 changed files with 21 additions and 0 deletions

View File

@ -59,6 +59,13 @@ def header(doc, item, cls="", root=True):
return "<h%s%s>%s</h%s>\n" % (depth, cls, item.value, depth)
def table(doc, item, cls="", root=True):
tbl = ""
for row in item.value.split("\n"):
tbl += "<tr>" + "</td><td>".join(row.split("|")) + "</tr>\n"
return "<table%s%s>%s</table%s>\n" % (depth, cls, tbl, depth)
builddoc = {
tokens.HEADER: (header, None),
tokens.IMAGE: (img, "materialboxed center-align responsive-img"),
@ -72,6 +79,7 @@ builddoc = {
tokens.SOURCE: (src, None),
tokens.EXAMPLE: (blockquote, None),
tokens.RESULTS: (blockquote, None),
tokens.TABLE: (table, None),
}

13
tests/fixtures/test_table.org vendored Normal file
View File

@ -0,0 +1,13 @@
#+TITLE: Emacs org-mode tables
#+AUTHOR: Eric H. Neilsen, Jr.
#+EMAIL: neilsen@fnal.gov
#+DATE: jkkj
#+KEYWORDS: emacs, orgmode, tests
#+DESCRIPTION: Test DESCRIPTION
#+KEYWORDS: key1, key2
| Header 1 | Header 2 |
|----------+----------|
| 11 | 12 |
| 21 | 22 |
| | |