Revise citeproc code to fit new citeproc 0.5 API.

Linkification of URLs in the bibliography is now done in
the citeproc library, depending on the setting of an option.
We set that option depending on the value of the metadata
field `link-bibliography` (defaulting to true, for consistency
with earlier behavior, though the new behavior includes the
CSL draft recommendation of hyperlinking the title or the whole
entry if a DOI, PMID, PMCID, or URL field is present but not
explicitly rendered).

These changes implement the following recommendations from the
draft CSL v1.0.2 spec (Appendix VI):

> The CSL syntax does not have support for configuration of links.
> However, processors should include links on bibliographic references,
> using the following rules:

> If the bibliography entry for an item renders any of the following
> identifiers, the identifier should be anchored as a link, with the
> target of the link as follows:

> - url: output as is
> - doi: prepend with "`https://doi.org/`"
> - pmid: prepend with "`https://www.ncbi.nlm.nih.gov/pubmed/`"
> - pmcid: prepend with "`https://www.ncbi.nlm.nih.gov/pmc/articles/`"

> If the identifier is rendered as a URI, include rendered URI components
> (e.g. "`https://doi.org/`") in the link anchor. Do not include any other
> affix text in the link anchor (e.g. "Available from: ", "doi: ", "PMID: ").
> If the bibliography entry for an item does not render any of
> the above identifiers, then set the anchor of the link as the item
> title. If title is not rendered, then set the anchor of the link as the
> full bibliography entry for the item. Set the target of the link as one
> of the following, in order of priority:
>
> - doi: prepend with "`https://doi.org/`"
> - pmcid: prepend with "`https://www.ncbi.nlm.nih.gov/pmc/articles/`"
> - pmid: prepend with "`https://www.ncbi.nlm.nih.gov/pubmed/`"
> - url: output as is
>
> If the item data does not include any of the above identifiers, do not
> include a link.
>
> Citation processors should include an option flag for calling
> applications to disable bibliography linking behavior.

Thanks to Benjamin Bray for getting this all working.
This commit is contained in:
John MacFarlane
2021-08-17 15:34:23 -07:00
parent 10dfd81000
commit fd99fe4d7e
7 changed files with 21 additions and 51 deletions
+3 -2
View File
@@ -29,8 +29,9 @@ Foo.[^1] Bar.[^2] Baz.[^3]
::: {#refs .references .csl-bib-body}
::: {#ref-item1 .csl-entry}
Olson HA, 'Codes, Costs, and Critiques: The Organization of Information
in *Library Quarterly*, 1931--2004' (2006) 76 *Library Quarterly* 19
Olson HA, '[Codes, Costs, and Critiques: The Organization of Information
in *Library Quarterly*, 1931--2004](https://doi.org/10.1086/504343)'
(2006) 76 *Library Quarterly* 19
:::
::: {#ref-item2 .csl-entry}
+2 -2
View File
@@ -44,8 +44,8 @@ I referenced something here^\[1\]^
::: {#refs .references .csl-bib-body}
::: {#ref-LiLiaoDongWanHaiYuDiQiDongWuCiJiShengChanLiYanJiuJiShengJingGuaYiXingPingJie2017 .csl-entry}
[\[1\] ]{.csl-left-margin}[李轶平, 于旭光, 孙明, 等.
辽东湾海域底栖动物次级生产力研究及生境适宜性评价\[J\]. 水产科学,
2017(06): 728--734.]{.csl-right-inline}
[辽东湾海域底栖动物次级生产力研究及生境适宜性评价](http://kns.cnki.net/kns/detail/detail.aspx?QueryID=4&CurRec=4&recid=&FileName=CHAN201706006&DbName=CJFDLAST2018&DbCode=CJFQ&yx=Y&pr=&URLID=21.1110.S.20171129.1725.006)\[J\].
水产科学, 2017(06): 728--734.]{.csl-right-inline}
:::
:::
```
+1 -2
View File
@@ -28,8 +28,7 @@ references:
::: {#ref-item-1 .csl-entry}
[Wolfinger, Christine]{.smallcaps}: *Keine Angst vor Linux, Unix: ein
Lehrbuch für Linux- und Unix-Anwender*. 11., vollst. überarb. Aufl.
Aufl. Berlin \[u.a.\] : Springer Vieweg, 2013
--- ISBN [978-3-642-32078-1](https://worldcat.org/isbn/978-3-642-32078-1)
Aufl. Berlin \[u.a.\] : Springer Vieweg, 2013 --- ISBN 978-3-642-32078-1
:::
:::
```
+2 -2
View File
@@ -28,8 +28,8 @@ references:
::: {#refs .references .csl-bib-body line-spacing="2"}
::: {#ref-ding_metallic_2012 .csl-entry}
[\[1\] ]{.csl-left-margin}[K. Ding, C. Z. Ning, *Light Sci. Appl.*
**2012**, *1*, e20.]{.csl-right-inline}
[[\[1\]K. Ding, C. Z. Ning, *Light Sci. Appl.* **2012**, *1*,
e20](https://doi.org/10.1038/lsa.2012.20)]{.csl-left-margin}.
:::
:::
```