Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9330: versionchanged causes error during pdf build #9333

Merged
merged 1 commit into from Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -16,6 +16,8 @@ Features added
Bugs fixed
----------

* #9330: changeset domain: :rst:dir:`versionchanged` with contents being a list
will cause error during pdf build
* #9313: LaTeX: complex table with merged cells broken since 4.0

Testing
Expand Down
16 changes: 12 additions & 4 deletions sphinx/domains/changeset.py
Expand Up @@ -74,8 +74,10 @@ def run(self) -> List[Node]:
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
classes = ['versionmodified', versionlabel_classes[self.name]]
if len(node):
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
if len(node) > 0 and isinstance(node[0], nodes.paragraph):
# the contents start with a paragraph
if node[0].rawsource:
# make the first paragraph translatable
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
Expand All @@ -84,10 +86,16 @@ def run(self) -> List[Node]:

para = cast(nodes.paragraph, node[0])
para.insert(0, nodes.inline('', '%s: ' % text, classes=classes))
elif len(node) > 0:
# the contents do not starts with a paragraph
para = nodes.paragraph('', '',
nodes.inline('', '%s: ' % text, classes=classes),
translatable=False)
node.insert(0, para)
else:
# the contents are empty
para = nodes.paragraph('', '',
nodes.inline('', '%s.' % text,
classes=classes),
nodes.inline('', '%s.' % text, classes=classes),
translatable=False)
node.append(para)

Expand Down