Skip to content

Rustdoc does not format ASCII art containing ### at the start of a line correctly #105527

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
rjvdw opened this issue Dec 10, 2022 · 4 comments · Fixed by #105539
Closed

Rustdoc does not format ASCII art containing ### at the start of a line correctly #105527

rjvdw opened this issue Dec 10, 2022 · 4 comments · Fixed by #105539
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@rjvdw
Copy link

rjvdw commented Dec 10, 2022

I tried this code:

//! This is some documentation with ASCII art:
//!
//! ```text
//! #..#.####.#....#.....##..
//! #..#.#....#....#....#..#.
//! ####.###..#....#....#..#.
//! #..#.#....#....#....#..#.
//! #..#.#....#....#....#..#.
//! #..#.####.####.####..##..
//! ```

I expected to see this happen: When I run rustdoc, I expect to see ASCII art in the output that matches the above example.

Instead, this happened: In the output, this actually appears:

#..#.####.#....#.....##..
#..#.#....#....#....#..#.
###.###..#....#....#..#.
#..#.#....#....#....#..#.
#..#.#....#....#....#..#.
#..#.####.####.####..##..

It appears that if a line starts with at least three #s, one gets "swallowed" somehow.

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0
Backtrace

n/a

@rjvdw rjvdw added the C-bug Category: This is a bug. label Dec 10, 2022
@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 10, 2022
@GuillaumeGomez
Copy link
Member

It's because of how # are handled for rust code blocks. I'll send a PR but we need to ensure that people are not relying on # to hide a line for non-rust code blocks.

@camelid
Copy link
Member

camelid commented Dec 11, 2022

This is actually a regression. I haven't bisected, but it occurred sometime between 1.50.0 and 1.63.0 based on a quick test. In 1.50.0, the following code block

/// ```markdown
/// # Header
/// ```

rendered as # Header, but in 1.63.0 it renders as a blank code block.

@camelid camelid added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Dec 11, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 11, 2022
@GuillaumeGomez
Copy link
Member

Thanks for the information @camelid !

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Dec 11, 2022
…ines-non-rust, r=notriddle

rustdoc: Only hide lines starting with `#` in rust code blocks

Fixes rust-lang#105527.

So before approving, this is a big question: in rust code blocks, in a line starts with a `#`, we hide it in the output. However, should we do the same for non-rust code blocks too? I think it's a bit problematic to do it because `#` can be used for many things but I prefer to check first with everyone (might also be worth updating documentation too).

cc `@rust-lang/rustdoc`
r? `@notriddle`
@bors bors closed this as completed in dd00582 Dec 11, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 12, 2022
@albertlarsan68
Copy link
Member

The regression is in nightly-2021-07-15

Commits in range:

commit[0] 2021-07-13UTC: Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
commit[1] 2021-07-13UTC: Auto merge of #87044 - cjgillot:expnhash, r=petrochenkov
commit[2] 2021-07-14UTC: Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkov
commit[3] 2021-07-14UTC: Auto merge of #86211 - tlyu:option-result-overviews, r=joshtriplett
commit[4] 2021-07-14UTC: Auto merge of #87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor
commit[5] 2021-07-14UTC: Auto merge of #87082 - michaelwoerister:const-in-debuginfo-type-names-fix, r=oli-obk,wesleywiser
commit[6] 2021-07-14UTC: Auto merge of #87133 - GuillaumeGomez:rollup-pfz9jbk, r=GuillaumeGomez
commit[7] 2021-07-14UTC: Auto merge of #86765 - cuviper:fuse-less-specialized, r=joshtriplett

Maybe this happened in #87056 (merged by #87133) (cc @GuillaumeGomez)

@camelid camelid removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Dec 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants