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 broken rendering of adjacent code blocks #38981

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ class SagecodeTransform(SphinxTransform):

def apply(self):
if self.app.builder.tags.has('html') or self.app.builder.tags.has('inventory'):
for node in self.document.findall(nodes.literal_block):
for node in list(self.document.findall(nodes.literal_block)):
if node.get('language') is None and node.astext().startswith('sage:'):
from docutils.nodes import container as Container, label as Label, literal_block as LiteralBlock, Text
from sphinx_inline_tabs._impl import TabContainer
Expand All @@ -963,7 +963,8 @@ def apply(self):
prev_node = node.previous_sibling()
if isinstance(node.previous_sibling(), TabContainer):
# Make sure not to merge inline tabs for adjacent literal blocks
parent.insert(index, Text(''))
parent.insert(index, nodes.paragraph())
prev_node = parent[index]
index += 1
parent.remove(node)
# Tab for Sage code
Expand Down Expand Up @@ -1102,3 +1103,4 @@ def feature_tags():
for feature in all_features():
if feature.is_present():
yield 'feature_' + feature.name.replace('.', '_')

Loading