Giter VIP home page Giter VIP logo

Comments (4)

kiryph avatar kiryph commented on August 26, 2024

@ge-ne Any chance you could have a look into this older issue as well. Is this more complicated than I imagine?

from bibtool.

ge-ne avatar ge-ne commented on August 26, 2024

sort.format = { %s($type) %s(year) %s(month) {%N(author) # %N(editor)} }

Whenever a format specifier fails -- because a field is not found or other reasons -- then backtracking takes place and an alternative is sought.
In the example this happens for the fields year and month which are not present in the new types.Thus backtracking occurs until the whole format fails. Finally the default key is used as final alternative. For those entries the key determines the sorting order. This can be seen when using the format to generate new keys.
A construction like {%s(year)#} and {%s(month)#} solve this problem.
The same behaviour can show up when neither author nor editor are present. The solution applies he same trick.

from bibtool.

kiryph avatar kiryph commented on August 26, 2024

Thanks for the explanation and solution. Very much appreciated.

I have read section A.7 in the documentation again. I think a few places could be improved. For example, the sentence

If everything fails the sort key is empty.

should be

If everything fails, the sort key is empty and the default sort key is used which is the reference key.

This is already mentioned at the beginning of this section:

The sort key is by default the reference key.

Also I would add something like

Whenever a format specifier fails -- because a field is not found or other reasons -- then backtracking takes place and an alternative is sought. Backtracking occurs until the whole format fails and the default sort key is used which is the reference key.
For example, when you want to sort chronologically by year and month as the first criteria and as secondary criteria by author or editor name, you should write the expression as

sort.format = { {%s(year) # } {%s(month) # } {%N(author) # %N(editor) # } }

This avoids that the whole sort format fails if any of year and month or both author and editor are not present.

For debugging purposes, I tried to see the sort key with

% Sort records
sort                     = on
sort.macros              = {off}
sort.format              = { %s($type) {%s(year)#} {%s(month)#} {%N(author) # %N(editor) #} }

add.field {sort="%s($sortkey)"}

However, the new field 'sort' is empty? Did I miss something?

Finally, I want to take here the opportunity to thank you for all your recent comments, commits and in general for bibtool. Many open source projects are abondaned after period of time but often I encounter issues which I would hope could be addressed.

from bibtool.

ge-ne avatar ge-ne commented on August 26, 2024

However, the new field 'sort' is empty? Did I miss something?

The field rewriting (add.field) is performed before key creation. This is necessary to make sure that fields referenced in sort format can be provided before they are used. Thus the sort key is empty when you add it...

from bibtool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.