Skip to content

fix: handle emphasis color on citation et al. text outside links - #378

Merged
mmcky merged 1 commit into
mainfrom
fix/citation-em-sibling-selector
Apr 6, 2026
Merged

mmcky merged 1 commit into
mainfrom
fix/citation-em-sibling-selector

Conversation

@mmcky

@mmcky mmcky commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

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 by sphinxcontrib-bibtex with bibtex_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:

<span id="id17">Barillas <em>et al.</em> [<a class="reference internal" href="...">2009</a>]</span>

The existing a.reference em selector 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) > em alongside the existing a.reference em selector 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 build compiles successfully
  • All 82 tests pass via tox
  • pre-commit run --all-files passes

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

codecov Bot commented Apr 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@172bd74). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #378   +/-   ##
=======================================
  Coverage        ?   47.75%           
=======================================
  Files           ?        2           
  Lines           ?      423           
  Branches        ?        0           
=======================================
  Hits            ?      202           
  Misses          ?      221           
  Partials        ?        0           
Flag Coverage Δ
pytests 47.75% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via span: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.

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

🎭 Visual Regression Test Results

passed  45 passed
skipped  1 skipped

Details

stats  46 tests across 1 suite
duration  1 minute, 9 seconds
commit  018006d

Skipped tests

mobile-chrome › theme.spec.ts › Theme Features › f-string interpolation styling

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions
github-actions Bot temporarily deployed to pull request April 6, 2026 02:37 Inactive
@mmcky
mmcky merged commit 44aeb6a into main Apr 6, 2026
13 checks passed
@mmcky
mmcky deleted the fix/citation-em-sibling-selector branch April 6, 2026 02:53

This branch was previously deployed

1 inactive deployment
pull request — 018006d3 Deployed Apr 6, 2026 by github-actions[bot]
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.

2 participants