Skip to content

fix: exclude emphasis color styling from citation reference links (et al.)#366

Open
mmcky wants to merge 3 commits intomainfrom
fix/citation-emphasis-styling
Open

fix: exclude emphasis color styling from citation reference links (et al.)#366
mmcky wants to merge 3 commits intomainfrom
fix/citation-emphasis-styling

Conversation

@mmcky
Copy link
Contributor

@mmcky mmcky commented Feb 19, 2026

Summary

Fixes emphasis color styling being applied to et al. text inside citation reference links.

Problem

The theme's emphasis styling replaces italics with a colored, semi-bold treatment for <em> tags. However, Sphinx/sphinxcontrib-bibtex renders "et al." inside citation links as <em>et al.</em>, which causes the emphasis color to be applied within the citation link text.

For example, in a reference like:

Barillas et al. [2009]

The "et al." was displaying in teal (the emphasis color) instead of matching the rest of the link text.

From doubts_or_variability

Fix

Added a.reference em CSS overrides that reset em tags inside reference links to inherit color and font-weight from their parent anchor element. Applied across:

  • _base.scss — default light theme
  • _dark-theme.scss — dark mode
  • _color-schemes.scss — gruvbox and gruvbox dark variants

The compiled CSS assets have been rebuilt.

@mmcky
Copy link
Contributor Author

mmcky commented Feb 19, 2026

This PR address the feedback from @HumphreyYang QuantEcon/lecture-python.myst#809

@codecov

This comment was marked as outdated.

The theme's emphasis styling (color + semi-bold weight) was being applied
to <em> tags inside citation reference links, causing 'et al.' text in
references like 'Barillas et al. [2009]' to display with the emphasis
color instead of inheriting the link color.

Add 'a.reference em' overrides in base, dark theme, and color scheme
styles to reset em tags inside reference links to inherit from their
parent link element.
@mmcky mmcky force-pushed the fix/citation-emphasis-styling branch from cb48009 to 36cb8a6 Compare February 19, 2026 07:17
@QuantEcon QuantEcon deleted a comment from github-actions bot Feb 19, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🎭 Visual Regression Test Results

passed  45 passed
skipped  1 skipped

Details

stats  46 tests across 1 suite
duration  1 minute, 1 second
commit  c2a5ef7

Skipped tests

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

@github-actions github-actions bot temporarily deployed to pull request February 19, 2026 07:25 Inactive
@mmcky mmcky requested a review from Copilot February 19, 2026 07:37
Copy link
Contributor

Copilot AI left a comment

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 adjusts the theme’s emphasis styling so that et al. (rendered as <em>…</em> inside sphinxcontrib-bibtex citation links) no longer picks up the theme’s emphasis color/weight treatment and instead matches the surrounding citation link text.

Changes:

  • Add CSS overrides for <em> nested within Sphinx “reference” anchors to inherit the anchor’s styling.
  • Apply the override in the base (light) styles, dark theme overrides, and gruvbox color schemes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/quantecon_book_theme/assets/styles/_base.scss Adds an override for <em> inside a.reference to inherit link styling.
src/quantecon_book_theme/assets/styles/_dark-theme.scss Adds a dark-mode override for <em> inside a.reference.
src/quantecon_book_theme/assets/styles/_color-schemes.scss Adds gruvbox and gruvbox-dark overrides for <em> inside a.reference.

@mmcky
Copy link
Contributor Author

mmcky commented Feb 19, 2026

Investigation Summary

After investigating the actual HTML output from sphinxcontrib-bibtex, the CSS selectors in this PR (a.reference em) are ineffective — the <em>et al.</em> text is a sibling of the <a> tag, not a child:

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

Additionally, the wrapper <span> has no CSS class, making it impossible to target citation <em> elements with pure CSS.

Upstream Fix

We've submitted a 1-line fix to sphinxcontrib-bibtex to add a bibtex-citation class to the citation wrapper node:

If merged, this PR can be revised to use .bibtex-citation em as the selector, which will correctly target only citation emphasis text.

@mmcky
Copy link
Contributor Author

mmcky commented Feb 23, 2026

  • wait for the next sphinxcontrib-bibtex to be released and then u update to leverage the new class.

@github-actions github-actions bot temporarily deployed to pull request February 23, 2026 22:17 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants