Skip to content

Commit

Permalink
gh-38981: Fix broken rendering of adjacent code blocks
Browse files Browse the repository at this point in the history
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->

a bug seen in, for example: https://doc-release--sagemath.netlify.app/ht
ml/en/reference/structure/sage/structure/category_object#sage.structure.
category_object.CategoryObject.variable_names

Compare with the fixed page: https://doc-pr-38981--sagemath.netlify.app/
html/en/reference/structure/sage/structure/category_object#sage.structur
e.category_object.CategoryObject.variable_names

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->

URL: #38981
Reported by: Kwankyu Lee
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager committed Nov 23, 2024
2 parents eaf7655 + 7279faa commit 95eb9b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=87648980fa41bbd38f9bf45beb7bcdb90e12d613
sha256=cb5129b2e60af70968a6d8de8937b0f9365a2146762bf34a09b4ad7a88c56b8b
sha1=75d6eb488fd370ea17699188dabf78afa295d6d9
sha256=679c7a5c352eeac458ee6574326208df1bc0b30be5c803b952e19a9d2a8b7d32
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d9c38a7c581e6ed54fbe420122b8bba488b16074
659705e89638fae6821783730c357bf292ebed6e
7 changes: 4 additions & 3 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,16 +954,17 @@ 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
parent = node.parent
index = parent.index(node)
prev_node = node.previous_sibling()
if isinstance(node.previous_sibling(), TabContainer):
if isinstance(prev_node, 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

0 comments on commit 95eb9b8

Please sign in to comment.