moewew / biblatex-ext

Extensions for the biblatex standard styles
LaTeX Project Public License v1.3c
24 stars 3 forks source link

Limitation of oa #34

Open bastien-roucaries opened 2 years ago

bastien-roucaries commented 2 years ago

Hi,

I want to redirect url to web.archive.org if url+an is archived (I will do a small package for this). However because \iffieldannnotation is not expandable I needed to patch \extblx@oa@url@definefieldurl instead of

DeclareOpenAccessFieldUrl[always]{url}{
\iffieldannotation[#2]{archived}{https://web.archive.org/web/\thefield{url}}{\thefield{url}}
}

I suppose they are two bugs:

\def\extblx@oa@url@definefieldurl#1#2#3#4{%
  \csdef{extblx@oa@url@from@#2}{#2}%
  \ifstrequal{#4}{always}
    {\csdef{extblx@oa@url@getfromfield@#1}{%
       \iffieldannotation[#2]{closedaccess}
         {}
         {\iffieldannotation[#2]{archived}{\def\extblx@oa@url{https://web.archive.org/web/#3}}{\def\extblx@oa@url{#3}}}}}
    {\csdef{extblx@oa@url@getfromfield@#1}{%
       \iffieldannotation[#2]{closedaccess}
          {\@secondoftwo}
          {\iffieldannotation[#2]{openaccess}
             {\@firstoftwo}
             {\ifcsequal{extblx@oa@url@from}{extblx@oa@url@from@#2}
                {\@firstoftwo}
                {\ifcsequal{extblx@oa@url@from}{extblx@oa@url@from@all}
                  {\@firstoftwo}
                  {\@secondoftwo}}}}
         {\iffieldannotation[#2]{archived}{\def\extblx@oa@url{https://web.archive.org/web/#3}}{\def\extblx@oa@url{#3}}}
         {}}}}

I believe also this piece of code could be rewritten more clearly using latex3...

moewew commented 2 years ago

The issue with \iffieldannotation is off-topic here. That is purely a biblatex issue. The problem with implementing a command like this is that it is difficult to grab optional arguments expandably in LaTeX (seems possibly in certain cases with xparse, but not generally: https://tex.stackexchange.com/q/602944/35864).

As for the other point: What kind of customisation and interface (!) are you realistically looking for?

bastien-roucaries commented 2 years ago

Hi,

I perfectly understand. I manage for my lab a few huge bibliography database and every time we get something open acess we get it archived by the wayback machine. When document get dead I would like to set the url+an{archived} attribute.

Moreover the goal it to add a clickable urldate to webarchive, and get our phdthesis more resistant to dead link

moewew commented 2 years ago

The motivation is clear, but the question is what kind of general interface you want to see on the biblatex-ext side (either as a user-facing feature or as something developers can hook into).

I don't think I want to implement your archived feature directly in biblate-ext, because it doesn't seem to be in scope for the open access detection feature, but that shouldn't stop us from devising a general interface or - if that does not appear useful - you from implementing whatever you need by messing with some internal macros of biblatex-ext. Of course using internal macros is always a bit risky, but it's better than nothing.

bastien-roucaries commented 2 years ago

@moewew I suppose \def\extblx@oa@url@definefieldurl could be simplified using latex3 construct. Note the duplication of \iffieldannotation[#2]{archived}{\def\extblx@oa@url{https://web.archive.org/web/#3}}{\def\extblx@oa@url{#3}}}} ...

If we could deduplicate I can only patch at one place...

moewew commented 2 years ago

Sure, things might be a bit more streamlined with expl3, but I wouldn't want to mix languages, so this would require a complete overhaul of biblatex-ext-oa.sty into expl3, which doesn't seem worth this gain.

Things might be different in a complete re-implementation, but in the current setup I can't see an elegant (non-ad-hoc) way around repeating the \def\extblx@oa@url{#3} in two places.