aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorNathan Gass <gass@search.ch>2010-12-13 21:33:08 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-13 20:50:29 -0800
commit2e728df7569853fdd3b496c70654b0a8eae7f1ec (patch)
treec039ec8b791520500aa629f8a94ff969c4782b75 /src/Text
parentc2d3796439d56dff6c72e9b961d080a52cf634b9 (diff)
downloadpandoc-2e728df7569853fdd3b496c70654b0a8eae7f1ec.tar.gz
Moved special handling of punctuation in suffix out of markdown reader.
This allows different writers to handle punctuation in the suffix differently.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Biblio.hs8
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
2 files changed, 8 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
index 0241b2d6d..a6c87fcbc 100644
--- a/src/Text/Pandoc/Biblio.hs
+++ b/src/Text/Pandoc/Biblio.hs
@@ -31,7 +31,7 @@ module Text.Pandoc.Biblio ( processBiblio ) where
import Data.List
import Data.Unique
-import Data.Char ( isDigit )
+import Data.Char ( isDigit, isPunctuation )
import qualified Data.Map as M
import Text.CSL hiding ( Cite(..), Citation(..) )
import qualified Text.CSL as CSL ( Cite(..) )
@@ -164,9 +164,13 @@ toCslCite c
AuthorInText -> (True, False)
SuppressAuthor -> (False,True )
NormalCitation -> (False,False)
+ s' = case s of
+ [] -> []
+ (Str (y:_) : _) | isPunctuation y -> s
+ _ -> Str "," : Space : s
in emptyCite { CSL.citeId = citationId c
, CSL.citePrefix = PandocText $ citationPrefix c
- , CSL.citeSuffix = PandocText $ s
+ , CSL.citeSuffix = PandocText $ s'
, CSL.citeLabel = la
, CSL.citeLocator = lo
, CSL.citeNoteNumber = show $ citationNoteNum c
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 5994f2ef8..51c61103b 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -32,7 +32,7 @@ module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate )
import qualified Data.Map as M
import Data.Ord ( comparing )
-import Data.Char ( isAlphaNum, isPunctuation )
+import Data.Char ( isAlphaNum )
import Data.Maybe
import Text.Pandoc.Definition
import Text.Pandoc.Shared
@@ -1291,12 +1291,7 @@ citeKey = try $ do
suffix :: GenParser Char ParserState [Inline]
suffix = try $ do
spnl
- res <- many $ notFollowedBy (oneOf ";]") >> inline
- return $ case res of
- [] -> []
- (Str (y:_) : _) | isPunctuation y
- -> res
- _ -> Str "," : Space : res
+ liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline
prefix :: GenParser Char ParserState [Inline]
prefix = liftM normalizeSpaces $