nixos-render-docs: wrap code in <pre><code>, not <pre>

newer hljs stylesheets work best with <pre><code> wrapping, and it's
semantically more accurate as well.
This commit is contained in:
pennae
2023-12-01 18:31:41 +01:00
parent 229e6eb8ed
commit 548f98f4fb
3 changed files with 18 additions and 10 deletions

View File

@@ -98,7 +98,7 @@ class HTMLRenderer(Renderer):
return "</strong></span>"
def fence(self, token: Token, tokens: Sequence[Token], i: int) -> str:
info = f" {escape(token.info, True)}" if token.info != "" else ""
return f'<pre class="programlisting{info}">\n{escape(token.content)}</pre>'
return f'<pre><code class="programlisting{info}">{escape(token.content)}</code></pre>'
def blockquote_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return '<div class="blockquote"><blockquote class="blockquote">'
def blockquote_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:

View File

@@ -497,7 +497,7 @@ class OptionsHTMLRenderer(OptionDocsRestrictions, HTMLRenderer):
return super().bullet_list_open(token, tokens, i)
def fence(self, token: Token, tokens: Sequence[Token], i: int) -> str:
info = f" {html.escape(token.info, True)}" if token.info != "" else ""
return f'<pre class="programlisting{info}">{html.escape(token.content)}</pre>'
return f'<pre><code class="programlisting{info}">{html.escape(token.content)}</code></pre>'
class HTMLConverter(BaseConverter[OptionsHTMLRenderer]):
__option_block_separator__ = ""