"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Text/Pandoc/Citeproc.hs" between
pandoc-2.11.1.1.tar.gz and pandoc-2.11.2.tar.gz

About: Pandoc converts files from one markup format into another.

Citeproc.hs  (pandoc-2.11.1.1):Citeproc.hs  (pandoc-2.11.2)
skipping to change at line 527 skipping to change at line 527
Note (walk go bs) : deNote rest Note (walk go bs) : deNote rest
where where
go [] = [] go [] = []
go (Cite (c:cs) ils : zs) go (Cite (c:cs) ils : zs)
| citationMode c == AuthorInText | citationMode c == AuthorInText
= Cite cs (concatMap (noteAfterComma (needsPeriod zs)) ils) : go zs = Cite cs (concatMap (noteAfterComma (needsPeriod zs)) ils) : go zs
| otherwise | otherwise
= Cite cs (concatMap noteInParens ils) : go zs = Cite cs (concatMap noteInParens ils) : go zs
go (x:xs) = x : go xs go (x:xs) = x : go xs
needsPeriod [] = True needsPeriod [] = True
needsPeriod (Str t:_) = not (T.null t) && isUpper (T.head t) needsPeriod (Str t:_) = case T.uncons t of
Nothing -> False
Just (c,_) -> isUpper c
needsPeriod (Space:zs) = needsPeriod zs needsPeriod (Space:zs) = needsPeriod zs
needsPeriod _ = False needsPeriod _ = False
noteInParens (Note bs') noteInParens (Note bs')
= Space : Str "(" : = Space : Str "(" :
removeFinalPeriod (blocksToInlines bs') ++ [Str ")"] removeFinalPeriod (blocksToInlines bs') ++ [Str ")"]
noteInParens x = [x] noteInParens x = [x]
noteAfterComma needsPer (Note bs') noteAfterComma needsPer (Note bs')
= Str "," : Space : = Str "," : Space :
(if needsPer (if needsPer
then id then id
skipping to change at line 550 skipping to change at line 552
deNote (x:xs) = x : deNote xs deNote (x:xs) = x : deNote xs
-- Note: we can't use dropTextWhileEnd indiscriminately, -- Note: we can't use dropTextWhileEnd indiscriminately,
-- because this would remove the final period on abbreviations like Ibid. -- because this would remove the final period on abbreviations like Ibid.
-- But it turns out that when the note citation ends with Ibid. -- But it turns out that when the note citation ends with Ibid.
-- (or Ed. etc.), the last inline will be Str "" as a result of -- (or Ed. etc.), the last inline will be Str "" as a result of
-- the punctuation-fixing mechanism that removes the double '.'. -- the punctuation-fixing mechanism that removes the double '.'.
removeFinalPeriod :: [Inline] -> [Inline] removeFinalPeriod :: [Inline] -> [Inline]
removeFinalPeriod ils = removeFinalPeriod ils =
case lastMay ils of case lastMay ils of
Just (Span attr ils')
-> initSafe ils ++ [Span attr (removeFinalPeriod ils')]
Just (Emph ils')
-> initSafe ils ++ [Emph (removeFinalPeriod ils')]
Just (Strong ils')
-> initSafe ils ++ [Strong (removeFinalPeriod ils')]
Just (SmallCaps ils')
-> initSafe ils ++ [SmallCaps (removeFinalPeriod ils')]
Just (Str t) Just (Str t)
| T.takeEnd 1 t == "." -> initSafe ils ++ [Str (T.dropEnd 1 t)] | T.takeEnd 1 t == "." -> initSafe ils ++ [Str (T.dropEnd 1 t)]
| isRightQuote (T.takeEnd 1 t)
-> removeFinalPeriod
(initSafe ils ++ [Str tInit | not (T.null tInit)]) ++ [Str tEnd]
where
tEnd = T.takeEnd 1 t
tInit = T.dropEnd 1 t
_ -> ils _ -> ils
where
isRightQuote "\8221" = True
isRightQuote "\8217" = True
isRightQuote "\187" = True
isRightQuote _ = False
 End of changes. 4 change blocks. 
1 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)