diff --git a/example.md b/example.md index 759f7a7..3b36983 100644 --- a/example.md +++ b/example.md @@ -28,7 +28,7 @@ This is the *blah blah*. ### 3 Table example -| 1 First column | 2 Second column | +| 1 This is a long column header that will overflow onto multiple lines | 2[4] Second column | |----------------|-----------------| | 1 First row | Foo bar | | 2 Second row | Baz qux | diff --git a/example.pdf b/example.pdf index 200abca..50fdf72 100644 Binary files a/example.pdf and b/example.pdf differ diff --git a/example.rtf b/example.rtf index 8f10924..157b11c 100644 --- a/example.rtf +++ b/example.rtf @@ -1 +1 @@ -{\rtf1\deff0{\fonttbl{\f0 TeX Gyre Heros{\*\falt FreeSans}{\*\falt Liberation Sans}{\*\falt Arial};}}\paperw11905\paperh16837\margl1133\margr1133\margt1133\margb1133{\header\f0\fs16\tqr\tx9637 Example Legal Document\tab }{\footer\f0\fs16\tqr\tx9637 \tab\chpgn}\sa198\fs1\~\fs24 {\fs20\li566{\b Note:} This is a note.\par}{\sb566\keepn\b\fs26\qc\caps Part 1\u8212?Preliminary\par}{\keepn\b\fi-566\li566 1\tab Short title\par}{\li566 This is the {\i blah blah}.\par}{\keepn\b\fi-566\li566 2\tab Another heading\par}{\fi-566\li1133 (1)\tab ABC\par}{\li1133 Continued\par}{\fi-566\li1700 (a)\tab asdf\par}{\fi-566\li1700 (b)\tab abcdefg\par}{\li1700 hijkl\par}{\li1133 Continued\par}{\fi-566\li1133 (2)\tab DEF\par}{\keepn\b\fi-566\li566 3\tab Table example\par}{\sa0\trowd\trgaph120\trleft566\clbrdrt\brdrs\clbrdrb\brdrs\cellx5101\clbrdrt\brdrs\clbrdrb\brdrs\cellx9636 {\b Column 1\intbl\cell}{\b Column 2\intbl\cell}\row{\b First column\intbl\cell}{\b Second column\intbl\cell}\row {1. First row\intbl\cell}{Foo bar\intbl\cell}\row {2. Second row\intbl\cell}{Baz qux\intbl\cell}\row }} +{\rtf1\deff0{\fonttbl{\f0 TeX Gyre Heros{\*\falt FreeSans}{\*\falt Liberation Sans}{\*\falt Arial};}}\paperw11905\paperh16837\margl1133\margr1133\margt1133\margb1133{\header\f0\fs16\tqr\tx9637 Example Legal Document\tab }{\footer\f0\fs16\tqr\tx9637 \tab\chpgn}\sa198\fs1\~\fs24 {\fs20\li566{\b Note:} This is a note.\par}{\sb566\keepn\b\fs26\qc\caps Part 1\u8212?Preliminary\par}{\keepn\b\fi-566\li566 1\tab Short title\par}{\li566 This is the {\i blah blah}.\par}{\keepn\b\fi-566\li566 2\tab Another heading\par}{\fi-566\li1133 (1)\tab ABC\par}{\li1133 Continued\par}{\fi-566\li1700 (a)\tab asdf\par}{\fi-566\li1700 (b)\tab abcdefg\par}{\li1700 hijkl\par}{\li1133 Continued\par}{\fi-566\li1133 (2)\tab DEF\par}{\keepn\b\fi-566\li566 3\tab Table example\par}{\sa0\trowd\trgaph120\trleft566\clbrdrt\brdrs\clbrdrb\brdrs\cellx2380\clbrdrt\brdrs\clbrdrb\brdrs\cellx9636 {\b Column 1\intbl\cell}{\b Column 2\intbl\cell}\row{\b This is a long column header that will overflow onto multiple lines\intbl\cell}{\b Second column\intbl\cell}\row {1. First row\intbl\cell}{Foo bar\intbl\cell}\row {2. Second row\intbl\cell}{Baz qux\intbl\cell}\row }} diff --git a/legalmd/latex_renderer.py b/legalmd/latex_renderer.py index e77ca8b..d78f5ff 100644 --- a/legalmd/latex_renderer.py +++ b/legalmd/latex_renderer.py @@ -173,8 +173,18 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer): for cell in token.children: if cell.colnum == 0: - cells1.append('\\multicolumn{2}{l}{\\bfseries Column ' + cell.label + '}') - cells2.append('\\multicolumn{2}{l}{\\bfseries ' + self.render_inner(cell) + '}') + coldef = format(r'p{\dimexpr\linewidth-\tabucolX-\tabcolsep\relax}', + colx=sum(col.weight for col in token.children[1:]), + colnd=2 * (len(token.children) - 1) + ) + cells1.append(format('\\multicolumn{2}{}{\\bfseries Column