@@ -33,7 +33,6 @@ module Text.Pandoc.Shared (
3333 splitBy,
3434 splitByIndices,
3535 substitute,
36− joinWithSep,
3736 -- * Text processing
3837 backslashEscapes,
3938 escapeStringUsing,
@@ -110,7 +109,7 @@ import Text.PrettyPrint.HughesPJ ( Doc, fsep, ($$), (<>), empty, isEmpty, text )
110109import qualified Text.PrettyPrint.HughesPJ as PP
111110import Text.Pandoc.CharacterReferences ( characterReference )
112111import Data.Char ( toLower, toUpper, ord, isLower, isUpper )
113−import Data.List ( find, isPrefixOf )
112+import Data.List ( find, isPrefixOf, intercalate )
114113import Control.Monad ( join )
115114import Network.URI ( parseURI, URI (..), isAllowedInURI )
116115import System.Directory
@@ -145,13 +144,6 @@ substitute target replacement lst =
145144 then replacement ++ (substitute target replacement $ drop (length target) lst)
146145 else (head lst):(substitute target replacement $ tail lst)
147146
148−-- | Joins a list of lists, separated by another list.
149−joinWithSep :: [a] -- ^ List to use as separator
150− -> [[a]] -- ^ Lists to join
151− -> [a]
152−joinWithSep _ [] = []
153−joinWithSep sep lst = foldr1 (\a b -> a ++ sep ++ b) lst
154−
155147--
156148-- Text processing
157149--
@@ -441,7 +433,7 @@ domain :: GenParser Char st [Char]
441433domain = do
442434 first <- many1 domainChar
443435 dom <- many1 $ try (char '.' >> many1 domainChar )
444− return $ joinWithSep "." (first:dom)
436+ return $ intercalate "." (first:dom)
445437
446438-- | Parses an email address; returns string.
447439emailAddress :: GenParser Char st [Char]
@@ -732,7 +724,7 @@ indentBy num first str =
732724 let (firstLine:restLines) = lines str
733725 firstLineIndent = num + first
734726 in (replicate firstLineIndent ' ') ++ firstLine ++ "\n" ++
735− (joinWithSep "\n" $ map ((replicate num ' ') ++ ) restLines)
727+ (intercalate "\n" $ map ((replicate num ' ') ++ ) restLines)
736728
737729-- | Prettyprint list of Pandoc blocks elements.
738730prettyBlockList :: Int -- ^ Number of spaces to indent list of blocks
@@ -740,7 +732,7 @@ prettyBlockList :: Int -- ^ Number of spaces to indent list of blocks
740732 -> String
741733prettyBlockList indent [] = indentBy indent 0 "[]"
742734prettyBlockList indent blocks = indentBy indent (-2) $ "[ " ++
743− (joinWithSep "\n, " (map prettyBlock blocks)) ++ " ]"
735+ (intercalate "\n, " (map prettyBlock blocks)) ++ " ]"
744736
745737-- | Prettyprint Pandoc block element.
746738prettyBlock :: Block -> String
@@ -748,20 +740,20 @@ prettyBlock (BlockQuote blocks) = "BlockQuote\n " ++
748740 (prettyBlockList 2 blocks)
749741prettyBlock (OrderedList attribs blockLists) =
750742 "OrderedList " ++ show attribs ++ "\n" ++ indentBy 2 0 ("[ " ++
751− (joinWithSep ", " $ map (\blocks -> prettyBlockList 2 blocks)
743+ (intercalate ", " $ map (\blocks -> prettyBlockList 2 blocks)
752744 blockLists)) ++ " ]"
753745prettyBlock (BulletList blockLists) = "BulletList\n" ++
754− indentBy 2 0 ("[ " ++ (joinWithSep ", "
746+ indentBy 2 0 ("[ " ++ (intercalate ", "
755747 (map (\blocks -> prettyBlockList 2 blocks) blockLists))) ++ " ]"
756748prettyBlock (DefinitionList blockLists) = "DefinitionList\n" ++
757− indentBy 2 0 ("[" ++ (joinWithSep ",\n"
749+ indentBy 2 0 ("[" ++ (intercalate ",\n"
758750 (map (\(term, blocks) -> " (" ++ show term ++ ",\n" ++
759751 indentBy 1 2 (prettyBlockList 2 blocks) ++ " )") blockLists))) ++ " ]"
760752prettyBlock (Table caption aligns widths header rows) =
761753 "Table " ++ show caption ++ " " ++ show aligns ++ " " ++
762754 show widths ++ "\n" ++ prettyRow header ++ " [\n" ++
763− (joinWithSep ",\n" (map prettyRow rows)) ++ " ]"
764− where prettyRow cols = indentBy 2 0 ("[ " ++ (joinWithSep ", "
755+ (intercalate ",\n" (map prettyRow rows)) ++ " ]"
756+ where prettyRow cols = indentBy 2 0 ("[ " ++ (intercalate ", "
765757 (map (\blocks -> prettyBlockList 2 blocks)
766758 cols))) ++ " ]"
767759prettyBlock block = show block