dcpurton / biblatex-sbl

Society of Biblical Literature (SBL) style files for biblatex
24 stars 5 forks source link

Set up more consistent delimiter contexts in citations, abbreviations, and bibliography #108

Open dcpurton opened 5 years ago

dcpurton commented 5 years ago

Delimiter contexts end up nearly always being bib. Recent changes in biblatex make it easier to do this.

moewew commented 5 years ago

I haven't had a proper look at the code, but I've always been wondering if it wouldn't be easier to make all those cite:<type> drivers simple bibmacros instead (maybe remove the begentry/finentry stuff etc.). Is there any benefit one gets from using drivers instead of bibmacros?

dcpurton commented 5 years ago

@moewew to be honest I don't know!

I just copied the behaviour of biblatex-chicago. And of course the standard verbose styles of biblatex end up calling the drivers as well since the output for the first citation is identical to the output in the bibliography.

Actually, don't you have to? The driver takes care of printing the right output based on entry type. For biblatex-sbl, the output varies wildly depending on the entry type.

moewew commented 5 years ago

Yes, biblatex-chicago does it, but the style also uses \cite commands in the bibliography, something that I would try to avoid as well. The standard styles only use \usedriver to reproduce the bibliography output so we don't get into trouble setting the delimiter context to bib (and indeed it is because of this that we did that in the first place).

As I said, I haven't tested this, but if instead of \usedriver{}{cite:\thefield{entrytype}} you say

\usebibmacro{cite:\thefield{entrytype}}%

you can define all your cite:... drivers as normal bibmacros.

In principle bibdrivers and bibmacros aren't that different, so in theory this should work.

dcpurton commented 5 years ago

@moewew , oooo. I see what you mean.

However, before I go down this track, what about the related:default macro. This uses \usedriver in the standard styles and I also make extensive use of related entries in citations. The related bibmacros also use the hook in \usedriver to change various definitions within a group. Would you recommend using a bibmacro here also, e.g.,

\newbibmacro*{related:default}{%
  \ifbibliography
    {\usedriver{%
       % redefine macros for related output
     }{\thefield{entrytype}}}
    {\begingroup
     % redefine macros for related output
     \usebibmacro{cite:\thefield{entrytype}}%
     \endgroup}}

This doesn't really seem better than using the driver everywhere.

Also, why would you get rid of of begentry/finentry?

moewew commented 5 years ago

Mhhh, yes I haven't thought through all the implications for your code. And maybe going over to bibmacros instead of drivers is just a bad workaround for the real issue (namely that \usedriver shouldn't get us into bib context; but I'm afraid that I can't see a way out of this at the moment, we - the standard styles - sort of rely on it and if we change that, which would probably involve adding the initialisation to \AtUsedriver or worse the pre-code of \usedriver, then contributed styles also relying on it might break, not sure how many would be affected, but at least biblatex-gost would be a potential victim).

It would of course be possible to make the code a bit prettier by introducing a helper macro like

\newcommand*{\bibcitedriver}[2]{%
  \ifbibliography
    {\usedriver{#1}{#2}}
    {\begingroup
     #1%
     \usebibmacro{cite:#2}%
     \endgroup}}

and then saying

\newbibmacro*{related:default}{%
  \bibcitedriver
    {%
     % redefine macros for related output
    }
    {\thefield{entrytype}}}

I was wrong about begentry and finentry is a bit tricky, but what I was ultimately trying to say is that you need to keep in mind that every \usedriver executes

\AtUsedriver{%
  \let\finentry\blx@finentry@usedrv
  \let\newblock\relax
  \let\abx@macro@bibindex\@empty
  \let\abx@macro@pageref\@empty}

and thus disables or redefines certain macros.