ShortCodes.jl icon indicating copy to clipboard operation
ShortCodes.jl copied to clipboard

Add formatting option for DOI

Open ghost opened this issue 3 years ago • 2 comments

First off, very cool package, especially when using with Pluto.jl. One thing that would be very useful from a stylistic viewpoint is being able to specify some formatting changes to the return reference. Specifically being able to truncate the number of authors and exclude citations, for example, rather than:

julia> DOI("10.5281/zenodo.6498231")

giving:

Van Der Plas, Fons; Dral, Michiel; Berg, Paul; Bochenski, Nicholas; Huijzer, Rik; Mengali, Alberto; Lungwitz, Benjamin; Burns, Connor; Ling, Jerry; Zhang, Eric; Schneider, Felipe S. S.; Weaver, Ian; Kadowaki, Shuhei; Gerritsen, Jelmar; Novosel, Rok; Moon, Zachary; Abbott, Michael; Bauer, Nicholas; Bouffard, Patrick; Terasaki, Satoshi Fonsp/Pluto.Jl: V0.19.3, Zenodo (2022) 10/gp2nvg, cited by 0

We can call something like

DOI("10.5281/zenodo.6498231",showauthors=1, citations=false)

to yield:

Van Der Plas, Fons; et al. Fonsp/Pluto.Jl: V0.19.3, Zenodo (2022) 10/gp2nvg

I can create a pull request for how I would do it I'm just not sure what the preferred approach would be given the formatting is handled in Base.show, or at least how I see it. Would be cool to specify different citation styles as well but that's probably good amount of effort.

ghost avatar Apr 29 '22 23:04 ghost

Sorry, I completely forgot about this. I kind of wanted a minimal type for the DOIs, but I already added a separate type for formatting (EmDOI), so a better approach would be nice before adding more formatting options. Perhaps consider adding a global formatting option or formatting function, perhaps.

hellemo avatar Jan 07 '23 08:01 hellemo