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

RST roles in titles render properly with rst_prolog #11445

Merged
merged 8 commits into from
Jul 23, 2023

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented May 28, 2023

When an RST file contains a section starting with an RST role and when rst_prolog is set, the prolog is inserted betweeen the title and the heading, causing the title to be incorrectly rendered.

For instance, if rst_epilog = ".. |foo| replace:: The foo", then

:mod:`foo` - |foo|
------------------
The foo module.

was actually transformed into

:mod:`foo` - |foo|

.. |foo| replace:: The foo

------------------
The foo module.

instead of

.. |foo| replace:: The foo

:mod:`foo` - |foo|
------------------
The foo module.

Fix #11437.

@picnixz picnixz force-pushed the fix/11437-rst-prolog-CRLF branch from 86ea33c to 593ec07 Compare May 28, 2023 19:17
@AA-Turner
Copy link
Member

AA-Turner commented Jul 23, 2023

@picnixz -- I've updated the methodology here to use a more correct regular expression, which means the previous logic within prepend_prolog() can be retained.

Note e.g. :field name: and :spam eggs ham:`code`:: are valid field names, but :role:`...` isn't. The bibliographic fields (docinfo) are all single words though, so we could restrict the regular expression if wanted, e.g. from: :(?![: ])([^:\\]|\\.|:(?!([ `]|$)))*(?<! ):( +|$) to :[A-Za-z]+:( +|$).

A

@picnixz
Copy link
Member Author

picnixz commented Jul 23, 2023

Thank you ! I didn't actually think about using the docinfo pattern itself actually but your approach is much better.

@AA-Turner AA-Turner merged commit 12e7cff into sphinx-doc:master Jul 23, 2023
26 checks passed
@picnixz picnixz deleted the fix/11437-rst-prolog-CRLF branch July 24, 2023 07:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using rst_prolog removes top level headings containing a domain directive
2 participants