aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-06-05 11:54:27 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-06-05 11:54:27 -0700
commitc06ed6e3b148910a89b7c9a9acb1dd41f818b351 (patch)
tree994a6127388afd3c2a7b5871c6a07e0117d3c0ef /src/Text
parent337735ae3221d7eb84776524376a221ffac3e7c4 (diff)
downloadpandoc-c06ed6e3b148910a89b7c9a9acb1dd41f818b351.tar.gz
Biblio: Add comma to beginning of bare suffix, e.g. @item1 [50].
Motivation: @item1 [50] should be as close as possible to [@item1, 50].
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Biblio.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
index 6168576fa..45c12cc96 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(..) )
@@ -124,13 +124,21 @@ toCslCite :: Citation -> CSL.Cite
toCslCite c
= let (l, s) = locatorWords $ citationSuffix c
(la,lo) = parseLocator l
+ s' = case (l,s,citationMode c) of
+ -- treat a bare locator as if it begins with comma
+ -- so @item1 [blah] is like [@item1, blah]
+ ("",(x:_),AuthorInText) | not (isPunct x)
+ -> [Str ",",Space] ++ s
+ _ -> s
+ isPunct (Str (c:_)) = isPunctuation c
+ isPunct _ = False
citMode = case citationMode c of
AuthorInText -> (True, False)
SuppressAuthor -> (False,True )
NormalCitation -> (False,False)
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