diff --git a/test.md b/test.md index 938fd30..b4eb439 100644 --- a/test.md +++ b/test.md @@ -142,11 +142,11 @@ To Do: i. bro ii. wym bro - + diff --git a/tex.py b/tex.py index 0a9ae7c..e884e24 100644 --- a/tex.py +++ b/tex.py @@ -136,6 +136,25 @@ def tex(e, indent_level: int=0, indent_str: str="\t") -> str: if inlinify(e) is not None: return f'\\fn{{{tex(inlinify(e), 0, "")}}}' + if isinstance(e, Table): + aligns = { + "AlignLeft": "\\quad#\\quad\\hfil", + "AlignRight": "\\quad\\hfil#\\quad", + "AlignCenter": "\\quad\\hfil#\\hfil\\quad", + "AlignDefault": "\\quad#\\quad\\hfil" + } + text = "\strut"+"&".join([aligns[col[0]] for col in e.colspec])+"\cr\n" + text += tex(e.head.content, 0, "") + text += "\\noalign{\\hrule}\n" + text += tex(e.content[0].content, 0, "") + text += "\\noalign{\\hrule}\n" + text += tex(e.foot.content, 0, "") + return "\\vskip1em\n\\halign{"+text+"}\n\\vskip1em\n" + # FIXME: Implement rowspan + + if isinstance(e, TableRow): + return "&".join([("\\multispan"+str(cell.colspan)+" " if cell.colspan > 1 else "")+tex(cell.content, 0, "") for cell in e.content])+"\cr\n" + if isinstance(e, RawInline): if e.format == "tex": return e.text