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

setting display: block on inline targets breaks things badly #315

Closed
drammock opened this issue Feb 2, 2021 · 5 comments · Fixed by #318
Closed

setting display: block on inline targets breaks things badly #315

drammock opened this issue Feb 2, 2021 · 5 comments · Fixed by #318
Milestone

Comments

@drammock
Copy link
Collaborator

drammock commented Feb 2, 2021

We're using sphinxcontrib-bibtex to handle citations; notice how the left bracket on the reference link is no longer inline, it shows up separated from its number and crashing into the title, and the remainder of the text starts a new paragraph:

pydata

I think this problem was introduced with #283 (or possibly #280).

this is how it should look (ignore the different spacing between top navbar and section title, that's just a page scrolling difference):

fixed

A proposed fix using javascript instead of CSS (note that the various disjuncts in the conditional may need to be made more general for it to work for all sphinx sites, not just ours):

<!-- this snippet prevents in-text anchors from being hidden under the -->
<!-- navbar when the page scrolls to them (citation/equation backlinks -->
<!-- are worst affected). -->
<script type="text/javascript">
    if ($(".navbar.fixed-top").length > 0) {
        var navHeight = $(".navbar").height();
        var shiftWindow = function() {
                var ourURL = document.URL;
                if ( (ourURL.search(/#[a-z]+\d\d\d\d$/) > 0) ||  // footbib item (bibtex key)
                     (ourURL.search("#id") > 0) ||               // footbib backreference
                     (ourURL.search("#equation") > 0) ) {        // numbered equation
                    scrollBy(0, -navHeight - 12);
                };
            };
        if (location.hash) shiftWindow();
        window.addEventListener("hashchange", shiftWindow);
    };
</script>
@jorisvandenbossche
Copy link
Member

Thanks for the report!
Does one of the preview builds in mne-tools/mne-python#8757 exhibit this, so it can be inspected live?

We actually have some footnote examples in the demo docs at https://pydata-sphinx-theme.readthedocs.io/en/latest/demo/demo.html#footnotes, so we should need to figure out what the difference is with the ones generated by sphinxcontrib-bibtex, as it seems to be working in our demo.

@drammock
Copy link
Collaborator Author

drammock commented Feb 2, 2021

Here it is: https://24938-1301584-gh.circle-artifacts.com/0/dev/overview/implementation.html#id1

Sorry, I should have thought to include that to begin with.

@drammock
Copy link
Collaborator Author

drammock commented Feb 2, 2021

actually it's broken on your demo site too: https://pydata-sphinx-theme.readthedocs.io/en/latest/demo/demo.html#id25

@jorisvandenbossche
Copy link
Member

Hmm, how did you get to that link?
If I just go to the demo page (without #id25 in the url), it renders fine. And don't directly see where I need to click to get that id25. When clicking the actual reference to go to the footnote, that works fine (although the offset doesn't seem to be working in this case, as it's hidden behind the navbar .. so that's another case that is not yet fixed).

@jorisvandenbossche
Copy link
Member

OK, I see, it's the "back" reference from the footnote to where it is referenced. That indeed triggers the issue in our demo docs as well. Thanks for pointing that out!

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 a pull request may close this issue.

2 participants