summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Citeproc.hs
AgeCommit message (Collapse)Author
2023-11-02Citeproc: don't link citations if `suppress-bibliography` specified.John MacFarlane
For there will be nothing to link to. Closes #9163.
2023-09-07Fix default citeproc entry-spacing.John MacFarlane
According to the CSL manual, the default entry spacing is 1. We were treating it as 0. T.P.Citeproc: always include an entry-spacing attribute in the Div if the bibliography element contains an entry-spacing attribute (previously we omitted it when it was 0). LaTeX writer: use entry spacing 1 if no entry-spacing attribute is present. Update tests. See #9058.
2023-06-27Use toTextM instead of toText when possible.John MacFarlane
(That is, whenever we have the filename and are in a PandocMonad instance.) This will lead to more informative error messages for UTF8 encoding, indicating the file path and byte offset where the error occurs. Closes #8884.
2022-10-19Text.Pandoc.Shared: remove `ordNub` [API change].John MacFarlane
This is just `nubOrd` from Data.Containers.ListUtils.
2022-10-03Separate out T.P.Data, T.P.Translations from T.P.Class. (#8348)John MacFarlane
This makes T.P.Class more self-contained, and suitable for extraction into a separate package if desired. [API changes] - T.P.Data is now an exported module, providing `readDataFile`, `readDefaultDataFile` (both formerly provided by T.P.Class), and also `getDataFileNames` (formerly unexported in T.P.App.CommandLineOptions). - T.P.Translations is now an exported module (along with T.P.Translations.Types), providing `readTranslations`, `getTranslations`, `setTranslations`, `translateTerm`, `lookupTerm`, `readTranslations`, `Term(..)`, and `Translations`. - T.P.Class: `readDataFile`, `readDefaultDataFile`, `setTranslations`, and `translateTerm` are no longer exported. `checkUserDataDir` is now exported. - Text.Pandoc now exports Text.Pandoc.Data and `setTranslations` and `translateTerm`.
2022-08-31Citeproc: check both extension and mime type to determine...John MacFarlane
...bibliography type when the bibliography is fetched remotely. This will help with cases where the URL ends in a parameter or otherwise does not end with a file extension. Closes #7151.
2022-03-16Allow formatted bibliography to be placed in metadata fields.John MacFarlane
This modifies `processCitations` so that pandoc will look not just in the document body but in metadata for a Div with id `refs` in which to place the formatted bibliography. Thus, one can include a metadata field, say `refs`, whose content is an empty div with id `refs`, and the formatted bibliography will be put into this metadata field. It may then be interpolated into a template using the variable `refs`. Closes #7969. Closes #526 by providing a way to interpolate references into a template.
2022-02-05Allow use of a RIS bibliography with citeproc.John MacFarlane
2022-02-03Use unreleased citeproc.John MacFarlane
2022-01-12Citeproc: allow `notes-after-punctuation` to work...John MacFarlane
with numerical styles that use superscripts (e.g. american-medical-association.csl), as well as with note styles. The default setting of `notes-after-punctuation` is true for note styles and false otherwise. This restores a behavior of pandoc-citeproc that wasn't properly carried over to Citeproc. Closes #7826. See also jgm/pandoc-citeproc#384.
2021-12-19JATS writer: keep quotes in element-citationsAlbert Krewinkel
The JATS writer was losing quotes in element-citations, as it uses the `T.P.Citeproc.getReferences` function to get references. That function replaces `Quoted` elements with spans. That transformation is required in `T.P.Citeproc.processCitations`, so it has been moved there.
2021-12-18Citeproc: avoid adding comma before an author-in-text citation...John MacFarlane
...in a note if it begins with a title (no author). Closes #7761.
2021-12-15T.P.Citeproc: do not export getStyle, getCiteprocLang.John MacFarlane
This commit undoes the API changes noted in ea77f2e6f653d5b570109fa208dc427d99f95b51 They are no longer needed, and we should avoid unnecessary API changes.
2021-12-13Citeproc changes:John MacFarlane
T.P.Citeproc exports `getCiteprocLang` and `getStyle` [API change]. T.P.Citeproc.Locator now exports `toLocatorMap`, `LocatorInfo`, and `LocatorMap`. The type of `parseLocator` has changed, so it now takes a `LocatorMap` rather than a `Locale` as parameter, and returns a `LocatorInfo` instead of a tuple.
2021-11-22Add .yml to Citeproc formatFromExtension (#7706)Jörn Krenzer
Make Citeproc recognize files with .yml extension (in addition to .yaml) as YAML bibliographies. Closes #7707.
2021-10-27Switch back from HsYAML to yaml.John MacFarlane
Reasons: - Performance: HsYAML is around 20 times slower in parsing large YAML bibliographies (#6084). - An issue was submitted to HsYAML, but it hasn't gotten any attention. HsYAML seems borderline unmaintained; it hasn't had a commit in over a year. - Unfortunately this goes back on our attempts to free ourselves from C dependencies (#4535). But I don't see a better alternative until a better pure Haskell parser is available. Closes #6084. Notes: - We've removed the FromYAML instances for all types that had them, since this is a HsYAML-specific typeclass [API change]. (The yaml package just uses From/ToJSON.) - Unlike HsYAML (in the configuration we were using), yaml parses 'Y', 'N', 'Yes', 'No', 'On', 'Off' as boolean values. Users may need to quote these when they are meant to be interpreted as strings. Similarly, 'null' is parsed as a YAML null value (and will be treated as an empty string by pandoc rather than the string 'null'). Quoting it will force it to be interpreted as a string. - Some tests had to be adjusted accordingly. - Pandoc now behaves better when the YAML metadata contains escaping errors: instead of just falling back on treating the section as a table, it raises a YAML parsing error.
2021-08-17Revise citeproc code to fit new citeproc 0.5 API.John MacFarlane
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.
2021-08-13Convert Quoted in bib entries to special Spans...John MacFarlane
before passing them off to citeproc. This ensures that we get proper localization and flipflopping if, e.g., quotes are used in titles. Closes jgm/citeproc#87.
2021-08-13Citeproc: avoid odd handling of quotes.John MacFarlane
citeproc changes allow us to ignore Quoted elements; citeproc now uses its own method for represented quoted things, and only localizes and flipflops quotes it adds itself. See #87. The one thing left to do is to convert Quoted elements in bibliography databases (esp. titles) to `Span ("",["csl-quoted"],[])` before passing them to citeproc, IF the localized quotes for the quote type match the standard inverted commas.
2021-08-13Removed quote localization from citeproc processing.John MacFarlane
This is now done in citeproc itself.
2021-07-05Add command test for #7394.John MacFarlane
And fix a small bug in handling of citations in notes, which led to commas at the end of sentences in some cases.
2021-07-05Citeproc: cleanup and efficiency improvement in deNote.John MacFarlane
2021-07-05Revamp note citation handling.John MacFarlane
Use latest citeproc, which uses a Span with a class rather than a Note for notes. This helps us distinguish between user notes and citation notes. Don't put citations at the beginning of a note in parentheses. (Closes #7394.)
2021-06-28Improve punctuation moving with `--citeproc`.John MacFarlane
Previously, using `--citeproc` could cause punctuation to move in quotes even when there aer no citations. This has been changed; now, punctuation moving is limited to citations. In addition, we only move footnotes around punctuation if the style is a note style, even if `notes-after-punctuation` is `true`.
2021-06-12Fix regression in citeproc processing.John MacFarlane
If inline references are used (in the metadata `references` field), we should still only include in the bibliography items that are actually cited -- unless `nocite` is used. Closes #7376.
2021-06-08Citeproc: avoid duplicate classes and attributes on refs div.John MacFarlane
2021-05-17Citeproc: ensure that CSL-related attributes are passed on...John MacFarlane
...to a Div with id 'refs'. Previously we just left the attributes of such a Div alone, which meant that style options like entry-spacing had no effect there.
2021-04-17Use document's lang for the lang parameter of citeproc...John MacFarlane
even if it differs from localeLanguage. (It is designed to be possible to override the locale language, and this is especially useful when one wants to use the unicode extension syntx, e.g. fr-u-kb.)
2021-04-17Remove Text.Pandoc.BCP47 module.John MacFarlane
[API change] Use Lang from UnicodeCollation.Lang instead. This is a richer implementation of BCP 47.
2021-03-12Citeproc: apply fixLinks correctly.John MacFarlane
This is code that incorporates a prefix like `https://doi.org/` into a following link when appropriate. But it didn't work because we were walking with a `[Inline] -> [Inline]` function on an `Inlines`. Changed the point of application of `fixLink` to resolve the issue. Closes #7130.
2021-02-26Fix/update URLs and use HTTP**S** where possible (#7122)Salim B
2021-01-21Text.Pandoc.Citeproc: use finer grained importsAlbert Krewinkel
This allows to import the module in writers without causing a circular dependency.
2021-01-10T.P.Citeproc: factor out and export `getStyle`.John MacFarlane
2021-01-10T.P.Citeproc: factor out getLang.John MacFarlane
2021-01-10T.P.Citeproc: refactor and export `getReferences`.John MacFarlane
See #7016.
2020-12-24Citeproc: fix handling of empty URL variables (`DOI`, etc.).John MacFarlane
The `linkifyVariables` function was changing these to links which then got treated as non-empty by citeproc, leading to wrong results (e.g. ignoring nonempty URL when empty DOI is present). Addresses part 2 of jgm/citeproc#41.
2020-12-16Fix citeproc regression with duplicate references.John MacFarlane
- Use dev version of citeproc, which handles duplicate ids better, preferring the last one in the list and discarding the rest. - Ensure that inline citations take priority over external ones. See jgm/citeproc#36. This restores the behavior of pandoc-citeproc.
2020-12-15Use fetchItem to get external bibliography.John MacFarlane
This means that: - a URL may be provided, and pandoc will fetch the resource. - Pandoc will search the resource path for the bibliography if it is not found relative to the working directory. Closes #6940.
2020-12-15Allow both inline and external references to be usedJohn MacFarlane
with `--citeproc`. This fixes a regression, since pandoc-citeproc allowed these to be combined. Closes #6951.
2020-12-02Citeproc: ensure that BCP47 lang codes can be used.John MacFarlane
We ignore the variants and just use the base lang code and country code when passing off to citeproc.
2020-11-25Fix truncation of `[Citation]` list in `Cite` inside footnotes...John MacFarlane
This affected author-in-text citations in footnotes. It didn't cause problems for the printed output, but for filters that expected the citation id and other information. Closes #6890.
2020-11-13Improve period suppression algorithm for citations in notes...John MacFarlane
in note citation styles. See #6835.
2020-11-07Lint code in PRs and when committing to master (#6790)Albert Krewinkel
* Remove unused LANGUAGE pragmata * Apply HLint suggestions * Configure HLint to ignore some warnings * Lint code when committing to master
2020-11-05Citeproc: improve punctuation in in-text note citations.John MacFarlane
Previously in-text note citations inside a footnote would sometimes have the final period stripped, even if it was needed (e.g. on the end of 'ibid'). See #6813.
2020-11-04Simplified idpred in citeproc.John MacFarlane
2020-11-01Citeproc: use comma for in-text citations inside footnotes.John MacFarlane
When an author-in-text citation like `@foo` occurs in a footnote, we now render it with: `AUTHOR NAME + COMMA + SPACE + REST`. Previously we rendered: `AUTHOR NAME + SPACE + "(" + REST + ")"`. This gives better results. Note that normal citations are still rendered in parentheses.
2020-11-01Improve deNote.John MacFarlane
2020-10-29Use new citeproc; do note capitalization here, not in citeproc.John MacFarlane
2020-10-27Remove obsolete commentJohn MacFarlane
2020-10-27Citeproc: properly handle `csl` field with `data:` URI.John MacFarlane
This is used with the JATS writer, so this fixes a regression in pandoc 2.11 with JATS output and citeproc. Closes #6783.