-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The source code typography is broken #378
Comments
Hi @Songbird0 as far as I know RBE is not yet ported to mdbook (it uses a customized gitbook). And if the snippet you have pasted your comment is any indicator it looks like the typography is already broken and the text gets misaligned on monospaced font (possibly the RBE gitbook uses non monospaced font and the snippet was hand edited to make it align.) I was able to realign it by hand reasonably easily in github editor (mdbook renderer will give similar results as the github's pre block) Unfortunately I'll not be able to help during the next two weeks as I'm on holidays mobile only. |
Yes, RBE is not yet using mdBook, see rust-lang/rust-by-example#248 |
Hi, Thanks all for answering.
Yes, I know, but it will be ported and you'll find the same problem certainly, so I'd like to solve it on my own.
I'm not sure to understand. I cannot hand edit a snippet rendered by mdbook. :/ |
What I meant is that most likely the foo.rs that you are including has already misaligned comments ( the code that you included in your comment certainly does) and as a result it does not align on the final rendering by mdbook. If I'm correct then the problem should be corrected in the foo.rs instead of mdbook. You can check if the code is properly aligned by viewing it in an editor and choosing a monospaced font like consolas/menlo (google for the one typical for your OS and editor) I'd like to have a look on the original file that you are trying to render (foo.rs) to be sure. Could you attach it to this bug report? But as stated before I'll might not be able to help right now. |
The page alignment doesn't appear to render correctly on mobile. I don't know the reason for that behavior but it should be well behaved in most normal desktop text editors. It looks like mdbook use pulldown-commonmark as the renderer. You should use a small testcase of the problem, such as something like this and run it though the markdown renderer and see if the correct HTML is generated. If it is not, submit it as an issue in the cmark renderer. If it is not the renderer, then the problem is elsewhere: ────┐
// │ |
Ok, I tried with Sublime Text 3.
Result (in Sublime Text 3): Refresh... Result (in my Firefox browser): Note(!): When JavaScript and fonts are disabled on my browser, the typography isn't broken, see: If I allow
Done ! -> brokentypo.zip
No problem, I'm not in hurry.
I track their repository. Thanks again for your help. |
It looks correct on my computer in firefox. Did you try a fresh profile? It might not be markdown rendering in that case. It might be a font related issue or something else. |
@Songbird0 I've looked on the attached file with mobile text editor and the lines match perfectly on "DejaVu Sans Mono" font and are completely broken on any other (monospaced or not) so this has nothing to do with renderer and most likely the default pre font on your browser (and the one used by RBE gitbook variant) happens to be DejaVu or compatible while the downloaded google fonts from cdn are not. Unfortunately I cannot say more atm. I guess I would prefer not to modify mdbook fontset just to cater for this particular comment formatting (lifetime lint lines from rustc work ok on all monospaced fonts that I've tested sone time ago) |
@Songbird0 unfortunately requiring readers to change their browser settings for the webpage to render properly is a nonsolution 😞 . I'll look into the problem further when I'm back behind proper keyboard. |
All right. See you soon! :) |
Hi I'had a cursory look over the problem and Im not able to reproduce this issue on my Arch Linux Firefox (renders ideally) and chromium (also looks very good but not as pixel perfect). On the other hand it looks that RBE's typography on android chromium is similarly broken. I have to admit that I'm not a webdev and someone with cross browser webdev experience would have to look at this issue. Some google webfonts magic might help here. |
With the @Songbird0 when you have some time, could you try to fiddle with the fonts on the rendered page to see if other fonts work better? You can change them on the fly using the developers tools in your browser. |
Thanks! This font was introduced in PR #250, maybe we should remove it from the list? |
Hmm the |
Unsure, but the fallback stack should be sufficiently exhaustive to have at least one monospace font available on mobile? |
I've looked into android mobile chromium. It looks like like only |
The problem currently still exists on https://doc.rust-lang.org/stable/. See for example https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime.html. The problem is that while the font itself (Source Code Pro Medium) does include the box drawing characters (U+2500-259F), the hosted version via https://fonts.googleapis.com/css?family=Source+Code+Pro:500 does not. The browser then falls back to a different font with different tracking, Consolas in my case. I see three possible ways to fix this:
I think 1 is probably the best solution, but I see that #848 wasn't going forward, so maybe 2 or 3 might be worth pursuing? |
Hi,
I'm translating RBE from English to French so I've copied this source code to translate its comments:
I preserved the originals comments not to break typography. When I put this code in
{{#playpen source/foo.rs}}
, the server displays:How to fix it ?
Regards.
The text was updated successfully, but these errors were encountered: