diff options
Diffstat (limited to 'src/Text/Pandoc/Readers')
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 19 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Org/Inlines.hs | 13 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index d81c4e3c1..248bf0146 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -55,7 +55,6 @@ import Text.Pandoc.Shared import Text.Pandoc.URI (escapeURI, isURI, pBase64DataURI) import Text.Pandoc.XML (fromEntities) import Text.Pandoc.Readers.Metadata (yamlBsToMeta, yamlBsToRefs, yamlMetaBlock) --- import Debug.Trace (traceShowId) type MarkdownParser m = ParsecT Sources ParserState m @@ -2247,14 +2246,8 @@ normalCite = try $ do return citations suffix :: PandocMonad m => MarkdownParser m (F Inlines) -suffix = try $ do - hasSpace <- option False (notFollowedBy nonspaceChar >> return True) - spnl - ils <- many (notFollowedBy (oneOf ";]") >> inline) - let rest = trimInlinesF (mconcat ils) - return $ if hasSpace && not (null ils) - then (B.space <>) <$> rest - else rest +suffix = try $ + mconcat <$> many (notFollowedBy (oneOf ";]") >> inline) prefix :: PandocMonad m => MarkdownParser m (F Inlines) prefix = trimInlinesF . mconcat <$> @@ -2274,11 +2267,11 @@ citation = try $ do suff <- suffix noteNum <- stateNoteNumber <$> getState return $ do - x <- pref - y <- suff + pref' <- B.toList <$> pref + suff' <- B.toList <$> suff return Citation{ citationId = key - , citationPrefix = B.toList x - , citationSuffix = B.toList y + , citationPrefix = pref' + , citationSuffix = suff' , citationMode = if suppress_author then SuppressAuthor else NormalCitation diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs index 4d901ffc4..99f71f306 100644 --- a/src/Text/Pandoc/Readers/Org/Inlines.hs +++ b/src/Text/Pandoc/Readers/Org/Inlines.hs @@ -182,21 +182,26 @@ adjustCiteStyle sty cs = do addPrefixToFirstItem :: (F Inlines) -> (F [Citation]) -> (F [Citation]) addPrefixToFirstItem aff cs = do cs' <- cs - aff' <- aff + aff' <- B.toList <$> aff case cs' of [] -> return [] (d:ds) -> return (d{ citationPrefix = - B.toList aff' <> citationPrefix d }:ds) + if null aff' + then citationPrefix d + else aff' ++ (Str "|" : citationPrefix d) }:ds) addSuffixToLastItem :: (F Inlines) -> (F [Citation]) -> (F [Citation]) addSuffixToLastItem aff cs = do cs' <- cs - aff' <- aff + aff' <- B.toList <$> aff case lastMay cs' of Nothing -> return cs' Just d -> return (init cs' ++ [d{ citationSuffix = - citationSuffix d <> B.toList aff' }]) + citationSuffix d <> + if null aff' + then [] + else Str "|" : aff' }]) citeItems :: PandocMonad m => OrgParser m (F [Citation]) citeItems = sequence <$> sepBy1' citeItem (char ';' <* void (many spaceChar)) |
