Closed
Description
Problem
Lines in Rust code blocks beginning with a #
and followed immediately by a character other than !
, [
, #
, or
are hidden by mdbook
but shown by rustdoc
.
For example, the following code block is rendered as empty by mdbook
:
```rust
#fn main() {}
```
Meanwhile, the following code block in a doc comment:
/// ```
/// #fn main() {}
/// ```
pub struct Foo;
Steps
mdbook init
echo '```rust\n#fn main() {}\n```' > src/chapter_1.md
mdbook serve
- Observe an empty code block. When the "Show hidden lines" button is clicked, the code block contains
fn main() {}
Possible Solution(s)
mdbook
should implement rustdoc
's behavior since the docs claim it does:
For the Rust language, you can use the # character as a prefix which will hide lines like you would with Rustdoc.
Notes
rustdoc
's rules are:
- If a line begins with
#
(note the space following the#
), the line is hidden - Two consecutive hashes
##
can be used to prevent the hiding of a line that would otherwise be hidden- To write a non-hidden line that starts with
#
, write##
which will render as#
- To write a non-hidden line that starts with
Is mdbook
willing to change this in a non-breaking release since it seems like a bug according to the docs, or would you rather wait until 0.5?
Version
mdbook v0.4.43