git.iko.soy/typeable/pandoc
on master help sign in
Shared: rename compactify', compactify'DL -> compactify, compactifyDL.
commit5156a4fe3c2438eeb0caa4a85e8adfdbea94e59d authorJohn MacFarlane <jgm@berkeley.edu> dateFri 27 Jan 2017, 21:36 (10 years ago) parent56f74cb
8 files changed+29−29
src/Text/Pandoc/Parsing.hs+1−1 src/Text/Pandoc/Readers/Markdown.hs+4−4 src/Text/Pandoc/Readers/Odt/ContentReader.hs+2−2 src/Text/Pandoc/Readers/Org/Blocks.hs+4−4 src/Text/Pandoc/Readers/RST.hs+2−2 src/Text/Pandoc/Readers/Txt2Tags.hs+4−4 src/Text/Pandoc/Shared.hs+8−8 tests/Tests/Shared.hs+4−4
src/Text/Pandoc/Parsing.hs+1−1
@@ -868,7 +868,7 @@ removeOneLeadingSpace xs =
868868 startsWithSpace (y:_) = y == ' '
869869
870870compactifyCell :: Blocks -> Blocks
871−compactifyCell bs = head $ compactify' [bs]
871+compactifyCell bs = head $ compactify [bs]
872872
873873-- | Parse footer for a grid table.
874874gridTableFooter :: Stream s m Char => ParserT s ParserState m [Char]
src/Text/Pandoc/Readers/Markdown.hs+4−4
@@ -909,12 +909,12 @@ orderedList = try $ do
909909 atMostSpaces (tabStop - (endpos - startpos))
910910 return res )
911911 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
913913
914914bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
915915bulletList = do
916916 items <- fmap sequence $ many1 $ listItem bulletListStart
917− return $ B.bulletList <$> fmap compactify' items
917+ return $ B.bulletList <$> fmap compactify items
918918
919919-- definition lists
920920
@@ -972,7 +972,7 @@ compactDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
972972compactDefinitionList = do
973973 guardEnabled Ext_compact_definition_lists
974974 items <- fmap sequence $ many1 $ definitionListItem True
975− return $ B.definitionList <$> fmap compactify'DL items
975+ return $ B.definitionList <$> fmap compactifyDL items
976976
977977normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
978978normalDefinitionList = do
@@ -1349,7 +1349,7 @@ gridTableRow indices = do
13491349 colLines <- many1 (gridTableRawLine indices)
13501350 let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
13511351 transpose colLines
1352− fmap compactify' <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
1352+ fmap compactify <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
13531353
13541354removeOneLeadingSpace :: [String] -> [String]
13551355removeOneLeadingSpace xs =
src/Text/Pandoc/Readers/Odt/ContentReader.hs+2−2
@@ -663,7 +663,7 @@ read_list = matchingElement NsText "list"
663663--
664664read_list_item :: ElementMatcher [Blocks]
665665read_list_item = matchingElement NsText "list-item"
666− $ liftA (compactify'.(:[]))
666+ $ liftA (compactify.(:[]))
667667 ( matchChildContent' [ read_paragraph
668668 , read_header
669669 , read_list
@@ -749,7 +749,7 @@ read_table_row = matchingElement NsTable "table-row"
749749--
750750read_table_cell :: ElementMatcher [Blocks]
751751read_table_cell = matchingElement NsTable "table-cell"
752− $ liftA (compactify'.(:[]))
752+ $ liftA (compactify.(:[]))
753753 $ matchChildContent' [ read_paragraph
754754 ]
755755
src/Text/Pandoc/Readers/Org/Blocks.hs+4−4
@@ -47,7 +47,7 @@ import Text.Pandoc.Builder ( Inlines, Blocks )
4747import Text.Pandoc.Class (PandocMonad)
4848import Text.Pandoc.Definition
4949import Text.Pandoc.Options
50−import Text.Pandoc.Shared ( compactify', compactify'DL, safeRead )
50+import Text.Pandoc.Shared ( compactify, compactifyDL, safeRead )
5151
5252import Control.Monad ( foldM, guard, mzero, void )
5353import Data.Char ( isSpace, toLower, toUpper)
@@ -898,16 +898,16 @@ list = choice [ definitionList, bulletList, orderedList ] <?> "list"
898898
899899definitionList :: PandocMonad m => OrgParser m (F Blocks)
900900definitionList = try $ do n <- lookAhead (bulletListStart' Nothing)
901− fmap B.definitionList . fmap compactify'DL . sequence
901+ fmap B.definitionList . fmap compactifyDL . sequence
902902 <$> many1 (definitionListItem $ bulletListStart' (Just n))
903903
904904bulletList :: PandocMonad m => OrgParser m (F Blocks)
905905bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)
906− fmap B.bulletList . fmap compactify' . sequence
906+ fmap B.bulletList . fmap compactify . sequence
907907 <$> many1 (listItem (bulletListStart' $ Just n))
908908
909909orderedList :: PandocMonad m => OrgParser m (F Blocks)
910−orderedList = fmap B.orderedList . fmap compactify' . sequence
910+orderedList = fmap B.orderedList . fmap compactify . sequence
911911 <$> many1 (listItem orderedListStart)
912912
913913bulletListStart' :: 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
574574orderedList = try $ do
575575 (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
576576 items <- many1 (listItem (orderedListStart style delim))
577− let items' = compactify' items
577+ let items' = compactify items
578578 return $ B.orderedListWith (start, style, delim) items'
579579
580580bulletList :: PandocMonad m => RSTParser m Blocks
581−bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
581+bulletList = B.bulletList . compactify <$> many1 (listItem bulletListStart)
582582
583583--
584584-- 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 )
3737import Data.Monoid ((<>))
3838import Text.Pandoc.Definition
3939import Text.Pandoc.Options
40−import Text.Pandoc.Shared (escapeURI,compactify', compactify'DL)
40+import Text.Pandoc.Shared (escapeURI,compactify, compactifyDL)
4141import Text.Pandoc.Parsing hiding (space, spaces, uri, macro)
4242import Data.Char (toLower)
4343import Data.List (transpose, intersperse, intercalate)
@@ -225,16 +225,16 @@ list :: T2T Blocks
225225list = choice [bulletList, orderedList, definitionList]
226226
227227bulletList :: T2T Blocks
228−bulletList = B.bulletList . compactify'
228+bulletList = B.bulletList . compactify
229229 <$> many1 (listItem bulletListStart parseBlocks)
230230
231231orderedList :: T2T Blocks
232−orderedList = B.orderedList . compactify'
232+orderedList = B.orderedList . compactify
233233 <$> many1 (listItem orderedListStart parseBlocks)
234234
235235definitionList :: T2T Blocks
236236definitionList = try $ do
237− B.definitionList . compactify'DL <$>
237+ B.definitionList . compactifyDL <$>
238238 many1 (listItem definitionListStart definitionListEnd)
239239
240240definitionListEnd :: T2T (Inlines, [Blocks])
src/Text/Pandoc/Shared.hs+8−8
@@ -59,8 +59,8 @@ module Text.Pandoc.Shared (
5959 deNote,
6060 stringify,
6161 capitalize,
62− compactify',
63− compactify'DL,
62+ compactify,
63+ compactifyDL,
6464 linesToPara,
6565 Element (..),
6666 hierarchicalize,
@@ -434,10 +434,10 @@ capitalize = walk go
434434-- | Change final list item from @Para@ to @Plain@ if the list contains
435435-- no other @Para@ blocks. Like compactify, but operates on @Blocks@ rather
436436-- 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)
438438 -> [Blocks]
439−compactify' [] = []
440−compactify' items =
439+compactify [] = []
440+compactify items =
441441 let (others, final) = (init items, last items)
442442 in case reverse (B.toList final) of
443443 (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
@@ -446,9 +446,9 @@ compactify' items =
446446 _ -> items
447447 _ -> items
448448
449−-- | Like @compactify'@, but acts on items of definition lists.
450−compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
451−compactify'DL items =
449+-- | Like @compactify@, but acts on items of definition lists.
450+compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
451+compactifyDL items =
452452 let defs = concatMap snd items
453453 in case reverse (concatMap B.toList defs) of
454454 (Para x:xs)
tests/Tests/Shared.hs+4−4
@@ -9,11 +9,11 @@ import Text.Pandoc.Builder
99import System.FilePath.Posix (joinPath)
1010
1111tests :: [Test]
12−tests = [ testGroup "compactify'DL"
13− [ testCase "compactify'DL with empty def" $
14− assertBool "compactify'DL"
12+tests = [ testGroup "compactifyDL"
13+ [ testCase "compactifyDL with empty def" $
14+ assertBool "compactifyDL"
1515 (let x = [(str "word", [para (str "def"), mempty])]
16− in compactify'DL x == x)
16+ in compactifyDL x == x)
1717 ]
1818 , testGroup "collapseFilePath" testCollapse
1919 ]