book
book copied to clipboard
Book copies code not displayed due to mdbook bug
https://rustwasm.github.io/book/hello-world.html
Some code on this page is incorrect, and is different from the source code. Presumably it was changed at some point and the site wasn't updated? Here is the offending snippet:
# #![allow(unused_variables)]
#fn main() {
#[no_mangle]
pub extern fn add_one(a: u32) -> u32 {
a + 1
}
#}
Assuming the code you're displaying is the result of using the "copy snippet" button (seems like it, since it displays fine), this is actually a bug upstream in mdbook
(there's an open issue at the moment).
Actually, I wasn't copying the snippet, that's just how it was displayed. I just realized though that NoScript was active on the page. Once I disabled NoScript it displayed fine and the code was correct. I'm not sure how many people might view the page with javascript disabled, but here's what it looked like:
Ah okay. Once that issue is resolved, this will be fixed as well. I haven't looked too much into how it'd be solved, but if you're interested it can be found here.
Since we know the root cause and there's an issue for upstream I've changed the title name and added some labels, but until this gets changed in mdbook there's not much we can do about it. Thanks for bringing it to our attention though! :D
fixed this in https://github.com/rust-lang/mdBook/pull/1911#issue-1409974442 !