doc: fix and simplify stylesheets for the manuals, fix nrd bug (#295847)

* doc: fix and simplify stylesheets for the manuals, fix nrd bug

* Add anchorjs script to add links on section headers

* Fix another nrd bug, address style changes

* Use span instead of a for inline span syntax
This commit is contained in:
Daniel Sidhion
2024-03-16 12:16:59 -07:00
committed by GitHub
parent 4645c67723
commit a1581a3647
8 changed files with 381 additions and 262 deletions

View File

@@ -163,7 +163,7 @@ class HTMLRenderer(Renderer):
# keycap-styled spans.
(id_part, class_part) = ("", "")
if s := token.attrs.get('id'):
id_part = f'<a id="{escape(cast(str, s), True)}" />'
id_part = f'<span id="{escape(cast(str, s), True)}"></span>'
if s := token.attrs.get('class'):
if s == 'keycap':
class_part = '<span class="keycap"><strong>'
@@ -181,7 +181,7 @@ class HTMLRenderer(Renderer):
if hstyle:
hstyle = f'style="{escape(hstyle, True)}"'
if anchor := cast(str, token.attrs.get('id', '')):
anchor = f'<a id="{escape(anchor, True)}"></a>'
anchor = f'<span id="{escape(anchor, True)}"></span>'
result = self._close_headings(hlevel)
tag = self._heading_tag(token, tokens, i)
toc_fragment = self._build_toc(tokens, i)
@@ -220,7 +220,7 @@ class HTMLRenderer(Renderer):
def example_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
if id := cast(str, token.attrs.get('id', '')):
id = f'id="{escape(id, True)}"' if id else ''
return f'<div class="example"><a {id} />'
return f'<div class="example"><span {id} ></span>'
def example_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return '</div></div><br class="example-break" />'
def example_title_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
@@ -239,7 +239,7 @@ class HTMLRenderer(Renderer):
)
def figure_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
if anchor := cast(str, token.attrs.get('id', '')):
anchor = f'<a id="{escape(anchor, True)}"></a>'
anchor = f'<span id="{escape(anchor, True)}"></span>'
return f'<div class="figure">{anchor}'
def figure_close(self, token: Token, tokens: Sequence[Token], i: int) -> str:
return (