0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-16 23:20:56 +03:00

nixos-render-docs: add image support

currently only supported for html. docbook could also support images,
but it's on the way out for manual generation anyway so we won't add
image support there. options docs can't use images because they also
target manpages, which leaves no viable users.
This commit is contained in:
pennae 2023-06-21 16:58:23 +02:00
parent b962ff92ff
commit 8c2d14a6b8
6 changed files with 70 additions and 8 deletions

View file

@ -184,3 +184,7 @@ class CommonMarkRenderer(Renderer):
def ordered_list_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:
self._list_stack.pop()
return ""
def image(self, token: Token, tokens: Sequence[Token], i: int) -> str:
if title := cast(str, token.attrs.get('title', '')):
title = ' "' + title.replace('"', '\\"') + '"'
return f'![{token.content}]({token.attrs["src"]}{title})'