Skip to content

Commit 9b749b5

Browse files
Render centered and caption nodes transparently instead of dropping their text
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d2dff40 commit 9b749b5

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

sphinx_markdown_builder/translator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
tgroup=None,
110110
figure=None,
111111
desc_signature_line=None,
112+
centered=None, # Sphinx ".. centered::" directive — render inner text inline
113+
caption=None, # figure/code-block :caption: — emit the label text inline
112114
)
113115

114116

tests/expected/ExampleRSTFile.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This file covers the following topics.
1616
>
1717
> * [Heading Levels](#heading-levels)
1818
> * [Paragraph Text and Commented Text](#paragraph-text-and-commented-text)
19+
> * [Centered Text](#centered-text)
1920
> * [Ordered and Unordered Lists](#ordered-and-unordered-lists)
2021
> * [Conditional Text](#conditional-text)
2122
> * [Notes and Warnings](#notes-and-warnings)
@@ -65,6 +66,9 @@ Italics are rarely used. Text surrounded by single asterisks is rendered in
6566
Monospace text is used for `code examples`. Text surrounded by double grave
6667
accent characters is rendered in monospace font.
6768

69+
## Centered Text
70+
71+
Centered text here
6872
<!-- comments can be added in a file by starting a line with 2 periods and a space. -->
6973

7074
In English source files, look for comments addressed to translators from writers.
@@ -598,6 +602,16 @@ being displayed in different colors.
598602
</problem>
599603
```
600604

605+
The following code block uses a `:caption:` to label the file name.
606+
607+
example.py
608+
```python
609+
print("hello")
610+
```
611+
612+
The following figure uses a caption to describe the image.
613+
614+
![Captioned figure example.](static/markdown.png)Figure caption text.
601615
<!-- Taken from https://github.com/openedx/edx-documentation/blob/master/en_us/links/links.rst -->
602616
<!-- Include this file in any file that includes a non-doc link. -->
603617

tests/expected/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [Heading 5](ExampleRSTFile.md#heading-5)
88
* [Heading 6](ExampleRSTFile.md#heading-6)
99
* [Paragraph Text and Commented Text](ExampleRSTFile.md#paragraph-text-and-commented-text)
10+
* [Centered Text](ExampleRSTFile.md#centered-text)
1011
* [Ordered and Unordered Lists](ExampleRSTFile.md#ordered-and-unordered-lists)
1112
* [Nested Lists or Content](ExampleRSTFile.md#nested-lists-or-content)
1213
* [Unordered List inside Ordered List](ExampleRSTFile.md#unordered-list-inside-ordered-list)

tests/source/ExampleRSTFile.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ Italics are rarely used. Text surrounded by single asterisks is rendered in
6666
Monospace text is used for ``code examples``. Text surrounded by double grave
6767
accent characters is rendered in monospace font.
6868

69+
*****************
70+
Centered Text
71+
*****************
72+
73+
.. centered:: Centered text here
74+
6975
.. comments can be added in a file by starting a line with 2 periods and a space.
7076
7177
In English source files, look for comments addressed to translators from writers.
@@ -778,4 +784,18 @@ being displayed in different colors.
778784
</solution>
779785
</problem>
780786
787+
The following code block uses a ``:caption:`` to label the file name.
788+
789+
.. code-block:: python
790+
:caption: example.py
791+
792+
print("hello")
793+
794+
The following figure uses a caption to describe the image.
795+
796+
.. figure:: /static/markdown.png
797+
:alt: Captioned figure example.
798+
799+
Figure caption text.
800+
781801
.. include:: links.rst

0 commit comments

Comments
 (0)