ppannuto / python-titlecase

Python library to capitalize strings as specified by the New York Times Manual of Style
MIT License
243 stars 36 forks source link

bibtex support #94

Open jeisner opened 6 months ago

jeisner commented 6 months ago

Might you consider adding BibTeX support? Many people miscapitalize titles in their BibTeX entries. The title is supposed to look like the output of the titlecase module, which is why this person used the module.

However, substrings that have "inherent case" are supposed to be enclosed in protective {} to prevent individual BibTeX styles from changing their case. It seems easier to handle that within titlecase than by some kind of postprocessing.

ppannuto commented 3 months ago

IIUC, I believe title casing rules in the *tex universe should be defined by the .bst file controlling bibliography generation. Latex/bibtex/natbib/etc have their own built in titlecasing engines, the casing in the source bibtex doesn't matter (beyond {} as an escape).

I don't think this is something that makes sense to build into titlecase (though feel free to re-open if you feel strongly otherwise).

jeisner commented 3 months ago

No, bibtex doesn't do titlecasing! That's why I spend too much time fixing my co-authors' incorrect .bib files. :-/

.bib files have to already provide titlecase as input because bibtex is not intended to be smart enough to know which words would be uppercased by titlecase.

This titlecase entry can then be modified by the .bst style, for example to leave book titles alone but do more lowercasing in article titles (when not protected by {}).

I wasn't very explicit about the kind of bibtex support that I was suggesting. If I recall, I was thinking of a bibtex=True flag that says

jeisner commented 3 months ago

though feel free to re-open if you feel strongly otherwise).

I don't seem to have the power to do so, though I can still comment.

ppannuto commented 3 months ago

Ah, I understand what you're going for now—more like a "include escape sequences for bibtex in output" mode?

That seems like a reasonable thing to add. Not something I'll have a chance to implement any time in the forseeable future, but I'm happy to take a PR that adds support.

jeisner commented 3 months ago

more like a "include escape sequences for bibtex in output" mode?

Yes, and also respect them if they're in the input.

If you can reopen the issue, maybe I or someone else can get around to it at some point. Thanks.