diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-11-03 12:58:29 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-11-03 12:58:29 -0700 |
commit | 5e1dc6adda5b11a1d5e51dcccae4801f60b64f4b (patch) | |
tree | da10c1369abd4cd000f3502828c717433e6ca5fd | |
parent | 075840231bf6ab63d032e39651286e4fee5aa555 (diff) | |
download | pandoc-5e1dc6adda5b11a1d5e51dcccae4801f60b64f4b.tar.gz |
Biblio: Improve footnote generation.
Patch from Andrea Rossato.
-rw-r--r-- | src/Text/Pandoc/Biblio.hs | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index d4b72c9ad..8a9b21b4e 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -107,26 +107,35 @@ procInlines f b mvCiteInNote :: [Inline] -> Block -> Block mvCiteInNote is = procInlines mvCite where - elem_ x xs = case x of Cite cs _ -> (Cite cs []) `elem` xs; _ -> False mvCite :: [Inline] -> [Inline] mvCite inls + | x:i:xs <- inls, startWPt xs + , x == Space, i `elem_` is = split i xs ++ mvCite (tailInline xs) | x:i:xs <- inls - , x == Space, i `elem_` is = mvInNote i : mvCite xs - | i:xs <- inls, i `elem_` is = mvInNote i : mvCite xs - | i:xs <- inls, Note _ <- i = checkNt i : mvCite xs - | i:xs <- inls = i : mvCite xs + , x == Space, i `elem_` is = mvInNote i : mvCite xs + | i:xs <- inls, i `elem_` is + , startWPt xs = split i xs ++ mvCite (tailInline xs) + | i:xs <- inls, Note _ <- i = checkNt i : mvCite xs + | i:xs <- inls = i : mvCite xs | otherwise = [] + elem_ x xs = case x of Cite cs _ -> (Cite cs []) `elem` xs; _ -> False + split i xs = Str (headInline xs) : mvInNote i : [] mvInNote i - | Cite t o <- i = Note [Para [Cite t $ toCapital o]] - | otherwise = Note [Para [i ]] + | Cite t o <- i = Note [Para [Cite t $ sanitize o]] + | otherwise = Note [Para [i ]] + sanitize i + | endWPt i = toCapital i + | otherwise = toCapital (i ++ [Str "."]) + checkPt i | Cite c o : xs <- i , headInline xs == lastInline o - , isPunct o = Cite c (initInline o) : checkPt xs + , endWPt o = Cite c (initInline o) : checkPt xs | x:xs <- i = x : checkPt xs | otherwise = [] - isPunct = and . map isPunctuation . lastInline - checkNt = processWith $ procInlines checkPt + endWPt = and . map isPunctuation . lastInline + startWPt = and . map isPunctuation . headInline + checkNt = processWith $ procInlines checkPt headInline :: [Inline] -> String headInline [] = [] @@ -164,6 +173,11 @@ initInline (i:[]) init' s = if s /= [] then init s else [] initInline (i:xs) = i : initInline xs +tailInline :: [Inline] -> [Inline] +tailInline = mapHeadInline tail' + where + tail' s = if s /= [] then tail s else [] + toCapital :: [Inline] -> [Inline] toCapital = mapHeadInline toCap where |