Repository navigation
fix: handle emphasis color on citation et al. text outside links - #378
Conversation
sphinxcontrib-bibtex with author_year style renders textual citations as: <span>Author <em>et al.</em> [<a class='reference'>year</a>]</span> The <em> is a sibling of the <a>, not a child. The existing a.reference em selector only matched <em> inside links. Add span:has(> a.reference) > em selector to also reset emphasis styling on <em> elements that are siblings of reference links within the same parent span.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #378 +/- ##
=======================================
Coverage ? 47.75%
=======================================
Files ? 2
Lines ? 423
Branches ? 0
=======================================
Hits ? 202
Misses ? 221
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the QuantEcon Book Theme’s SCSS to ensure the “et al.” <em> text in sphinxcontrib-bibtex author-year textual citations does not inherit the theme’s emphasis color when the <em> is rendered as a sibling of the year link rather than inside it.
Changes:
- Extend the existing citation emphasis reset selector (
a.reference em) to also cover the “textual citation” DOM pattern viaspan:has(> a.reference) > em. - Apply the same selector update consistently across light, dark, and gruvbox color scheme variants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/quantecon_book_theme/assets/styles/_base.scss |
Adds a :has()-based selector to reset <em> styling for textual citations in the base (light) theme. |
src/quantecon_book_theme/assets/styles/_dark-theme.scss |
Mirrors the selector update for dark mode to ensure the reset wins against dark theme emphasis rules. |
src/quantecon_book_theme/assets/styles/_color-schemes.scss |
Mirrors the selector update for gruvbox (light + dark) so the reset applies under that scheme as well. |
🎭 Visual Regression Test ResultsDetails
Skipped testsmobile-chrome › theme.spec.ts › Theme Features › f-string interpolation styling |
Problem
The v0.20.1 CSS fix for emphasis color on citation "et al." text (
a.reference em) does not work for textual citations rendered bysphinxcontrib-bibtexwithbibtex_reference_style: author_year.With this style, the HTML structure places
<em>et al.</em>as a sibling of the<a>link, not a child:The existing
a.reference emselector only matches<em>inside<a>, so the "et al." text still displays in the theme's emphasis color (teal).Fix
Add
span:has(> a.reference) > emalongside the existinga.reference emselector in all theme variants:_base.scss(light theme)_dark-theme.scss(dark mode)_color-schemes.scss(gruvbox light + dark)This targets
<em>elements that are direct children of a<span>which also contains a direct child<a class="reference">— matching the sphinxcontrib-bibtex textual citation pattern.Browser support
CSS
:has()is supported in all modern browsers (Chrome 105+, Firefox 121+, Safari 15.4+). See caniuse.Testing
npm run buildcompiles successfullytoxpre-commit run --all-filespasses