Change definition markup to specify level of indentation
This commit is contained in:
parent
b7066c8e4e
commit
00b8991648
@ -153,7 +153,8 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
def render_definition(self, token):
|
||||
self.heading_last = False
|
||||
|
||||
return format(r'\N{\par\leftskip=\dimexpr<lmarg>+1cm\relax\hangindent=1cm <content>\par}\N',
|
||||
return format(r'\N{\par\leftskip=\dimexpr<lmarg>+<level>cm\relax\relax\hangindent=1cm <content>\par}\N',
|
||||
level=token.level,
|
||||
content=self.render_inner(token)
|
||||
)
|
||||
|
||||
@ -192,7 +193,7 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
def render_note(self, token):
|
||||
self.heading_last = False
|
||||
|
||||
return format(r'\N{\nopagebreak\par\footnotesize\selectfont\settowidth{\notetaglength}{\bfseries <label>:}\addtolength{\notetaglength}{1em}\leftskip=\dimexpr1cm+<level>cm\relax\hangindent=\notetaglength\makebox[\notetaglength][l]{\bfseries <label>:}<content>\par}\N',
|
||||
return format(r'\N{\nopagebreak\par\footnotesize\selectfont\settowidth{\notetaglength}{\bfseries <label>:}\addtolength{\notetaglength}{1em}\leftskip=\dimexpr<lmarg>+<level>cm\relax\hangindent=\notetaglength\makebox[\notetaglength][l]{\bfseries <label>:}<content>\par}\N',
|
||||
level=token.level,
|
||||
label=token.label,
|
||||
content=self.render_inner(token)
|
||||
|
@ -167,10 +167,10 @@ class Note(mistletoe.block_token.BlockToken):
|
||||
mistletoe.block_token.add_token(Note)
|
||||
|
||||
class Definition(mistletoe.block_token.BlockToken):
|
||||
pattern = re.compile(r'\*\*\*(.+)\*\*\*(:|.*means)')
|
||||
pattern = re.compile(r'(\t*)(\*\*\*.+\*\*\*(?::|.*means|.*includes).*)')
|
||||
|
||||
def __init__(self, match):
|
||||
self.children = mistletoe.span_token.tokenize_inner(match)
|
||||
self.level, self.children = match
|
||||
|
||||
@classmethod
|
||||
def start(cls, line):
|
||||
@ -178,7 +178,11 @@ class Definition(mistletoe.block_token.BlockToken):
|
||||
|
||||
@classmethod
|
||||
def read(cls, lines):
|
||||
return next(lines).rstrip('\n')
|
||||
line = next(lines)
|
||||
match = cls.pattern.match(line)
|
||||
|
||||
level_str, content = match.group(1, 2)
|
||||
return len(level_str), mistletoe.span_token.tokenize_inner(content)
|
||||
|
||||
mistletoe.block_token.add_token(Definition)
|
||||
|
||||
|
@ -257,7 +257,7 @@ class RTFRenderer(mistletoe.base_renderer.BaseRenderer):
|
||||
|
||||
return format(r'{\fi<fi>\li<li> <content>\par}',
|
||||
fi=cm_to_twip(-1),
|
||||
li=cm_to_twip(LMARG + 2),
|
||||
li=cm_to_twip(LMARG + token.level + 1),
|
||||
content=self.render_inner(token)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user