nixos-render-docs: always render links bold in manpages
no reason to differentiate between links by source of their label. this feature seems to be mostly used to change labels of links to other options, but this should ultimately be done by auto-linking from {option}`...`. at some point we may want to introduce a warning when this pattern is encountered, but there's a lot to work out still before we can do that.
This commit is contained in:
parent
5c5dadd382
commit
3a3274231e
2 changed files with 4 additions and 6 deletions
|
@ -149,14 +149,12 @@ class ManpageRenderer(Renderer):
|
|||
def link_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
href = cast(str, token.attrs['href'])
|
||||
(text, font) = ("", "\\fB")
|
||||
text = ""
|
||||
if tokens[i + 1].type == 'link_close' and href in self._href_targets:
|
||||
# TODO error or warning if the target can't be resolved
|
||||
text = self._href_targets[href]
|
||||
elif href in self._href_targets:
|
||||
font = "\\fR" # TODO docbook renders these links differently for some reason
|
||||
self._font_stack.append(font)
|
||||
return f"{font}{text}\0 <"
|
||||
self._font_stack.append("\\fB")
|
||||
return f"\\fB{text}\0 <"
|
||||
def link_close(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||
env: MutableMapping[str, Any]) -> str:
|
||||
self._font_stack.pop()
|
||||
|
|
|
@ -26,4 +26,4 @@ def test_fonts() -> None:
|
|||
def test_expand_link_targets() -> None:
|
||||
c = Converter({}, { '#foo1': "bar", "#foo2": "bar" })
|
||||
assert (c._render("[a](#foo1) [](#foo2) [b](#bar1) [](#bar2)") ==
|
||||
"\\fRa\\fR \\fBbar\\fR \\fBb\\fR \\fB\\fR")
|
||||
"\\fBa\\fR \\fBbar\\fR \\fBb\\fR \\fB\\fR")
|
||||
|
|
Loading…
Reference in a new issue