diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-12-23 19:54:35 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-12-23 19:54:35 +0300 |
commit | b5a9a056020e6bf5424a77a350b3204fd0e79a5a (patch) | |
tree | b17136105a8612ce3ddd0ff3dc850fbf2fc1b73f /sphinx/writers | |
parent | f2dc8a999a589bc7a9a85f6f0dd5691aabc17062 (diff) | |
parent | 6ad6594ec73d44d51c18faf0f41dd92f958cc45b (diff) |
Merge branch '4.x' into drop-translator-specific-unknown_visit-calls
Diffstat (limited to 'sphinx/writers')
-rw-r--r-- | sphinx/writers/latex.py | 4 | ||||
-rw-r--r-- | sphinx/writers/manpage.py | 2 | ||||
-rw-r--r-- | sphinx/writers/texinfo.py | 26 |
3 files changed, 23 insertions, 9 deletions
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index e5bd028f9..d33f92dce 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -757,9 +757,7 @@ class LaTeXTranslator(SphinxTranslator): self._depart_signature_line(node) def visit_desc_content(self, node: Element) -> None: - if node.children and not isinstance(node.children[0], nodes.paragraph): - # avoid empty desc environment which causes a formatting bug - self.body.append('~') + pass def depart_desc_content(self, node: Element) -> None: pass diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index a5d1e2b19..3bcf650a7 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -107,7 +107,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator): # Overwrite admonition label translations with our own for label, translation in admonitionlabels.items(): - self.language.labels[label] = self.deunicode(translation) # type: ignore + self.language.labels[label] = self.deunicode(translation) # overwritten -- added quotes around all .TH arguments def header(self) -> str: diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 539a72388..c764b3027 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -194,6 +194,7 @@ class TexinfoTranslator(SphinxTranslator): self.curfilestack: List[str] = [] self.footnotestack: List[Dict[str, List[Union[collected_footnote, bool]]]] = [] # NOQA self.in_footnote = 0 + self.in_samp = 0 self.handled_abbrs: Set[str] = set() self.colwidths: List[int] = None @@ -545,9 +546,12 @@ class TexinfoTranslator(SphinxTranslator): def add_xref(self, id: str, name: str, node: Node) -> None: name = self.escape_menu(name) sid = self.get_short_id(id) - self.body.append('@ref{%s,,%s}' % (sid, name)) - self.referenced_ids.add(sid) - self.referenced_ids.add(self.escape_id(id)) + if self.config.texinfo_cross_references: + self.body.append('@ref{%s,,%s}' % (sid, name)) + self.referenced_ids.add(sid) + self.referenced_ids.add(self.escape_id(id)) + else: + self.body.append(name) # -- Visiting @@ -809,15 +813,23 @@ class TexinfoTranslator(SphinxTranslator): self.body.append('}') def visit_emphasis(self, node: Element) -> None: - self.body.append('@emph{') + element = 'emph' if not self.in_samp else 'var' + self.body.append('@%s{' % element) def depart_emphasis(self, node: Element) -> None: self.body.append('}') + def is_samp(self, node: Element) -> bool: + return 'samp' in node['classes'] + def visit_literal(self, node: Element) -> None: + if self.is_samp(node): + self.in_samp += 1 self.body.append('@code{') def depart_literal(self, node: Element) -> None: + if self.is_samp(node): + self.in_samp -= 1 self.body.append('}') def visit_superscript(self, node: Element) -> None: @@ -1223,7 +1235,11 @@ class TexinfoTranslator(SphinxTranslator): self.depart_topic(node) def visit_label(self, node: Element) -> None: - self.body.append('@w{(') + # label numbering is automatically generated by Texinfo + if self.in_footnote: + raise nodes.SkipNode + else: + self.body.append('@w{(') def depart_label(self, node: Element) -> None: self.body.append(')} ') |