FlamingTempura / bibtex-tidy

Cleaner and Formatter for BibTeX files
https://flamingtempura.github.io/bibtex-tidy/
MIT License
832 stars 63 forks source link

Please remove from sorting keys @string @xdata #405

Closed mafsi closed 1 year ago

mafsi commented 1 year ago

@xdata & @string are also sorted when --sort=key is passed.

@string{ucp      = {University of California Press}}

@xdata{uchp,
  location      = {New York},
  publisher     = {University of Chicago Press}
}

...
rest of the `.bib` file
FlamingTempura commented 1 year ago

Any reason these should not be sorted? Personal preference or is the order important for biblatex?

mafsi commented 1 year ago

Usually these entries are at the top of the .bib file as references, then added to the references to speed up the process of repeatedly writing certain fields. When they are sorted, they appear interspersed through the references. The idea is that only the references should be sorted, not these entries.

For example:

@string{uchp = {University of Chicago Press}}

@xdata{hum,
  location = {București},
  publisher = {Humanitas}
}

....

@book{lincoln:theorizing,
  title = {Theorizing myth},
  subtitle = {Narrative, ideology, and scholarship},
  author = {Lincoln, Bruce},
  year = {1999},
  pagetotal = {298},
  location = {Chicago},
  publisher = uchp,
  isbn = {0226482022}
}

@book{blaga:trilogyb,
  title = {Trilogy of Culture},
  author = {Blaga, Lucian},
  year = {2011},
  isbn = {978-973-50-2953-1},
  xdata = {hum}
}
FlamingTempura commented 1 year ago

Thanks for clarifying.

To explain how it works currently: @string blocks are treated the same as comments; they glue themselves to the next entry such that they remain above the same entry when sorted. @xdata has no special handling and is sorted the same as any other entry.

Here's my current proposal, keen to get your thoughts. We could allow you to specify special as a sort field to bring any special blocks (@string, @xdata, @preamble, @set) to the top of the file.

This could be combined with other sort fields, e.g. special,key to have special blocks at the top, then sort by key.

mafsi commented 1 year ago

I think your proposal is an excelent idea. Thanks for adding this, and thanks for your work!

FlamingTempura commented 1 year ago

As of v1.11.0 / current web UI, you can specify special as a sort field. I'll close this ticket, but let me know if there are any issues.

mafsi commented 1 year ago

Is working on the website. I'm waiting the NPM package to be updated. Thanks a lot!