nixos-render-docs: don't double-escape link titles

This commit is contained in:
pennae 2023-06-21 16:16:29 +02:00
parent f8ffb616a6
commit 8c33134465

View file

@ -67,7 +67,8 @@ class HTMLRenderer(Renderer):
if tokens[i + 1].type == 'link_close':
tag, text = "xref", xref.title_html
if xref.title:
title = f'title="{escape(xref.title, True)}"'
# titles are not attribute-safe on their own, so we need to replace quotes.
title = 'title="{}"'.format(xref.title.replace('"', '"'))
target, href = "", xref.href()
return f'<a class="{tag}" href="{href}" {title} {target}>{text}'
def link_close(self, token: Token, tokens: Sequence[Token], i: int) -> str: