-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40b7470
commit 5953e77
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# This file is included by docs/make_work.jl to define the custom citation style `oscar_style`. | ||
# | ||
# It is heavily based upon | ||
# https://juliadocs.org/DocumenterCitations.jl/v1.0.0/gallery/#Custom-style:-Citation-key-labels | ||
# | ||
|
||
import DocumenterCitations | ||
|
||
# we use some (undocumented) internal helper functions for formatting... | ||
using DocumenterCitations: format_names, tex2unicode, italicize_md_et_al | ||
|
||
const oscar_style = :oscar | ||
|
||
# The long reference string in the bibliography | ||
function DocumenterCitations.format_bibliography_reference(::Val{oscar_style}, entry) | ||
return DocumenterCitations.format_bibliography_reference(:numeric, entry) | ||
end | ||
|
||
# The label in the bibliography | ||
function DocumenterCitations.format_bibliography_label(::Val{oscar_style}, entry, citations) | ||
return "[$(entry.id)]" | ||
end | ||
|
||
# The order of entries in the bibliography | ||
DocumenterCitations.bib_sorting(::Val{oscar_style}) = :nyt # name, year, title | ||
|
||
# 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 | ||
) | ||
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 | ||
names = tex2unicode( | ||
format_names(entry; names=:lastonly, and=true, et_al, et_al_text="*et al.*") | ||
) | ||
capitalize && (names = uppercasefirst(names)) | ||
link_text = italicize_md_et_al("$names $link_text") | ||
end | ||
return link_text | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters