From bfd5c6b172b7b4cc471b1ed80673bac545604f62 Mon Sep 17 00:00:00 2001 From: Herwig Stuetz Date: Tue, 23 May 2017 21:30:31 +0200 Subject: Org reader: Fix cite parsing behaviour Until now, org-ref cite keys included special characters also at the end. This caused problems when citations occur right before colons or at the end of a sentence. With this change, all non alphanumeric characters at the end of a cite key are ignored. This also adds `,` to the list of special characters that are legal in cite keys to better mirror the behaviour of org-export. --- test/Tests/Readers/Org.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs index 37ad2462b..3302e0c3e 100644 --- a/test/Tests/Readers/Org.hs +++ b/test/Tests/Readers/Org.hs @@ -334,6 +334,18 @@ tests = } in (para $ cite [citation] "cite:pandoc") + , "Org-ref simple citation with underscores" =: + "cite:pandoc_org_ref" =?> + let citation = Citation + { citationId = "pandoc_org_ref" + , citationPrefix = mempty + , citationSuffix = mempty + , citationMode = AuthorInText + , citationNoteNum = 0 + , citationHash = 0 + } + in (para $ cite [citation] "cite:pandoc_org_ref") + , "Org-ref simple citation succeeded by comma" =: "cite:pandoc," =?> let citation = Citation @@ -346,6 +358,30 @@ tests = } in (para $ cite [citation] "cite:pandoc" <> str ",") + , "Org-ref simple citation succeeded by dot" =: + "cite:pandoc." =?> + let citation = Citation + { citationId = "pandoc" + , citationPrefix = mempty + , citationSuffix = mempty + , citationMode = AuthorInText + , citationNoteNum = 0 + , citationHash = 0 + } + in (para $ cite [citation] "cite:pandoc" <> str ".") + + , "Org-ref simple citation succeeded by colon" =: + "cite:pandoc:" =?> + let citation = Citation + { citationId = "pandoc" + , citationPrefix = mempty + , citationSuffix = mempty + , citationMode = AuthorInText + , citationNoteNum = 0 + , citationHash = 0 + } + in (para $ cite [citation] "cite:pandoc" <> str ":") + , "Org-ref simple citep citation" =: "citep:pandoc" =?> let citation = Citation -- cgit v1.2.3