Skip to content

fix: preserve mixed-fence code blocks in doc rendering#22350

Open
MavenRain wants to merge 1 commit into
rust-lang:masterfrom
MavenRain:fix-doc-mixed-fences
Open

fix: preserve mixed-fence code blocks in doc rendering#22350
MavenRain wants to merge 1 commit into
rust-lang:masterfrom
MavenRain:fix-doc-mixed-fences

Conversation

@MavenRain
Copy link
Copy Markdown
Contributor

@MavenRain MavenRain commented May 12, 2026

Resurrects the fix that #13850 attempted in 2023 before being closed for inactivity. format_docs_ was treating ``` and ~~~ as interchangeable fences, so a literal ~~~ line inside a ```-opened block closed the block early (and the mirror case for ```-inside- ~~~). Tracks the opening fence and closes only on a match.

Closes #13815.

  `format_docs_` was toggling `in_code_block` whenever any
  RUSTDOC_FENCES prefix appeared, so a `~~~` line inside a
  ```-opened block would close the block prematurely (and a
  ``` line inside a ~~~-opened block would do the same).
  Track which fence opened the current block in
  `current_fence: Option<&'static str>` and only close on the
  matching fence.

  Closes rust-lang#13815.

Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken markdown for mixing backticks and tildes in code block

2 participants