Skip to content
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

CSS: Do not allow section anchor ¶ to wrap alone to next line #1412

Open
benjaoming opened this issue Jan 17, 2023 · 5 comments · May be fixed by #1417
Open

CSS: Do not allow section anchor ¶ to wrap alone to next line #1412

benjaoming opened this issue Jan 17, 2023 · 5 comments · May be fixed by #1417
Labels
Bug A bug Good First Issue Good for new contributors Improvement Minor improvement to code

Comments

@benjaoming
Copy link
Contributor

We need a CSS rule that prohibits the Pilcrow (¶) from jumping to the next line. It's hidden so it looks weird.

image

@benjaoming benjaoming added Improvement Minor improvement to code Bug A bug Good First Issue Good for new contributors labels Jan 17, 2023
@benjaoming benjaoming changed the title Do not allow section anchor to wrap alone to next line Do not allow section anchor ¶ to wrap alone to next line Jan 17, 2023
@benjaoming benjaoming changed the title Do not allow section anchor ¶ to wrap alone to next line CSS: Do not allow section anchor ¶ to wrap alone to next line Jan 17, 2023
@n-peugnet
Copy link

n-peugnet commented Jan 20, 2023

This can be done by adding the following CSS (tested on Firefox and Chromium):

.rst-content a.headerlink {
  display: inline;
}

As no space is present between the headerlink and the previous word, it forces them to be wrapped together.

Peek 2023-01-20 15-15

@benjaoming
Copy link
Contributor Author

As no space is present between the headerlink and the previous word

Ah yeah, perhaps we can add a   - I guess this is exactly what it is meant for :)

@n-peugnet
Copy link

n-peugnet commented Jan 20, 2023

As no space is present between the headerlink and the previous word

Ah yeah, perhaps we can add a   - I guess this is exactly what it is meant for :)

Not really, the problem comes from the fact that currently the .headerlink is set to display: inline-block, so it will always first wrap at the block boundary. With no CSS at all, the behaviour would be the expected one, as the <a> is not separated from the previous word with any space and its default display mode is inline.
Using a &nbsp here will only add complexity, adding space with margin-left as currently done seems a better idea.

I never used SASS but it seems display: inline (or display: initial) can be added here:

h1, h2, h3, h4, h5, h6, dl dt, p, p.caption, table > caption, .code-block-caption, .eqno
.headerlink
opacity: 0
font-size: 14px
font-family: FontAwesome
margin-left: 0.5em
@extend .fa
&:focus
opacity: 1
&:hover .headerlink
opacity: 1

@benjaoming
Copy link
Contributor Author

Roger! Thanks for the wonderful explanation!

If you would like to submit a PR, I can build the SASS and push to your PR 👍 Alternatively, there is a Makefile in our project with some Docker build stuff.

@n-peugnet
Copy link

If you would like to submit a PR, I can build the SASS and push to your PR

I think that I prefer this option. I will make the PR right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Good First Issue Good for new contributors Improvement Minor improvement to code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants