Skip to content

Commit

Permalink
Bump DocumenterCitations to 1.3 (#3003)
Browse files Browse the repository at this point in the history
* Bump DocumenterCitations to 1.3

* Escape `&`

* Use `\url` again

* Fix corporate authors
  • Loading branch information
lgoettgens authored Nov 23, 2023
1 parent a9db139 commit a179656
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
3 changes: 0 additions & 3 deletions .bibtoolrsc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,3 @@ check.error.rule { doi "\://" "\@ \$: doi field should not be a URL" }

# Check that the url field is not a DOI
check.error.rule { url "doi\.org/" "\@ \$: url field should not contain a doi. Use the doi field instead" }

# Check that no field contains a LaTeX url command, as DocumenterCitations.jl prints them ugly
check.error.rule { "\\url" "\@ \$: LaTeX's `\\url` commands are not supported" }
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"

[compat]
Documenter = "1.1"
DocumenterCitations = "~1.2"
DocumenterCitations = "~1.3.1"
54 changes: 10 additions & 44 deletions docs/citation_style.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,32 @@

import DocumenterCitations

# we use some (undocumented) internal helper functions for formatting...
using DocumenterCitations: format_names, tex2unicode

const oscar_style = :oscar

# The long reference string in the bibliography
function DocumenterCitations.format_bibliography_reference(::Val{oscar_style}, entry)
if entry.id in ["OEIS", "Stacks"]
# patch DocumenterCitations.format_bibliography_reference(:numeric, entry) for corporate authors (https://github.com/JuliaDocs/DocumenterCitations.jl/issues/44)
authors = tex2unicode(format_names(entry; names=:full))
title = DocumenterCitations.xtitle(entry)
if !isempty(title)
title = "<i>" * tex2unicode(title) * "</i>"
end
linked_title = DocumenterCitations.linkify(title, entry.access.url)
published_in = DocumenterCitations.linkify(
tex2unicode(DocumenterCitations.format_published_in(entry)),
DocumenterCitations._doi_link(entry),
)
eprint = DocumenterCitations.format_eprint(entry)
note = DocumenterCitations.format_note(entry)
parts = String[]
for part in (authors, linked_title, published_in, eprint, note)
if !isempty(part)
push!(parts, part)
end
end
html = DocumenterCitations._join_bib_parts(parts)
return html
end
return DocumenterCitations.format_bibliography_reference(:numeric, entry)
function DocumenterCitations.format_bibliography_reference(style::Val{oscar_style}, entry)
return DocumenterCitations.format_labeled_bibliography_reference(style, entry)
end

# The label in the bibliography
function DocumenterCitations.format_bibliography_label(::Val{oscar_style}, entry, citations)
return "[$(entry.id)]"
end

function DocumenterCitations.citation_label(style::Val{oscar_style}, entry, citations; _...)
return entry.id
end

# The order of entries in the bibliography
DocumenterCitations.bib_sorting(::Val{oscar_style}) = :key # sort by citation key

# The type of html tag to use for the bibliography
DocumenterCitations.bib_html_list_style(::Val{oscar_style}) = :dl

function DocumenterCitations.format_citation(
::Val{oscar_style}, entry, citations; note, cite_cmd, capitalize, starred
style::Val{oscar_style}, cit, entries, citations
)
link_text = isnothing(note) ? "[$(entry.id)]" : "[$(entry.id), $note]"
if cite_cmd == :citet
et_al = starred ? 0 : 1 # 0: no "et al."; 1: "et al." after 1st author
if entry.id in ["OEIS", "Stacks"]
# patch for corporate authors (https://github.com/JuliaDocs/DocumenterCitations.jl/issues/44)
names = tex2unicode(format_names(entry; names=:full))
else
names = tex2unicode(
format_names(entry; names=:lastonly, and=true, et_al, et_al_text="*et al.*")
)
end
capitalize && (names = uppercasefirst(names))
link_text = "$names $link_text"
end
return link_text
# The only difference compared to `:alpha` is the citation label, which is
# picked up automatically by redefining `citation_label` above.
return DocumenterCitations.format_labeled_citation(style, cit, entries, citations)
end
18 changes: 9 additions & 9 deletions docs/oscar_references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ @Article{AZ99
@Article{BBS02,
author = {Bayer, M. and Bruening, A. and Stewart, J.},
title = {A Combinatorial Study of Multiplexes and Ordinary Polytopes},
journal = {Discrete & Computational Geometry},
journal = {Discrete \& Computational Geometry},
volume = {27},
pages = {49--63},
year = {2002},
Expand Down Expand Up @@ -703,7 +703,7 @@ @Article{FGLM93
@Article{FJR17,
author = {Fan, Huijun and Jarvis, Tyler and Ruan, Yongbin},
title = {A mathematical theory of the gauged linear sigma model},
journal = {Geometry & Topology},
journal = {Geometry \& Topology},
volume = {22},
number = {1},
publisher = {Mathematical Sciences Publishers},
Expand All @@ -719,7 +719,7 @@ @InProceedings{FLINT
title = {Fast Library for Number Theory: An Introduction},
booktitle = {Proceedings of the Third International Congress on Mathematical Software},
series = {ICMS'10},
note = {https://flintlib.org},
note = {\url{https://flintlib.org}},
address = {Berlin, Heidelberg},
publisher = {Springer-Verlag},
pages = {88--91},
Expand Down Expand Up @@ -934,7 +934,7 @@ @Book{HEO05
author = {Holt, Derek F. and Eick, Bettina and O'Brien, Eamonn A.},
title = {Handbook of computational group theory},
series = {Discrete Mathematics and its Applications (Boca Raton)},
publisher = {Chapman & Hall/CRC, Boca Raton, FL},
publisher = {Chapman \& Hall/CRC, Boca Raton, FL},
pages = {xvi+514},
year = {2005},
doi = {10.1201/9781420035216}
Expand Down Expand Up @@ -1064,7 +1064,7 @@ @Book{JT13
@Article{JZ00,
author = {Joswig, Michael and Ziegler, Günter M.},
title = {Neighborly Cubical Polytopes},
journal = {Discrete & Computational Geometry },
journal = {Discrete \& Computational Geometry },
volume = {24},
pages = {325--344},
year = {2000},
Expand Down Expand Up @@ -1414,9 +1414,9 @@ @Article{Nik79

@Misc{OEIS,
bibkey = {OEIS},
author = {OEIS Foundation Inc.},
author = {{OEIS Foundation Inc.}},
title = {The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},
howpublished = {Published electronically at https://oeis.org},
howpublished = {Published electronically at \url{https://oeis.org}},
year = {2023},
url = {https://oeis.org}
}
Expand Down Expand Up @@ -1690,7 +1690,7 @@ @Article{Sta79

@Misc{Stacks,
bibkey = {Stacks},
author = {The Stacks Project Authors},
author = {{The Stacks Project Authors}},
title = {{S}tacks {P}roject},
howpublished = {Published electronically},
url = {https://stacks.math.columbia.edu/}
Expand Down Expand Up @@ -1746,7 +1746,7 @@ @Book{Was08
title = {Elliptic curves},
series = {Discrete Mathematics and its Applications (Boca Raton)},
note = {Number theory and cryptography},
publisher = {Chapman & Hall/CRC, Boca Raton, FL},
publisher = {Chapman \& Hall/CRC, Boca Raton, FL},
edition = {Second},
pages = {xviii+513},
year = {2008},
Expand Down

0 comments on commit a179656

Please sign in to comment.