Skip to content

Commit

Permalink
fix: replace rawsource attribute with node directly, due to removal o…
Browse files Browse the repository at this point in the history
…f rawsource in Docutil 2.0 (#9838)

(cherry picked from commit d831461)
  • Loading branch information
corban-beaird authored and determined-ci committed Aug 19, 2024
1 parent d58ff68 commit 89d5ddb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions docs/rebrand-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ def Text(node: docutils.nodes.Text, _: rstfmt.FormatContext) -> rstfmt.inline_it
exclude_types = (docutils.nodes.literal_block, docutils.nodes.literal)
if isinstance(node.parent, exclude_types) or isinstance(node.parent.parent, exclude_types):
yield node.astext()
# The rawsource attribute tends not to be set for text nodes not directly under paragraphs.
elif isinstance(node.parent, docutils.nodes.paragraph):
# Any instance of "\ " disappears in the parsing. It may have an effect if it separates
# this text from adjacent inline markup, but in that case it will be replaced by the
# wrapping algorithm. Other backslashes may be unnecessary (e.g., "a\` b" or "a\b"), but
# finding all of those is future work.
yield rewrite_text(node.rawsource.replace(r"\ ", ""))
yield rewrite_text(node.replace(r"\ ", ""))
else:
yield rewrite_text(node.astext())

Expand Down

0 comments on commit 89d5ddb

Please sign in to comment.