Skip to content

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

@drammock

Description

@drammock

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions