Skip to content

Fix stray spacing of code blocks containing injected main #1374

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

Closed
wants to merge 2 commits into from

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Nov 6, 2020

For example see the first code block in https://doc.rust-lang.org/1.47.0/book/ch03-02-data-types.html.

```rust
let guess: u32 = "42".parse().expect("Not a number!");
```

Before:

Screenshot from 2020-11-05 21-31-53


After:

Screenshot from 2020-11-05 21-32-20

@ehuss
Copy link
Contributor

ehuss commented Nov 10, 2020

Hm, so I'm uncertain about this change. There's a problem that on narrower screens, the buttons will overlap the code (see #1322). I think this could make the problem worse. I would kinda like to have a solution for the overlap problem first before deciding what to do here.

I'm uncertain if it makes sense to have a blank space on every example? Some other docs sites do that (like docusaurus).

Another option is to hide the buttons with a mouseover (like bookdown), but that doesn't work on mobile, and may not be discoverable and too magical.

Another option would be to hang the icons off the right side, but I don't know what that would look like, or if there would be enough space.

I don't really know what would be a good approach.

@dtolnay
Copy link
Member Author

dtolnay commented Nov 10, 2020

Good call.

I since realized I do not want buttons anyway on my site (​```rust,noplayground & playground = { copyable = false }) and without buttons the blank line does not appear, so I no longer need this -- feel free to close.

@pickfire
Copy link
Contributor

pickfire commented Jan 4, 2021

Is it possible to use a css based approach to do some padding on small screens?

Originally, I opened an issue in rust-unofficial/patterns#155. I was searching for issues in this repo and came across this. I believe this would not look so good on desktop or even tablets, maybe very small screens with very long first line would be affected by this, I don't think I have seen any in the wild. Even if I did, it is less annoying than the extra space which leads to me searching issues in this repo.

@Dylan-DPC-zz
Copy link

closing this, we can discuss other approaches on the issue or in a new pr

@dtolnay
Copy link
Member Author

dtolnay commented Jan 6, 2021

I filed #1433 to track in mdBook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants