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

add modded CSS from basic theme for footnotes/citations #313

Merged
merged 5 commits into from
Mar 30, 2024

Conversation

2bndy5
Copy link
Collaborator

@2bndy5 2bndy5 commented Feb 1, 2024

resolves #312

I also noticed that the npm run check wasn't getting executed in CI; I think there were some changes in GH Actions' expressions about contains().

@2bndy5 2bndy5 force-pushed the fix-footnote-display branch 2 times, most recently from 2f747c4 to e5887a0 Compare February 1, 2024 19:12
@jbms
Copy link
Owner

jbms commented Feb 1, 2024

One thing I noticed is that the first line of the footnote text, if it is wrapped, gets indented more because it is pushed over by the float. This problem is addressed by the use of a table or ol element. We could also fix it in CSS though by using CSS grid without changing the html. Alternatively just increasing the padding would probably fix it in most cases.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 1, 2024

I noticed that too. I actually decreased the padding (paragraph's margin-left) because wrapped lines looked oddly estranged. As for the floated element pushing the first line of a paragraph, I'll look into the CSS grid idea. The problem is that the footnote label/back-link(s) are not guaranteed to always be the same width (as evident by the citation example).

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 1, 2024

I ended up going with flex because CSS grids are designed to be statically oriented (based on space available) which tended to reserve more space for the footnote label/backrefs than minimally needed. I like the way this looks now:
image

EDIT: scratch that. A second paragraph in footnote content renders as a new column... Still investigating

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 1, 2024

Using the grid technique works pretty well:
image
Obviously, I have to adjust the margin of the paragraphs still...

But for citations that have a span for .label and .backrefs the grid auto expands to 2 rows to compensate for 2 span items in column 1:
image

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 2, 2024

Ok, I just used separate rules for specifying columns of a citation or footnote. Also, the contents are not guaranteed to be paragraphs, so I adjusted the copied p selectors from the basic theme to use :not(span.class).

locally used examples:
image
image

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 2, 2024

I found and fixed a flaw with my CSS grid attempt. Citations and footnotes now use a 3 col grid. The 2nd col is used for multiple backrefs. If there is only 1 backref, then it is incorporated into the span.label (in col 1) and col 2 is auto-shrunk to invisible width.

@jbms
Copy link
Owner

jbms commented Feb 2, 2024

Thanks.

I'm not sure exactly what the desired formatting is. However if we want to achieve table-like formatting, where the text content is all aligned even if the label portions have different widths, then we need all of the footnotes to be contained within a single grid.

One way to achieve that is to apply display: grid to the outer aside.footnotes container, apply display: contents; to the inner aside.footnote element, and then assign the inner elements as you are currently doing. That is the technique I've used for similar things in the past.

Now that css subgrid (https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Subgrid) is supported by all major browsers, this could also be done in a cleaner way using CSS subgrid without having to rely on the display: contents; hack. However, I haven't used CSS subgrid myself.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 2, 2024

I did see the subgrid docs when researching, but I didn't think it was really applicable.

Using a subgrid, the multitude of elements put in col 3 overlap each other:
image

When each footnote/citation is a separate grid, the multitude of elements in col 3 get a new row for each element:
image

I'm still trying to figure out a way to use subgrids for this. It would be easier if the footnote/citation content was encapsulated in a container element, but they aren't.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Mar 28, 2024

ping @jbms

TL;DR: using nested CSS grids would require monkeypatching Sphinx's output of footnotes/citations. The body of the footnote/citation needs to be contained in a separate HTML element, but instead Sphinx outputs the body within the same container element that also holds the elements describing the back-ref.

I'd rather not resort to monkeypatching just to satisfy a desired CSS design.

@2bndy5 2bndy5 merged commit 63a80bb into main Mar 30, 2024
71 checks passed
@2bndy5 2bndy5 deleted the fix-footnote-display branch March 30, 2024 06:08
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.

Extra whitespace for rendered footnotes/citations
2 participants