book icon indicating copy to clipboard operation
book copied to clipboard

Book copies code not displayed due to mdbook bug

Open perrycate opened this issue 6 years ago • 5 comments

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
}
#}

perrycate avatar Jun 30 '18 02:06 perrycate

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).

mtn avatar Jun 30 '18 17:06 mtn

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:

screenshot_20180630_141814

perrycate avatar Jun 30 '18 18:06 perrycate

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.

mtn avatar Jun 30 '18 18:06 mtn

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

mgattozzi avatar Jul 03 '18 15:07 mgattozzi

fixed this in https://github.com/rust-lang/mdBook/pull/1911#issue-1409974442 !

yoyomo avatar Oct 17 '22 18:10 yoyomo