diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-03-09 13:39:19 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-03-09 13:39:19 -0800 |
commit | 5f013051e2fccc123e8a365da27367da83016795 (patch) | |
tree | 5e0ee20a9b72b2880c569092cfab073bd7ef827b /src/Text | |
parent | 96274b2838a56df0463c844ef5ff6080545690e8 (diff) | |
download | pandoc-5f013051e2fccc123e8a365da27367da83016795.tar.gz |
Made man writer more robust.
Previously it assumed that inlines weren't normalized.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Man.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 02dd45c4a..c481e6c87 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -126,8 +126,8 @@ escapeCode = concat . intersperse "\n" . map escapeLine . lines where breakSentence :: [Inline] -> ([Inline], [Inline]) breakSentence [] = ([],[]) breakSentence xs = - let isSentenceEndInline (Str ".") = True - isSentenceEndInline (Str "?") = True + let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True + isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True isSentenceEndInline (LineBreak) = True isSentenceEndInline _ = False (as, bs) = break isSentenceEndInline xs @@ -135,8 +135,9 @@ breakSentence xs = [] -> (as, []) [c] -> (as ++ [c], []) (c:Space:cs) -> (as ++ [c], cs) - (Str ".":Str ")":cs) -> (as ++ [Str ".", Str ")"], cs) - (LineBreak:Str ".":cs) -> (as ++[LineBreak], Str ".":cs) + (Str ".":Str (')':ys):cs) -> (as ++ [Str ".", Str (')':ys)], cs) + (x@(Str ('.':')':_)):cs) -> (as ++ [x], cs) + (LineBreak:x@(Str ('.':_)):cs) -> (as ++[LineBreak], x:cs) (c:cs) -> (as ++ [c] ++ ds, es) where (ds, es) = breakSentence cs @@ -285,7 +286,7 @@ blockListToMan opts blocks = inlineListToMan :: WriterOptions -> [Inline] -> State WriterState Doc -- if list starts with ., insert a zero-width character \& so it -- won't be interpreted as markup if it falls at the beginning of a line. -inlineListToMan opts lst@(Str "." : _) = mapM (inlineToMan opts) lst >>= +inlineListToMan opts lst@(Str ('.':_) : _) = mapM (inlineToMan opts) lst >>= (return . (text "\\&" <>) . hcat) inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat) |