hellemo / ShortCodes.jl

Short codes to embed content in Pluto notebooks
MIT License
51 stars 4 forks source link

Add formatting option for DOI #8

Open ghost opened 2 years ago

ghost commented 2 years ago

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.

hellemo commented 1 year ago

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.

eford commented 1 month ago

+1 to this feature request.