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):
|
||||
if token.full_label():
|
||||
sha = hashlib.sha256()
|
||||
sha.update(token.full_label().encode('utf-8'))
|
||||
hyperlink = format(r'\hypertarget{<linkname>}{}',
|
||||
linkname=sha.hexdigest()
|
||||
)
|
||||
else:
|
||||
hyperlink = '{}'
|
||||
|
||||
if token.level == 1:
|
||||
# Part
|
||||
@ -155,11 +158,14 @@ class LaTeXRenderer(mistletoe.latex_renderer.LaTeXRenderer):
|
||||
|
||||
def render_subrules_item(self, token):
|
||||
if token.label:
|
||||
if token.full_label():
|
||||
sha = hashlib.sha256()
|
||||
sha.update(token.full_label().encode('utf-8'))
|
||||
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',
|
||||
hyperlink=hyperlink,
|
||||
|
Loading…
Reference in New Issue
Block a user