diff --git a/example.md b/example.md index 6c4ae75..a3712b3 100644 --- a/example.md +++ b/example.md @@ -24,6 +24,8 @@ This is the *blah blah*. Cross reference to `rule 1`_ +#### Fourth-level heading + (2) DEF ### 3 Table example diff --git a/example.rtf b/example.rtf index 14ceecb..1433463 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 Cross reference to rule\u160?1\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 }} +{\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}\fs1\~\par\sa198\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 Cross reference to rule\u160?1\par}{\keepn\i\li566 Fourth-level heading\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 19345a4..76e3ab1 100644 --- a/legalmd/latex_renderer.py +++ b/legalmd/latex_renderer.py @@ -82,7 +82,13 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer): if token.level == 3: heading_last, self.heading_last = self.heading_last, False - return format(r'{\par\bfseries\makebox[][l]{~}\phantomsection\addcontentsline{toc}{subsubsection}{}\nopagebreak\par}', + return format(r'{\par\leftskip=\bfseries \phantomsection\addcontentsline{toc}{subsubsection}{}\nopagebreak\par}', + content=self.render_inner(token) + ) + + if token.level == 4: + heading_last, self.heading_last = self.heading_last, False + return format(r'{\par\leftskip=\itshape \nopagebreak\par}', content=self.render_inner(token) ) diff --git a/legalmd/rtf_renderer.py b/legalmd/rtf_renderer.py index ecd26c9..999bc5c 100644 --- a/legalmd/rtf_renderer.py +++ b/legalmd/rtf_renderer.py @@ -106,6 +106,13 @@ class RTFRenderer(mistletoe.base_renderer.BaseRenderer): hangindent=cm_to_twip(LMARG)+self.quotemargin, content=self.render_inner(token) ) + + if token.level == 4: + heading_last, self.heading_last = self.heading_last, False + return format(r'{\keepn\i\li \par}', + hangindent=cm_to_twip(LMARG)+self.quotemargin, + content=self.render_inner(token) + ) def render_numbered_heading(self, token): if token.level == 1: