From 394fa9d0727a30f540d9c36ccfa68fc942cad587 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 14 Dec 2021 10:40:24 -0800 Subject: Org reader: parse official org-cite citations. We also support the older org-ref style as a fallback. We no longer support the "markdown-style" citations. See #7329. --- test/Tests/Readers/Org/Inline/Citation.hs | 40 +++++++++++++++++++++++++++---- test/command/7329.md | 23 ++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/Tests/Readers/Org/Inline/Citation.hs b/test/Tests/Readers/Org/Inline/Citation.hs index 7eabd9aae..2d0d460a2 100644 --- a/test/Tests/Readers/Org/Inline/Citation.hs +++ b/test/Tests/Readers/Org/Inline/Citation.hs @@ -19,9 +19,9 @@ import Text.Pandoc.Builder tests :: [TestTree] tests = - [ testGroup "Markdown-style citations" + [ testGroup "Org-cite citations" [ "Citation" =: - "[@nonexistent]" =?> + "[cite:@nonexistent]" =?> let citation = Citation { citationId = "nonexistent" , citationPrefix = [] @@ -29,10 +29,10 @@ tests = , citationMode = NormalCitation , citationNoteNum = 0 , citationHash = 0} - in (para $ cite [citation] "[@nonexistent]") + in (para $ cite [citation] "[cite:@nonexistent]") , "Citation containing text" =: - "[see @item1 p. 34-35]" =?> + "[cite:see @item1 p. 34-35]" =?> let citation = Citation { citationId = "item1" , citationPrefix = [Str "see"] @@ -40,7 +40,37 @@ tests = , citationMode = NormalCitation , citationNoteNum = 0 , citationHash = 0} - in (para $ cite [citation] "[see @item1 p. 34-35]") + in (para $ cite [citation] "[cite:see @item1 p. 34-35]") + + , "Author-in-text citation with locator and suffix" =: + "[cite/t:see @item1 p. 34-35 and *passim*; @item2]" =?> + let citations = + [ Citation + { citationId = "item1" + , citationPrefix = [ Str "see" ] + , citationSuffix = + [ Str "p." + , Space + , Str "34-35" + , Space + , Str "and" + , Space + , Strong [ Str "passim" ] + ] + , citationMode = AuthorInText + , citationNoteNum = 0 + , citationHash = 0 + } + , Citation + { citationId = "item2" + , citationPrefix = [] + , citationSuffix = [] + , citationMode = NormalCitation + , citationNoteNum = 0 + , citationHash = 0 + } + ] + in (para $ cite citations "[cite/t:see @item1 p. 34-35 and *passim*; @item2]") ] , testGroup "org-ref citations" diff --git a/test/command/7329.md b/test/command/7329.md index 565241db8..9ed9c52ff 100644 --- a/test/command/7329.md +++ b/test/command/7329.md @@ -42,3 +42,26 @@ <> Doe, John. 2005. /First Book/. Cambridge: Cambridge University Press. ``` + +``` +% pandoc -f org -t markdown +- [cite/t:@item1] +- [cite/t:@item1 p. 12] +- [cite/t:@item1 p.12; see also @item2] +- [cite:@item1] +- [cite/na:@item1] +- [cite:see @item1 p. 12] +- [cite:see @item1 p. 12 and /passim/] +- [cite:@item1; @item2] +- [cite:see @item1; @item2] +^D +- @item1 +- @item1 [p. 12] +- @item1 [p.12; see also @item2] +- [@item1] +- [-@item1] +- [see @item1 p. 12] +- [see @item1 p. 12 and *passim*] +- [@item1; @item2] +- [see @item1; @item2] +``` -- cgit v1.2.3