git.iko.soy/typeable/pandoc
on master help sign in
Shared: rename compactify', compactify'DL -> compactify, compactifyDL.
5156a4fJohn MacFarlane
src/Text/Pandoc/Parsing.hs+1−1
@@ -868,7 +868,7 @@ removeOneLeadingSpace xs =
868 startsWithSpace (y:_) = y == ' '
868 startsWithSpace (y:_) = y == ' '
869
869
870compactifyCell :: Blocks -> Blocks
870compactifyCell :: Blocks -> Blocks
871−compactifyCell bs = head $ compactify' [bs]
871+compactifyCell bs = head $ compactify [bs]
872
872
873-- | Parse footer for a grid table.
873-- | Parse footer for a grid table.
874gridTableFooter :: Stream s m Char => ParserT s ParserState m [Char]
874gridTableFooter :: Stream s m Char => ParserT s ParserState m [Char]
src/Text/Pandoc/Readers/Markdown.hs+4−4
@@ -909,12 +909,12 @@ orderedList = try $ do
909 atMostSpaces (tabStop - (endpos - startpos))
909 atMostSpaces (tabStop - (endpos - startpos))
910 return res )
910 return res )
911 start' <- option 1 $ guardEnabled Ext_startnum >> return start
911 start' <- option 1 $ guardEnabled Ext_startnum >> return start
912− return $ B.orderedListWith (start', style, delim) <$> fmap compactify' items
912+ return $ B.orderedListWith (start', style, delim) <$> fmap compactify items
913
913
914bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
914bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
915bulletList = do
915bulletList = do
916 items <- fmap sequence $ many1 $ listItem bulletListStart
916 items <- fmap sequence $ many1 $ listItem bulletListStart
917− return $ B.bulletList <$> fmap compactify' items
917+ return $ B.bulletList <$> fmap compactify items
918
918
919-- definition lists
919-- definition lists
920
920
@@ -972,7 +972,7 @@ compactDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
972compactDefinitionList = do
972compactDefinitionList = do
973 guardEnabled Ext_compact_definition_lists
973 guardEnabled Ext_compact_definition_lists
974 items <- fmap sequence $ many1 $ definitionListItem True
974 items <- fmap sequence $ many1 $ definitionListItem True
975− return $ B.definitionList <$> fmap compactify'DL items
975+ return $ B.definitionList <$> fmap compactifyDL items
976
976
977normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
977normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
978normalDefinitionList = do
978normalDefinitionList = do
@@ -1349,7 +1349,7 @@ gridTableRow indices = do
1349 colLines <- many1 (gridTableRawLine indices)
1349 colLines <- many1 (gridTableRawLine indices)
1350 let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
1350 let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
1351 transpose colLines
1351 transpose colLines
1352− fmap compactify' <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
1352+ fmap compactify <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
1353
1353
1354removeOneLeadingSpace :: [String] -> [String]
1354removeOneLeadingSpace :: [String] -> [String]
1355removeOneLeadingSpace xs =
1355removeOneLeadingSpace xs =
src/Text/Pandoc/Readers/Odt/ContentReader.hs+2−2
@@ -663,7 +663,7 @@ read_list = matchingElement NsText "list"
663--
663--
664read_list_item :: ElementMatcher [Blocks]
664read_list_item :: ElementMatcher [Blocks]
665read_list_item = matchingElement NsText "list-item"
665read_list_item = matchingElement NsText "list-item"
666− $ liftA (compactify'.(:[]))
666+ $ liftA (compactify.(:[]))
667 ( matchChildContent' [ read_paragraph
667 ( matchChildContent' [ read_paragraph
668 , read_header
668 , read_header
669 , read_list
669 , read_list
@@ -749,7 +749,7 @@ read_table_row = matchingElement NsTable "table-row"
749--
749--
750read_table_cell :: ElementMatcher [Blocks]
750read_table_cell :: ElementMatcher [Blocks]
751read_table_cell = matchingElement NsTable "table-cell"
751read_table_cell = matchingElement NsTable "table-cell"
752− $ liftA (compactify'.(:[]))
752+ $ liftA (compactify.(:[]))
753 $ matchChildContent' [ read_paragraph
753 $ matchChildContent' [ read_paragraph
754 ]
754 ]
755
755
src/Text/Pandoc/Readers/Org/Blocks.hs+4−4
@@ -47,7 +47,7 @@ import Text.Pandoc.Builder ( Inlines, Blocks )
47import Text.Pandoc.Class (PandocMonad)
47import Text.Pandoc.Class (PandocMonad)
48import Text.Pandoc.Definition
48import Text.Pandoc.Definition
49import Text.Pandoc.Options
49import Text.Pandoc.Options
50−import Text.Pandoc.Shared ( compactify', compactify'DL, safeRead )
50+import Text.Pandoc.Shared ( compactify, compactifyDL, safeRead )
51
51
52import Control.Monad ( foldM, guard, mzero, void )
52import Control.Monad ( foldM, guard, mzero, void )
53import Data.Char ( isSpace, toLower, toUpper)
53import Data.Char ( isSpace, toLower, toUpper)
@@ -898,16 +898,16 @@ list = choice [ definitionList, bulletList, orderedList ] <?> "list"
898
898
899definitionList :: PandocMonad m => OrgParser m (F Blocks)
899definitionList :: PandocMonad m => OrgParser m (F Blocks)
900definitionList = try $ do n <- lookAhead (bulletListStart' Nothing)
900definitionList = try $ do n <- lookAhead (bulletListStart' Nothing)
901− fmap B.definitionList . fmap compactify'DL . sequence
901+ fmap B.definitionList . fmap compactifyDL . sequence
902 <$> many1 (definitionListItem $ bulletListStart' (Just n))
902 <$> many1 (definitionListItem $ bulletListStart' (Just n))
903
903
904bulletList :: PandocMonad m => OrgParser m (F Blocks)
904bulletList :: PandocMonad m => OrgParser m (F Blocks)
905bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)
905bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)
906− fmap B.bulletList . fmap compactify' . sequence
906+ fmap B.bulletList . fmap compactify . sequence
907 <$> many1 (listItem (bulletListStart' $ Just n))
907 <$> many1 (listItem (bulletListStart' $ Just n))
908
908
909orderedList :: PandocMonad m => OrgParser m (F Blocks)
909orderedList :: PandocMonad m => OrgParser m (F Blocks)
910−orderedList = fmap B.orderedList . fmap compactify' . sequence
910+orderedList = fmap B.orderedList . fmap compactify . sequence
911 <$> many1 (listItem orderedListStart)
911 <$> many1 (listItem orderedListStart)
912
912
913bulletListStart' :: Monad m => Maybe Int -> OrgParser m Int
913bulletListStart' :: Monad m => Maybe Int -> OrgParser m Int
src/Text/Pandoc/Readers/RST.hs+2−2
@@ -574,11 +574,11 @@ orderedList :: PandocMonad m => RSTParser m Blocks
574orderedList = try $ do
574orderedList = try $ do
575 (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
575 (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
576 items <- many1 (listItem (orderedListStart style delim))
576 items <- many1 (listItem (orderedListStart style delim))
577− let items' = compactify' items
577+ let items' = compactify items
578 return $ B.orderedListWith (start, style, delim) items'
578 return $ B.orderedListWith (start, style, delim) items'
579
579
580bulletList :: PandocMonad m => RSTParser m Blocks
580bulletList :: PandocMonad m => RSTParser m Blocks
581−bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
581+bulletList = B.bulletList . compactify <$> many1 (listItem bulletListStart)
582
582
583--
583--
584-- directive (e.g. comment, container, compound-paragraph)
584-- directive (e.g. comment, container, compound-paragraph)
src/Text/Pandoc/Readers/Txt2Tags.hs+4−4
@@ -37,7 +37,7 @@ import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )
37import Data.Monoid ((<>))
37import Data.Monoid ((<>))
38import Text.Pandoc.Definition
38import Text.Pandoc.Definition
39import Text.Pandoc.Options
39import Text.Pandoc.Options
40−import Text.Pandoc.Shared (escapeURI,compactify', compactify'DL)
40+import Text.Pandoc.Shared (escapeURI,compactify, compactifyDL)
41import Text.Pandoc.Parsing hiding (space, spaces, uri, macro)
41import Text.Pandoc.Parsing hiding (space, spaces, uri, macro)
42import Data.Char (toLower)
42import Data.Char (toLower)
43import Data.List (transpose, intersperse, intercalate)
43import Data.List (transpose, intersperse, intercalate)
@@ -225,16 +225,16 @@ list :: T2T Blocks
225list = choice [bulletList, orderedList, definitionList]
225list = choice [bulletList, orderedList, definitionList]
226
226
227bulletList :: T2T Blocks
227bulletList :: T2T Blocks
228−bulletList = B.bulletList . compactify'
228+bulletList = B.bulletList . compactify
229 <$> many1 (listItem bulletListStart parseBlocks)
229 <$> many1 (listItem bulletListStart parseBlocks)
230
230
231orderedList :: T2T Blocks
231orderedList :: T2T Blocks
232−orderedList = B.orderedList . compactify'
232+orderedList = B.orderedList . compactify
233 <$> many1 (listItem orderedListStart parseBlocks)
233 <$> many1 (listItem orderedListStart parseBlocks)
234
234
235definitionList :: T2T Blocks
235definitionList :: T2T Blocks
236definitionList = try $ do
236definitionList = try $ do
237− B.definitionList . compactify'DL <$>
237+ B.definitionList . compactifyDL <$>
238 many1 (listItem definitionListStart definitionListEnd)
238 many1 (listItem definitionListStart definitionListEnd)
239
239
240definitionListEnd :: T2T (Inlines, [Blocks])
240definitionListEnd :: T2T (Inlines, [Blocks])
src/Text/Pandoc/Shared.hs+8−8
@@ -59,8 +59,8 @@ module Text.Pandoc.Shared (
59 deNote,
59 deNote,
60 stringify,
60 stringify,
61 capitalize,
61 capitalize,
62− compactify',
62+ compactify,
63− compactify'DL,
63+ compactifyDL,
64 linesToPara,
64 linesToPara,
65 Element (..),
65 Element (..),
66 hierarchicalize,
66 hierarchicalize,
@@ -434,10 +434,10 @@ capitalize = walk go
434-- | Change final list item from @Para@ to @Plain@ if the list contains
434-- | Change final list item from @Para@ to @Plain@ if the list contains
435-- no other @Para@ blocks. Like compactify, but operates on @Blocks@ rather
435-- no other @Para@ blocks. Like compactify, but operates on @Blocks@ rather
436-- than @[Block]@.
436-- than @[Block]@.
437−compactify' :: [Blocks] -- ^ List of list items (each a list of blocks)
437+compactify :: [Blocks] -- ^ List of list items (each a list of blocks)
438 -> [Blocks]
438 -> [Blocks]
439−compactify' [] = []
439+compactify [] = []
440−compactify' items =
440+compactify items =
441 let (others, final) = (init items, last items)
441 let (others, final) = (init items, last items)
442 in case reverse (B.toList final) of
442 in case reverse (B.toList final) of
443 (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
443 (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
@@ -446,9 +446,9 @@ compactify' items =
446 _ -> items
446 _ -> items
447 _ -> items
447 _ -> items
448
448
449−-- | Like @compactify'@, but acts on items of definition lists.
449+-- | Like @compactify@, but acts on items of definition lists.
450−compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
450+compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
451−compactify'DL items =
451+compactifyDL items =
452 let defs = concatMap snd items
452 let defs = concatMap snd items
453 in case reverse (concatMap B.toList defs) of
453 in case reverse (concatMap B.toList defs) of
454 (Para x:xs)
454 (Para x:xs)
tests/Tests/Shared.hs+4−4
@@ -9,11 +9,11 @@ import Text.Pandoc.Builder
9import System.FilePath.Posix (joinPath)
9import System.FilePath.Posix (joinPath)
10
10
11tests :: [Test]
11tests :: [Test]
12−tests = [ testGroup "compactify'DL"
12+tests = [ testGroup "compactifyDL"
13− [ testCase "compactify'DL with empty def" $
13+ [ testCase "compactifyDL with empty def" $
14− assertBool "compactify'DL"
14+ assertBool "compactifyDL"
15 (let x = [(str "word", [para (str "def"), mempty])]
15 (let x = [(str "word", [para (str "def"), mempty])]
16− in compactify'DL x == x)
16+ in compactifyDL x == x)
17 ]
17 ]
18 , testGroup "collapseFilePath" testCollapse
18 , testGroup "collapseFilePath" testCollapse
19 ]
19 ]