rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
18.11k stars 1.63k forks source link

Support languages other than Rust for "Hiding code lines" #1475

Open ZeWaka opened 3 years ago

ZeWaka commented 3 years ago

Note: This is not clearly specified in the documentation that it only works for Rust as well.

Here is the line of code that causes this behavior: https://github.com/rust-lang/mdBook/blob/c83bbd631930787c7844b185917d40bcc28733d8/src/renderer/html_handlebars/hbs_renderer.rs#L803-L805

Therefore, since the language is not Rust, we execute https://github.com/rust-lang/mdBook/blob/3f39ba82f9b9cdaa0e8dd3eed91decb1e31a7de4/src/renderer/html_handlebars/hbs_renderer.rs#L851-L853 instead, leading us to not call hide_lines.

This might just be an oversight. However, I know some languages would not be happy with this, as they use # for comments.

Therefore, a proper fix for this (imo) would be a configurable BORING_LINES_REGEX, and remove the language restriction.

baszalmstra commented 3 years ago

+1 Would also love to see this!