Skip to content

feat: Add option to preserve TeX markup in cache #865

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benthamite
Copy link
Contributor

@benthamite benthamite commented Jul 1, 2025

NB: the PR is not ready to be merged. Please read below for a description of the required additional changes.

The PR introduces a new user option, citar-cache-preserve-markup, to control whether TeX markup is preserved in bibliography fields when populating the Citar cache. This helps address issues with incorrect capitalization in formatted references, as reported in #784.

Problem

When using citar-insert-reference with citeproc-el, titles and other fields may not be capitalized correctly. This is because citar's caching mechanism, which uses parsebib-parse, strips TeX markup by default. For example, a title like {Can humans be the {FORTRAN} of creatures?} becomes "Can humans be the fortran of creatures?", losing the intended capitalization of "FORTRAN".

Solution

This change introduces a new boolean custom variable, citar-cache-preserve-markup.

  • When nil (the default), citar maintains the existing behavior of stripping TeX markup.
  • When t, citar preserves TeX markup by passing :display nil to parsebib-parse.

The cache invalidation logic has also been updated. The cache will now be rebuilt if the value of citar-cache-preserve-markup changes, ensuring that the cached entries reflect the user's current setting.

Known Issues

Preserving markup across all fields can have side effects on downstream processors like citeproc-el, which may not expect markup in certain fields (e.g., date or author). This can lead to parsing errors or incorrect formatting for those fields.

This change provides a way to solve the capitalization issue, but a full solution requires improvements to the parsers in citeproc-el. Since I don’t understand the inner workings of this other package, I am not able to implement those changes myself.

Co-authored-by: aider (gemini/gemini-2.5-pro-preview-06-05) <aider@aider.chat>
@bdarcus
Copy link
Contributor

bdarcus commented Jul 4, 2025

I'll take a look at this soon, but note that the CI check is failing currently, and you can convert this to a draft to indicate it's "not ready" status.

@benthamite benthamite marked this pull request as draft July 4, 2025 12:10
@benthamite
Copy link
Contributor Author

I didn't know about the ‘draft’ option, thanks.

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