git.iko.soy/typeable/pandoc
on master help sign in
Shared: Made splitBy take a test instead of an element.
commitfe1152985ca8824b62c7bce397a681e7e422e8e1 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 21 Dec 2010, 08:41 (16 years ago) parent4e44635
4 files changed+9−9
src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Shared.hs+6−6 src/Text/Pandoc/Writers/Docbook.hs+1−1 src/Text/Pandoc/Writers/Man.hs+1−1
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -340,7 +340,7 @@ authors :: GenParser Char ParserState Block
340340authors = try $ do
341341 string "\\author{"
342342 raw <- many1 (notFollowedBy (char '}') >> inline)
343− let authors' = map normalizeSpaces $ splitBy LineBreak raw
343+ let authors' = map normalizeSpaces $ splitBy (== LineBreak) raw
344344 char '}'
345345 spaces
346346 updateState (\s -> s { stateAuthors = authors' })
src/Text/Pandoc/Shared.hs+6−6
@@ -98,12 +98,12 @@ import Paths_pandoc (getDataFileName)
9898--
9999
100100-- | Split list by groups of one or more sep.
101−splitBy :: (Eq a) => a -> [a] -> [[a]]
101+splitBy :: (a -> Bool) -> [a] -> [[a]]
102102splitBy _ [] = []
103−splitBy sep lst =
104− let (first, rest) = break (== sep) lst
105− rest' = dropWhile (== sep) rest
106− in first:(splitBy sep rest')
103+splitBy isSep lst =
104+ let (first, rest) = break isSep lst
105+ rest' = dropWhile isSep rest
106+ in first:(splitBy isSep rest')
107107
108108-- | Split list into chunks divided at specified indices.
109109splitByIndices :: [Int] -> [a] -> [[a]]
@@ -227,7 +227,7 @@ tabFilter tabStop =
227227
228228-- | Wrap inlines to line length.
229229wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
230−wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>=
230+wrapped listWriter sect = (mapM listWriter $ splitBy (== Space) sect) >>=
231231 return . fsep
232232
233233-- | Wrap inlines if the text wrap option is selected.
src/Text/Pandoc/Writers/Docbook.hs+1−1
@@ -217,7 +217,7 @@ tableItemToDocbook opts tag align item =
217217-- | Take list of inline elements and return wrapped doc.
218218wrap :: WriterOptions -> [Inline] -> Doc
219219wrap opts lst = if writerWrapText opts
220− then fsep $ map (inlinesToDocbook opts) (splitBy Space lst)
220+ then fsep $ map (inlinesToDocbook opts) (splitBy (== Space) lst)
221221 else inlinesToDocbook opts lst
222222
223223-- | Convert a list of inline elements to Docbook.
src/Text/Pandoc/Writers/Man.hs+1−1
@@ -59,7 +59,7 @@ pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
5959 xs -> (text (reverse xs), doubleQuotes empty)
6060 let description = hsep $
6161 map (doubleQuotes . text . removeLeadingTrailingSpace) $
62− splitBy '|' rest
62+ splitBy (== '|') rest
6363 body <- blockListToMan opts blocks
6464 notes <- liftM stNotes get
6565 notes' <- notesToMan opts (reverse notes)