mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-22 01:11:02 +03:00
nixos-render-docs: add support for full attributed spans
this is pretty much what pandoc calls bracketed spans. since we only want to support ids and classes it doesn't seem fair to copy the name, so we'll call them "attributed span" for now. renderers are expected to know about *all* classes they could encounter and act appropriately, and since there are currently no classes with any defined behavior the most appropriate thing to do for now is to reject all classes.
This commit is contained in:
parent
1c9f55ec64
commit
67086639e0
4 changed files with 169 additions and 55 deletions
|
@ -212,9 +212,18 @@ class DocBookRenderer(Renderer):
|
|||
else:
|
||||
return ref
|
||||
raise NotImplementedError("md node not supported yet", token)
|
||||
def inline_anchor(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
return f'<anchor xml:id={quoteattr(cast(str, token.attrs["id"]))} />'
|
||||
def attr_span_begin(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
# we currently support *only* inline anchors (and no attributes at all).
|
||||
id_part = ""
|
||||
if s := token.attrs.get('id'):
|
||||
id_part = f'<anchor xml:id={quoteattr(cast(str, s))} />'
|
||||
if 'class' in token.attrs:
|
||||
return super().attr_span_begin(token, tokens, i, options, env)
|
||||
return id_part
|
||||
def attr_span_end(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
return ""
|
||||
def ordered_list_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
start = f' startingnumber="{token.attrs["start"]}"' if 'start' in token.attrs else ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue