-
Notifications
You must be signed in to change notification settings - Fork 5
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
Prevent duplicate labels in :alpha
style
#31
Conversation
There's a preview at https://juliadocs.org/DocumenterCitations.jl/previews/PR31/gallery/#alphabetic_style |
I'm going to mark this as "Draft" for now, since #29 convinced me that I'll probably want to tweak the arguments for the internal functions a little bit, and pass around the full So I'll probably make the changes to the internals and rebase this PR on top of that. |
This implements a stateful `AlphaStyle` that disambiguates the labels for the bibliography by appending a suffix "a", "b", etc. This emulates the behavior of the numeric citation style in LaTeX. To enable the generating of unique labels, there is a new internal `init_bibliography!` function that is called at the beginning of the `ExpandBibliography` pipeline step. The existing `:alpha` style is automatically upgraded to the new `AlphaStyle`. It's just easier for users to pass `style=:alpha` than to instantiate the full `AlphaStyle`. Moreover, there's no reason anyone would ever want to use the old "dumb" `:alpha` style. In addition to the new `AlphaStyle`, this also fixes some inconsistencies relative to the alphabetic citation style in LaTeX: * Up to four names are included in the label, not 3 (but 5 or more names results in 3 names and "+") * The first letter of a "particle" of the name is included in the label, e.g. "vWB08" for a first author "von Winckel"
It turns out there's a more elegant solution that doesn't require breaking backwards compatibility at all (not that the internal functions are part of the stable API; but I'd still rather not change them unless absolutely necessary): I've added a new internal function It's a much cleaner implementation for the "smart" This should now be ready for a final review and merge, and then I'll follow up with #32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this looks good to me, though I can not for a 100% review the internal code – the functionality seems to work very nicely.
@fredrikekre Can I go ahead and merge, or did you want to further review this? Also, since we didn't explicitly talk about this when QuantumCitations got merged back into DocumenterCitations and moved here: Should I still consider myself the primary maintainer of this project, as a direct continuation of QuantumCitations? If yes, I would be a bit more direct in pushing the further development:
None of this precludes any co-maintainers, i.e. you/anyone with push access to the repo from also doing any of those same things. In any case, especially with the transition to Documenter 1.0, I'll be coordinating with you and @mortenpi via comments here or on the |
If there are no further comments, I will merge this tomorrow |
This implements a stateful
AlphaStyle
that disambiguates the labels for the bibliography by appending a suffix "a", "b", etc. This emulates the behavior of the numeric citation style in LaTeX.The existing
:alpha
style is automatically upgraded to the newAlphaStyle
. It's a lot easier for users to passstyle=:alpha
than to instantiate the fullAlphaStyle
, in particular becauseAlphaStyle
needs access to all the entries of the.bib
file (so instantiating in manually would end up reading the.bib
file twice). Moreover, there's no reason anyone would ever want to use the old "dumb":alpha
style.In addition to the new
AlphaStyle
, this also fixes some inconsistencies relative to the alphabetic citation style in LaTeX:Closes #26