Try to avoid page break after colon
This commit is contained in:
parent
19a05b469d
commit
2b21860dd0
@ -141,8 +141,11 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
def render_paragraph(self, token):
|
||||
self.heading_last = False
|
||||
|
||||
return format(r'\N{\par\leftskip=\dimexpr\quotemargin+<lmarg>\relax <content>\par}\N',
|
||||
content = self.render_inner(token)
|
||||
|
||||
return format(r'\N{\par\leftskip=\dimexpr\quotemargin+<lmarg>\relax <content><pagebreak>\par}\N',
|
||||
content=content,
|
||||
pagebreak=r'\nopagebreak' if content.strip().endswith(':') else ''
|
||||
)
|
||||
|
||||
def render_quote(self, token):
|
||||
@ -166,6 +169,8 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
)
|
||||
|
||||
def render_subrules_item(self, token):
|
||||
content = self.render_inner(token)
|
||||
|
||||
if token.label:
|
||||
if token.full_label():
|
||||
sha = hashlib.sha256()
|
||||
@ -176,18 +181,20 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
else:
|
||||
hyperlink = '{}'
|
||||
|
||||
return format(r'\N{\par<hyperlink>\leftskip=\dimexpr\quotemargin+<lmarg>+<level>cm\relax\hangindent=1cm\parskip=<parskip>\makebox[<lmarg>][l]{<label>}<content>\par}\N',
|
||||
return format(r'\N{\par<hyperlink>\leftskip=\dimexpr\quotemargin+<lmarg>+<level>cm\relax\hangindent=1cm\parskip=<parskip>\makebox[<lmarg>][l]{<label>}<content><pagebreak>\par}\N',
|
||||
hyperlink=hyperlink,
|
||||
parskip=r'\parskip',# if token.level <= 1 else '0cm',
|
||||
label=token.label,
|
||||
level=token.level,
|
||||
content=self.render_inner(token)
|
||||
content=content,
|
||||
pagebreak=r'\nopagebreak' if content.strip().endswith(':') else ''
|
||||
)
|
||||
else:
|
||||
return format(r'\N{\par\leftskip=\dimexpr<lmarg>+<level>cm+1cm\relax\parskip=<parskip> <content>\par}\N',
|
||||
return format(r'\N{\par\leftskip=\dimexpr<lmarg>+<level>cm+1cm\relax\parskip=<parskip> <content><pagebreak>\par}\N',
|
||||
parskip=r'\parskip',# if token.level <= 1 else '0cm',
|
||||
level=token.level,
|
||||
content=self.render_inner(token)
|
||||
content=content,
|
||||
pagebreak=r'\nopagebreak' if content.strip().endswith(':') else ''
|
||||
)
|
||||
|
||||
def render_note(self, token):
|
||||
|
@ -152,9 +152,12 @@ class RTFRenderer(mistletoe.base_renderer.BaseRenderer):
|
||||
def render_paragraph(self, token):
|
||||
self.heading_last = False
|
||||
|
||||
return format(r'{\li<leftmargin> <content>\par}',
|
||||
leftmargin=cm_to_twip(LMARG)+self.quotemargin,
|
||||
content = self.render_inner(token)
|
||||
|
||||
return format(r'{\li<leftmargin><pagebreak> <content>\par}',
|
||||
leftmargin=cm_to_twip(LMARG)+self.quotemargin,
|
||||
content=content,
|
||||
pagebreak=r'\keepn' if content.strip().endswith(':') else ''
|
||||
)
|
||||
|
||||
def render_block_code(self, token):
|
||||
@ -229,18 +232,22 @@ class RTFRenderer(mistletoe.base_renderer.BaseRenderer):
|
||||
return self.render_inner(token)
|
||||
|
||||
def render_subrules_item(self, token):
|
||||
content = self.render_inner(token)
|
||||
|
||||
if token.label:
|
||||
return format(r'{\fi<fi>\li<li> <label>\tab <content>\par}',
|
||||
return format(r'{\fi<fi>\li<li><pagebreak> <label>\tab <content>\par}',
|
||||
fi=cm_to_twip(-1),
|
||||
li=cm_to_twip(LMARG + token.level + 1)+self.quotemargin,
|
||||
label=token.label,
|
||||
content=self.render_inner(token)
|
||||
content=content,
|
||||
pagebreak=r'\keepn' if content.strip().endswith(':') else ''
|
||||
)
|
||||
else:
|
||||
return format(r'{\li<li> <content>\par}',
|
||||
return format(r'{\li<li><pagebreak> <content>\par}',
|
||||
li=cm_to_twip(LMARG + token.level + 1)+self.quotemargin,
|
||||
label=token.label,
|
||||
content=self.render_inner(token)
|
||||
content=content,
|
||||
pagebreak=r'\keepn' if content.strip().endswith(':') else ''
|
||||
)
|
||||
|
||||
def render_note(self, token):
|
||||
|
Loading…
Reference in New Issue
Block a user