Don't generate hyperlinks for un-referenceable headings/items (e.g. inside quotes)
This commit is contained in:
parent
c4481addf3
commit
071e6db304
@ -93,11 +93,14 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def render_numbered_heading(self, token):
|
def render_numbered_heading(self, token):
|
||||||
sha = hashlib.sha256()
|
if token.full_label():
|
||||||
sha.update(token.full_label().encode('utf-8'))
|
sha = hashlib.sha256()
|
||||||
hyperlink = format(r'\hypertarget{<linkname>}{}',
|
sha.update(token.full_label().encode('utf-8'))
|
||||||
linkname=sha.hexdigest()
|
hyperlink = format(r'\hypertarget{<linkname>}{}',
|
||||||
)
|
linkname=sha.hexdigest()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
hyperlink = '{}'
|
||||||
|
|
||||||
if token.level == 1:
|
if token.level == 1:
|
||||||
# Part
|
# Part
|
||||||
@ -155,11 +158,14 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
|||||||
|
|
||||||
def render_subrules_item(self, token):
|
def render_subrules_item(self, token):
|
||||||
if token.label:
|
if token.label:
|
||||||
sha = hashlib.sha256()
|
if token.full_label():
|
||||||
sha.update(token.full_label().encode('utf-8'))
|
sha = hashlib.sha256()
|
||||||
hyperlink = format(r'\hypertarget{<linkname>}{}',
|
sha.update(token.full_label().encode('utf-8'))
|
||||||
linkname=sha.hexdigest()
|
hyperlink = format(r'\hypertarget{<linkname>}{}',
|
||||||
)
|
linkname=sha.hexdigest()
|
||||||
|
)
|
||||||
|
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>\par}\N',
|
||||||
hyperlink=hyperlink,
|
hyperlink=hyperlink,
|
||||||
|
Loading…
Reference in New Issue
Block a user