summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnMacFarlane <>2019-03-13 06:27:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-03-13 06:27:00 (GMT)
commitc53df0fb671bee5e8ba81cab9489a23b9743d92d (patch)
treed43950317423832d1f143d9a43fd663d81cf530e
parent9e9ddf2ff1a6f99449f3c6ff3b9d5c2e257d3c7c (diff)
version 0.16.1.3HEAD0.16.1.3master
-rw-r--r--changelog8
-rw-r--r--man/man1/pandoc-citeproc.12
-rw-r--r--pandoc-citeproc.cabal2
-rw-r--r--src/Text/CSL/Input/Bibtex.hs6
-rw-r--r--src/Text/CSL/Pandoc.hs20
-rw-r--r--src/Text/CSL/Style.hs6
-rw-r--r--src/Text/CSL/Util.hs30
-rw-r--r--tests/issue392.expected.native7
-rw-r--r--tests/issue392.in.native2
-rw-r--r--tests/issue61.expected.native10
-rw-r--r--tests/locators-delimited.expected.native10
-rw-r--r--tests/vancouver.csl351
12 files changed, 426 insertions, 28 deletions
diff --git a/changelog b/changelog
index 309193e..ba1cc0e 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
+pandoc-citeproc (0.16.1.3)
+
+ * Correctly handle initials even when
+ presented without a space, as in "J.G. Smith" (#392).
+ * Avoid generating Str "" when possible.
+ * Allow superscript in-text styles to be treated as "notes"
+ for purposes of moving punctuation (George Pollard, #382).
+
pandoc-citeproc (0.16.1.2)
* Fix extraction page-first when page is not fully numeric (#386).
diff --git a/man/man1/pandoc-citeproc.1 b/man/man1/pandoc-citeproc.1
index 78e2ac0..8497667 100644
--- a/man/man1/pandoc-citeproc.1
+++ b/man/man1/pandoc-citeproc.1
@@ -1,7 +1,7 @@
.\"t
.\" Automatically generated by Pandoc 2.7
.\"
-.TH "pandoc-citeproc" "1" "2019-03-07" "pandoc-citeproc 0.16.1.2" ""
+.TH "pandoc-citeproc" "1" "2019-03-12" "pandoc-citeproc 0.16.1.3" ""
.hy
.SH NAME
.PP
diff --git a/pandoc-citeproc.cabal b/pandoc-citeproc.cabal
index 8b7554f..301a077 100644
--- a/pandoc-citeproc.cabal
+++ b/pandoc-citeproc.cabal
@@ -1,5 +1,5 @@
name: pandoc-citeproc
-version: 0.16.1.2
+version: 0.16.1.3
cabal-version: 1.12
synopsis: Supports using pandoc with citeproc
diff --git a/src/Text/CSL/Input/Bibtex.hs b/src/Text/CSL/Input/Bibtex.hs
index b9e7a1b..343d0b8 100644
--- a/src/Text/CSL/Input/Bibtex.hs
+++ b/src/Text/CSL/Input/Bibtex.hs
@@ -41,7 +41,8 @@ import Text.CSL.Reference
import Text.CSL.Style (Agent (..), emptyAgent, CslTerm (..),
Formatted (..), Locale (..))
import Text.CSL.Util (onBlocks, protectCase, safeRead,
- splitStrWhen, trim, unTitlecase)
+ splitStrWhen, trim, unTitlecase,
+ addSpaceAfterPeriod)
import Text.Pandoc.Definition
import qualified Text.Pandoc.UTF8 as UTF8
import qualified Text.Pandoc.Walk as Walk
@@ -1009,7 +1010,8 @@ toLiteralList _ = mzero
toAuthorList :: Options -> [Block] -> Bib [Agent]
toAuthorList opts [Para xs] =
- filter (/= emptyAgent) <$> mapM (toAuthor opts) (splitByAnd xs)
+ filter (/= emptyAgent) <$> mapM (toAuthor opts . addSpaceAfterPeriod)
+ (splitByAnd xs)
toAuthorList opts [Plain xs] = toAuthorList opts [Para xs]
toAuthorList _ _ = mzero
diff --git a/src/Text/CSL/Pandoc.hs b/src/Text/CSL/Pandoc.hs
index ca204ba..8133b53 100644
--- a/src/Text/CSL/Pandoc.hs
+++ b/src/Text/CSL/Pandoc.hs
@@ -297,6 +297,10 @@ getNoteCitationIds _ = []
isNote :: Inline -> Bool
isNote (Note _) = True
isNote (Cite _ [Note _]) = True
+ -- the following allows citation styles that are "in-text" but use superscript
+ -- references to be treated as if they are "notes" for the purposes of moving
+ -- the citations after trailing punctuation (see <https://github.com/jgm/pandoc-citeproc/issues/382>):
+isNote (Cite _ [Superscript _]) = True
isNote _ = False
mvPunctInsideQuote :: Inline -> Inline -> [Inline]
@@ -318,16 +322,22 @@ mvPunct moveNotes sty (q : s : x : ys)
, startWithPunct ys
= if moveNotes
then mvPunct moveNotes sty $
- q : Str (headInline ys) : x : tailInline ys
+ case headInline ys of
+ "" -> q : x : tailInline ys
+ w -> q : Str w : x : tailInline ys
else q : x : mvPunct moveNotes sty ys
mvPunct moveNotes sty (Cite cs ils : ys)
| length ils > 1
, isNote (last ils)
, startWithPunct ys
, moveNotes
- = Cite cs (init ils
- ++ [Str (headInline ys) | not (endWithPunct False (init ils))]
- ++ [last ils]) : mvPunct moveNotes sty (tailInline ys)
+ = Cite cs
+ (init ils ++
+ (case headInline ys of
+ "" -> []
+ s' | not (endWithPunct False (init ils)) -> [Str s']
+ | otherwise -> [])
+ ++ [last ils]) : mvPunct moveNotes sty (tailInline ys)
mvPunct moveNotes sty (q@(Quoted _ _) : w@(Str _) : x : ys)
| isNote x
, isPunctuationInQuote sty
@@ -563,7 +573,7 @@ pLocatorWordIntegrated :: Bool -> Parsec [Inline] st (Bool, String)
pLocatorWordIntegrated isFirst = try $ do
punct <- if isFirst
then return ""
- else stringify <$> option (Str "") pLocatorSep
+ else (stringify <$> pLocatorSep) <|> return ""
sp <- option "" (pSpace >> return " ")
(dig, s) <- pBalancedBraces [('(',')'), ('[',']'), ('{','}')] pPageSeq
return (dig, punct ++ sp ++ s)
diff --git a/src/Text/CSL/Style.hs b/src/Text/CSL/Style.hs
index 95a6ce2..b7fec18 100644
--- a/src/Text/CSL/Style.hs
+++ b/src/Text/CSL/Style.hs
@@ -118,7 +118,7 @@ import Text.CSL.Util (orIfNull, headInline, initInline,
lastInline, mapping', mb, parseBool,
parseString, query, splitStrWhen,
tailInline, trimr, (.#:), (.#?),
- AddYaml(..))
+ AddYaml(..), addSpaceAfterPeriod)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Definition hiding (Citation, Cite)
import qualified Text.Pandoc.Walk as Walk
@@ -819,7 +819,9 @@ removeQuoted (Formatted ils) = Formatted (go ils)
instance FromJSON Agent where
parseJSON (Object v) = nameTransform <$> (Agent <$>
- (v .: "given" <|> ((map Formatted . wordsBy isSpace . unFormatted) <$> v .: "given") <|> pure []) <*>
+ (v .: "given" <|> ((map Formatted . wordsBy isSpace .
+ addSpaceAfterPeriod . unFormatted) <$>
+ v .: "given") <|> pure []) <*>
v .:? "dropping-particle" .!= mempty <*>
v .:? "non-dropping-particle" .!= mempty <*>
(removeQuoted <$> (v .:? "family" .!= mempty)) <*>
diff --git a/src/Text/CSL/Util.hs b/src/Text/CSL/Util.hs
index ea7ebb1..b8938d7 100644
--- a/src/Text/CSL/Util.hs
+++ b/src/Text/CSL/Util.hs
@@ -50,13 +50,14 @@ module Text.CSL.Util
, mapping'
, parseRomanNumeral
, isRange
+ , addSpaceAfterPeriod
) where
import Prelude
import Control.Monad.State
import Data.Aeson
import Data.Aeson.Types (Parser)
-import Data.Char (isAscii, isLower, isPunctuation, isUpper,
- toLower, toUpper)
+import Data.Char (isAscii, isLower, isPunctuation,
+ isUpper, isLetter, toLower, toUpper)
import Data.Generics (Data, Typeable, everything, everywhere,
everywhere', everywhereM, mkM, mkQ, mkT)
import Data.List.Split (wordsBy)
@@ -407,7 +408,8 @@ lastInline xs = case stringify xs of
initInline :: [Inline] -> [Inline]
initInline [] = []
initInline [i]
- | Str s <- i = return $ Str (init' s)
+ | Str s <- i
+ , not (null s) = return $ Str (init s)
| Emph is <- i = return $ Emph (initInline is)
| Strong is <- i = return $ Strong (initInline is)
| Superscript is <- i = return $ Superscript (initInline is)
@@ -421,10 +423,9 @@ initInline [i]
initInline (i:xs) = i : initInline xs
tailInline :: [Inline] -> [Inline]
-tailInline (Space:xs) = xs
+tailInline (Space:xs) = xs
tailInline (SoftBreak:xs) = xs
-tailInline xs = removeEmpty $ tailFirstInlineStr xs
- where removeEmpty = dropWhile (== Str "")
+tailInline xs = tailFirstInlineStr xs
tailFirstInlineStr :: [Inline] -> [Inline]
tailFirstInlineStr = mapHeadInline (drop 1)
@@ -437,7 +438,9 @@ mapHeadInline :: (String -> String) -> [Inline] -> [Inline]
mapHeadInline _ [] = []
mapHeadInline f (i:xs)
| Str [] <- i = mapHeadInline f xs
- | Str s <- i = Str (f s) : xs
+ | Str s <- i = case f s of
+ "" -> xs
+ _ -> Str (f s) : xs
| Emph is <- i = Emph (mapHeadInline f is) : xs
| Strong is <- i = Strong (mapHeadInline f is) : xs
| Superscript is <- i = Superscript (mapHeadInline f is) : xs
@@ -530,3 +533,16 @@ pRomanNumeral = do
isRange :: String -> Bool
isRange s = ',' `elem` s || '-' `elem` s || '\x2013' `elem` s
+
+-- see issue 392 for motivation. We want to treat
+-- "J.G. Smith" and "J. G. Smith" the same.
+addSpaceAfterPeriod :: [Inline] -> [Inline]
+addSpaceAfterPeriod = go . splitStrWhen (=='.')
+ where
+ go [] = []
+ go (Str [c]:Str ".":Str [d]:xs)
+ | isLetter d
+ , isLetter c
+ , isUpper c
+ , isUpper d = Str [c]:Str ".":Space:Str [d]:go xs
+ go (x:xs) = x:go xs
diff --git a/tests/issue392.expected.native b/tests/issue392.expected.native
new file mode 100644
index 0000000..c3b6279
--- /dev/null
+++ b/tests/issue392.expected.native
@@ -0,0 +1,7 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
+[Para [Cite [Citation {citationId = "james", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 1}] [Str "(1)"],Str ";",Space,Cite [Citation {citationId = "macfarlane", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 2}] [Str "(2)"]]
+,Div ("refs",["references"],[])
+ [Div ("ref-james",[],[])
+ [Para [Str "1.",Space,Str "James",Space,Str "MR.",Space]]
+ ,Div ("ref-macfarlane",[],[])
+ [Para [Str "2.",Space,Str "MacFarlane",Space,Str "JG.",Space]]]]
diff --git a/tests/issue392.in.native b/tests/issue392.in.native
new file mode 100644
index 0000000..d70fee4
--- /dev/null
+++ b/tests/issue392.in.native
@@ -0,0 +1,2 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
+[Para [Cite [Citation {citationId = "james", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@james"],Str ";",Space,Cite [Citation {citationId = "macfarlane", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@macfarlane"]]]
diff --git a/tests/issue61.expected.native b/tests/issue61.expected.native
index a37fc83..5068f5a 100644
--- a/tests/issue61.expected.native
+++ b/tests/issue61.expected.native
@@ -1,10 +1,10 @@
Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/modern-humanities-research-association.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Doe"]),("given",MetaInlines [Str "John"])])]),("id",MetaInlines [Str "doe"]),("issued",MetaMap (fromList [("date-parts",MetaList [MetaList [MetaString "1985"]])])),("publisher",MetaInlines [Str "Publisher"]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "book"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Roe"]),("given",MetaInlines [Str "Rob"])])]),("id",MetaInlines [Str "roe"]),("issued",MetaMap (fromList [("date-parts",MetaList [MetaList [MetaString "1985"]])])),("publisher",MetaInlines [Str "Publisher"]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "book"])])])]})
[Header 1 ("text",[],[]) [Str "Text"]
-,Para [Str "Foo",Str "",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "VIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 1}] [Note [Para [Str "John",Space,Str "Doe,",Space,Emph [Str "Title"],Space,Str "(Publisher,",Space,Str "1985),",Space,Str "VIII,",Space,Str "89."]]]]
-,Para [Str "Foo",Str "",Cite [Citation {citationId = "roe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "III,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 2}] [Note [Para [Str "Rob",Space,Str "Roe,",Space,Emph [Str "Title"],Space,Str "(Publisher,",Space,Str "1985),",Space,Str "III,",Space,Str "89."]]]]
-,Para [Str "Foo",Str "",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "LVIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 3}] [Note [Para [Str "Doe,",Space,Str "LVIII,",Space,Str "89."]]]]
-,Para [Str "Foo",Str "",Cite [Citation {citationId = "roe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "MVIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 4}] [Note [Para [Str "Roe,",Space,Str "MVIII,",Space,Str "89."]]]]
-,Para [Str "Foo",Str "",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "CL,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 5}] [Note [Para [Str "Doe,",Space,Str "CL,",Space,Str "89."]]]]
+,Para [Str "Foo",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "VIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 1}] [Note [Para [Str "John",Space,Str "Doe,",Space,Emph [Str "Title"],Space,Str "(Publisher,",Space,Str "1985),",Space,Str "VIII,",Space,Str "89."]]]]
+,Para [Str "Foo",Cite [Citation {citationId = "roe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "III,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 2}] [Note [Para [Str "Rob",Space,Str "Roe,",Space,Emph [Str "Title"],Space,Str "(Publisher,",Space,Str "1985),",Space,Str "III,",Space,Str "89."]]]]
+,Para [Str "Foo",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "LVIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 3}] [Note [Para [Str "Doe,",Space,Str "LVIII,",Space,Str "89."]]]]
+,Para [Str "Foo",Cite [Citation {citationId = "roe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "MVIII,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 4}] [Note [Para [Str "Roe,",Space,Str "MVIII,",Space,Str "89."]]]]
+,Para [Str "Foo",Cite [Citation {citationId = "doe", citationPrefix = [], citationSuffix = [Str ",",Space,Str "CL,",Space,Str "89"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 5}] [Note [Para [Str "Doe,",Space,Str "CL,",Space,Str "89."]]]]
,Header 1 ("references",["unnumbered"],[]) [Str "References"]
,Div ("refs",["references"],[])
[Div ("ref-doe",[],[])
diff --git a/tests/locators-delimited.expected.native b/tests/locators-delimited.expected.native
index 5500993..5606e39 100644
--- a/tests/locators-delimited.expected.native
+++ b/tests/locators-delimited.expected.native
@@ -5,16 +5,16 @@ Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/locators.csl"]),
,Para [Str "Kitchen",Space,Str "sink",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{123(4)a-8([a]12.398{8})}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 3}] [Note [Para [Str "Ibid-with-locator",Space,Str "{123(4)a\8211\&8([a]12.398{8})}."]]]]
,Para [Str "Empty",Space,Str "braces",Space,Str "inside",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{{}}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 4}] [Note [Para [Str "Ibid-with-locator",Space,Str "{{}}."]]]]
,Para [Str "Label",Space,Str "specified",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{p.\160a}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 5}] [Note [Para [Str "Ibid-with-locator",Space,Str "{a}."]]]]
-,Para [Str "Should",Space,Str "it",Space,Str "work",Space,Str "outside?",Space,Str "No.",Str "",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "p.",Space,Str "{(a)}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 6}] [Note [Para [Str "Subsequent,",Space,Str "p.",Space,Str "{(a)}."]]]]
-,Para [Str "Empty",Space,Str "locator",Str "",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 7}] [Note [Para [Str "Ibid."]]]]
+,Para [Str "Should",Space,Str "it",Space,Str "work",Space,Str "outside?",Space,Str "No.",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "p.",Space,Str "{(a)}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 6}] [Note [Para [Str "Subsequent,",Space,Str "p.",Space,Str "{(a)}."]]]]
+,Para [Str "Empty",Space,Str "locator",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 7}] [Note [Para [Str "Ibid."]]]]
,Para [Str "Empty",Space,Str "locator",Space,Str "to",Space,Str "force",Space,Str "suffix",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{}",Space,Str "123-35",Space,Str "numbers",Space,Str "are",Space,Str "suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 8}] [Note [Para [Str "Ibid",Space,Str "123-35",Space,Str "numbers",Space,Str "are",Space,Str "suffix."]]]]
-,Para [Str "Suffix",Space,Str "generally",Str "",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{123-35}",Space,Str "numbers",Space,Str "not,",Space,Str "but",Space,Str "text",Space,Str "is",Space,Str "suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 9}] [Note [Para [Str "Ibid-with-locator",Space,Str "{123\8211\&35}",Space,Str "numbers",Space,Str "not,",Space,Str "but",Space,Str "text",Space,Str "is",Space,Str "suffix."]]]]
+,Para [Str "Suffix",Space,Str "generally",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{123-35}",Space,Str "numbers",Space,Str "not,",Space,Str "but",Space,Str "text",Space,Str "is",Space,Str "suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 9}] [Note [Para [Str "Ibid-with-locator",Space,Str "{123\8211\&35}",Space,Str "numbers",Space,Str "not,",Space,Str "but",Space,Str "text",Space,Str "is",Space,Str "suffix."]]]]
,Para [Str "With",Space,Str "preceding",Space,Str "comma",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{p.\160VI}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 10}] [Note [Para [Str "Ibid-with-locator",Space,Str "{VI}."]]]]
,Para [Str "No",Space,Str "commas",Space,Str "before",Space,Str "label",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{,",Space,Str "p.",Space,Str "(p.\160is",Space,Str "not",Space,Str "recognised)}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 11}] [Note [Para [Str "Ibid-with-locator",Space,Str "{,",Space,Str "p.",Space,Str "(p.",Space,Str "is",Space,Str "not",Space,Str "recognised)}."]]]]
,Para [Str "Trim",Space,Str "white",Space,Str "space",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "{",Space,Str "p.\160\&9",Space,Str "}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 12}] [Note [Para [Str "Ibid-with-locator",Space,Str "{9}."]]]]
,Para [Str "Without",Space,Str "delimiters",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str ",",Space,Str "suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 13}] [Note [Para [Str "Subsequent,",Space,Str "suffix."]]]]
,Para [Str "With",Space,Str "rendering",Space,Str "label",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{ss",Space,Str "IV",Space,Str "div",Space,Str "4",Space,Str "s",Space,Str "128L(7)(a)(i)-(iv),",Space,Str "129(5),",SoftBreak,Str "130(b)}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 14}] [Note [Para [Str "Ibid-with-locator",Space,Str "ss",Space,Str "{IV",Space,Str "div",Space,Str "4",Space,Str "s",Space,Str "128L(7)(a)(i)\8211(iv),",Space,Str "129(5),",Space,Str "130(b)}."]]]]
-,Para [Str "The",Space,Str "text",Space,Str "is",Space,Str "apparently",Space,Str "NOT",Space,Str "verbatim;",Space,Str "it",Space,Str "is",Space,Str "lightly",Space,Str "processed",Space,Str "as",Space,Str "page",Space,Str "numbers.",Str "",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{no",Space,Str "comma,",Space,Str "no",Space,Str "label,",Space,Str "no",Space,Str "nothing}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 15}] [Note [Para [Str "Ibid-with-locator",Space,Str "{no",Space,Str "comma,",Space,Str "nolabel,",Space,Str "nonothing}."]]]]
-,Para [Str "AGLC-style",Space,Str "page",Space,Str "[para]",Str "",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{584",Space,Str "[78]}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 16}] [Note [Para [Str "Ibid-with-locator",Space,Str "{584",Space,Str "[78]}."]]]]
+,Para [Str "The",Space,Str "text",Space,Str "is",Space,Str "apparently",Space,Str "NOT",Space,Str "verbatim;",Space,Str "it",Space,Str "is",Space,Str "lightly",Space,Str "processed",Space,Str "as",Space,Str "page",Space,Str "numbers.",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{no",Space,Str "comma,",Space,Str "no",Space,Str "label,",Space,Str "no",Space,Str "nothing}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 15}] [Note [Para [Str "Ibid-with-locator",Space,Str "{no",Space,Str "comma,",Space,Str "nolabel,",Space,Str "nonothing}."]]]]
+,Para [Str "AGLC-style",Space,Str "page",Space,Str "[para]",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{584",Space,Str "[78]}"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 16}] [Note [Para [Str "Ibid-with-locator",Space,Str "{584",Space,Str "[78]}."]]]]
,Para [Str "Unbalanced",Space,Str "curly",Space,Str "{",Space,Str "breaks",Space,Str "the",Space,Str "parse",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{p.\160suffix{suffix}suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 17}] [Note [Para [Str "Subsequent",Space,Str "{p.\160suffix{suffix}suffix."]]]]
,Para [Str "Unbalanced",Space,Str "curly",Space,Str "}",Space,Str "ends",Space,Str "early",Cite [Citation {citationId = "citekey", citationPrefix = [], citationSuffix = [Str "{green}suffix}suffix"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 18}] [Note [Para [Str "Ibid-with-locator",Space,Str "{green}",Space,Str "suffix}suffix."]]]]]
diff --git a/tests/vancouver.csl b/tests/vancouver.csl
new file mode 100644
index 0000000..edbb69b
--- /dev/null
+++ b/tests/vancouver.csl
@@ -0,0 +1,351 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" page-range-format="minimal">
+ <info>
+ <title>Vancouver</title>
+ <id>http://www.zotero.org/styles/vancouver</id>
+ <link href="http://www.zotero.org/styles/vancouver" rel="self"/>
+ <link href="http://www.nlm.nih.gov/bsd/uniform_requirements.html" rel="documentation"/>
+ <author>
+ <name>Michael Berkowitz</name>
+ <email>mberkowi@gmu.edu</email>
+ </author>
+ <contributor>
+ <name>Sean Takats</name>
+ <email>stakats@gmu.edu</email>
+ </contributor>
+ <contributor>
+ <name>Sebastian Karcher</name>
+ </contributor>
+ <category citation-format="numeric"/>
+ <category field="medicine"/>
+ <summary>Vancouver style as outlined by International Committee of Medical Journal Editors Uniform Requirements for Manuscripts Submitted to Biomedical Journals: Sample References</summary>
+ <updated>2014-09-06T16:03:01+00:00</updated>
+ <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
+ </info>
+ <locale xml:lang="en">
+ <date form="text" delimiter=" ">
+ <date-part name="year"/>
+ <date-part name="month" form="short" strip-periods="true"/>
+ <date-part name="day"/>
+ </date>
+ <terms>
+ <term name="collection-editor" form="long">
+ <single>editor</single>
+ <multiple>editors</multiple>
+ </term>
+ <term name="presented at">presented at</term>
+ <term name="available at">available from</term>
+ <term name="section" form="short">sect.</term>
+ </terms>
+ </locale>
+ <locale xml:lang="fr">
+ <date form="text" delimiter=" ">
+ <date-part name="day"/>
+ <date-part name="month" form="short" strip-periods="true"/>
+ <date-part name="year"/>
+ </date>
+ </locale>
+ <macro name="author">
+ <names variable="author">
+ <name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
+ <label form="long" prefix=", "/>
+ <substitute>
+ <names variable="editor"/>
+ </substitute>
+ </names>
+ </macro>
+ <macro name="editor">
+ <names variable="editor" suffix=".">
+ <name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
+ <label form="long" prefix=", "/>
+ </names>
+ </macro>
+ <macro name="chapter-marker">
+ <choose>
+ <if type="chapter paper-conference entry-dictionary entry-encyclopedia" match="any">
+ <text term="in" text-case="capitalize-first"/>
+ </if>
+ </choose>
+ </macro>
+ <macro name="publisher">
+ <choose>
+ <!--discard publisher info for articles-->
+ <if type="article-journal article-magazine article-newspaper" match="none">
+ <group delimiter=": " suffix=";">
+ <choose>
+ <if type="thesis">
+ <text variable="publisher-place" prefix="[" suffix="]"/>
+ </if>
+ <else-if type="speech"/>
+ <else>
+ <text variable="publisher-place"/>
+ </else>
+ </choose>
+ <text variable="publisher"/>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="access">
+ <choose>
+ <if variable="URL">
+ <group delimiter=": ">
+ <text term="available at" text-case="capitalize-first"/>
+ <text variable="URL"/>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="accessed-date">
+ <choose>
+ <if variable="URL">
+ <group prefix="[" suffix="]" delimiter=" ">
+ <text term="cited" text-case="lowercase"/>
+ <date variable="accessed" form="text"/>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="container-title">
+ <choose>
+ <if type="article-journal article-magazine chapter paper-conference article-newspaper review review-book entry-dictionary entry-encyclopedia" match="any">
+ <group suffix="." delimiter=" ">
+ <choose>
+ <if type="article-journal review review-book" match="any">
+ <text variable="container-title" form="short" strip-periods="true"/>
+ </if>
+ <else>
+ <text variable="container-title" strip-periods="true"/>
+ </else>
+ </choose>
+ <choose>
+ <if variable="URL">
+ <text term="internet" prefix="[" suffix="]" text-case="capitalize-first"/>
+ </if>
+ </choose>
+ </group>
+ <text macro="edition" prefix=" "/>
+ </if>
+ <!--add event-name and event-place once they become available-->
+ <else-if type="bill legislation" match="any">
+ <group delimiter=", ">
+ <group delimiter=". ">
+ <text variable="container-title"/>
+ <group delimiter=" ">
+ <text term="section" form="short" text-case="capitalize-first"/>
+ <text variable="section"/>
+ </group>
+ </group>
+ <text variable="number"/>
+ </group>
+ </else-if>
+ <else-if type="speech">
+ <group delimiter=": " suffix=";">
+ <group delimiter=" ">
+ <text variable="genre" text-case="capitalize-first"/>
+ <text term="presented at"/>
+ </group>
+ <text variable="event"/>
+ </group>
+ </else-if>
+ <else>
+ <group delimiter=", " suffix=".">
+ <choose>
+ <if variable="collection-title" match="none">
+ <group delimiter=" ">
+ <label variable="volume" form="short" text-case="capitalize-first"/>
+ <text variable="volume"/>
+ </group>
+ </if>
+ </choose>
+ <text variable="container-title"/>
+ </group>
+ </else>
+ </choose>
+ </macro>
+ <macro name="title">
+ <text variable="title"/>
+ <choose>
+ <if type="article-journal article-magazine chapter paper-conference article-newspaper review review-book entry-dictionary entry-encyclopedia" match="none">
+ <choose>
+ <if variable="URL">
+ <text term="internet" prefix=" [" suffix="]" text-case="capitalize-first"/>
+ </if>
+ </choose>
+ <text macro="edition" prefix=". "/>
+ </if>
+ </choose>
+ <choose>
+ <if type="thesis">
+ <text variable="genre" prefix=" [" suffix="]"/>
+ </if>
+ </choose>
+ </macro>
+ <macro name="edition">
+ <choose>
+ <if is-numeric="edition">
+ <group delimiter=" ">
+ <number variable="edition" form="ordinal"/>
+ <text term="edition" form="short"/>
+ </group>
+ </if>
+ <else>
+ <text variable="edition" suffix="."/>
+ </else>
+ </choose>
+ </macro>
+ <macro name="date">
+ <choose>
+ <if type="article-journal article-magazine article-newspaper review review-book" match="any">
+ <group suffix=";" delimiter=" ">
+ <date variable="issued" form="text"/>
+ <text macro="accessed-date"/>
+ </group>
+ </if>
+ <else-if type="bill legislation" match="any">
+ <group delimiter=", ">
+ <date variable="issued" delimiter=" ">
+ <date-part name="month" form="short" strip-periods="true"/>
+ <date-part name="day"/>
+ </date>
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </group>
+ </else-if>
+ <else-if type="report">
+ <date variable="issued" delimiter=" ">
+ <date-part name="year"/>
+ <date-part name="month" form="short" strip-periods="true"/>
+ </date>
+ <text macro="accessed-date" prefix=" "/>
+ </else-if>
+ <else-if type="patent">
+ <group suffix=".">
+ <group delimiter=", ">
+ <text variable="number"/>
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </group>
+ <text macro="accessed-date" prefix=" "/>
+ </group>
+ </else-if>
+ <else-if type="speech">
+ <group delimiter="; ">
+ <group delimiter=" ">
+ <date variable="issued" delimiter=" ">
+ <date-part name="year"/>
+ <date-part name="month" form="short" strip-periods="true"/>
+ <date-part name="day"/>
+ </date>
+ <text macro="accessed-date"/>
+ </group>
+ <text variable="event-place"/>
+ </group>
+ </else-if>
+ <else>
+ <group suffix=".">
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ <text macro="accessed-date" prefix=" "/>
+ </group>
+ </else>
+ </choose>
+ </macro>
+ <macro name="pages">
+ <choose>
+ <if type="article-journal article-magazine article-newspaper review review-book" match="any">
+ <text variable="page" prefix=":"/>
+ </if>
+ <else-if type="book" match="any">
+ <text variable="number-of-pages" prefix=" "/>
+ <choose>
+ <if is-numeric="number-of-pages">
+ <label variable="number-of-pages" form="short" prefix=" " plural="never"/>
+ </if>
+ </choose>
+ </else-if>
+ <else>
+ <group prefix=" " delimiter=" ">
+ <label variable="page" form="short" plural="never"/>
+ <text variable="page"/>
+ </group>
+ </else>
+ </choose>
+ </macro>
+ <macro name="journal-location">
+ <choose>
+ <if type="article-journal article-magazine review review-book" match="any">
+ <text variable="volume"/>
+ <text variable="issue" prefix="(" suffix=")"/>
+ </if>
+ </choose>
+ </macro>
+ <macro name="collection-details">
+ <choose>
+ <if type="article-journal article-magazine article-newspaper review review-book" match="none">
+ <choose>
+ <if variable="collection-title">
+ <group delimiter=" " prefix="(" suffix=")">
+ <names variable="collection-editor" suffix=".">
+ <name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
+ <label form="long" prefix=", "/>
+ </names>
+ <group delimiter="; ">
+ <text variable="collection-title"/>
+ <group delimiter=" ">
+ <label variable="volume" form="short"/>
+ <text variable="volume"/>
+ </group>
+ </group>
+ </group>
+ </if>
+ </choose>
+ </if>
+ </choose>
+ </macro>
+ <macro name="report-details">
+ <choose>
+ <if type="report">
+ <text variable="number" prefix="Report No.: "/>
+ </if>
+ </choose>
+ </macro>
+ <citation collapse="citation-number">
+ <sort>
+ <key variable="citation-number"/>
+ </sort>
+ <layout prefix="(" suffix=")" delimiter=",">
+ <text variable="citation-number"/>
+ </layout>
+ </citation>
+ <bibliography et-al-min="7" et-al-use-first="6" second-field-align="flush">
+ <layout>
+ <text variable="citation-number" suffix=". "/>
+ <group delimiter=". " suffix=". ">
+ <text macro="author"/>
+ <text macro="title"/>
+ </group>
+ <group delimiter=" " suffix=". ">
+ <group delimiter=": ">
+ <text macro="chapter-marker"/>
+ <group delimiter=" ">
+ <text macro="editor"/>
+ <text macro="container-title"/>
+ </group>
+ </group>
+ <text macro="publisher"/>
+ <group>
+ <text macro="date"/>
+ <text macro="journal-location"/>
+ <text macro="pages"/>
+ </group>
+ </group>
+ <text macro="collection-details" suffix=". "/>
+ <text macro="report-details" suffix=". "/>
+ <text macro="access"/>
+ </layout>
+ </bibliography>
+</style>