From 565113fb6b91ecaf1827110a53df923d9ef36789 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 27 Oct 2011 13:58:10 -0700 Subject: Biblio: Treat \160 as space when parsing locator and suffix. This fixes a bug with "p. 33" when `--smart` is used. Previously the whole "p. 33" would be included in the suffix, with no locator. --- src/Text/Pandoc/Biblio.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index d65c9de1c..3182d7d0b 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -182,9 +182,13 @@ toCslCite c locatorWords :: [Inline] -> (String, [Inline]) locatorWords inp = - case parse pLocatorWords "suffix" inp of + case parse pLocatorWords "suffix" $ breakup inp of Right r -> r Left _ -> ("",inp) + where breakup [] = [] + breakup (Str x : xs) = map Str (splitup x) ++ breakup xs + breakup (x : xs) = x : breakup xs + splitup = groupBy (\x y -> x /= '\160' && y /= '\160') pLocatorWords :: GenParser Inline st (String, [Inline]) pLocatorWords = do @@ -201,7 +205,7 @@ pMatch condition = try $ do return t pSpace :: GenParser Inline st Inline -pSpace = pMatch (== Space) +pSpace = pMatch (\t -> t == Space || t == Str "\160") pLocator :: GenParser Inline st String pLocator = try $ do -- cgit v1.2.3