git.iko.soy/typeable/pandoc
on master help sign in
hlint code improvements.
b8ffd83John MacFarlane
data/templates/default.ms+1−1
@@ -40,8 +40,8 @@ $endif$
40.nr FL \n[LL]
40.nr FL \n[LL]
41.\" footnote point size
41.\" footnote point size
42.nr FPS (\n[PS] - 2000)
42.nr FPS (\n[PS] - 2000)
43−.\" paper size
44$if(papersize)$
43$if(papersize)$
44+.\" paper size
45.ds paper $papersize$
45.ds paper $papersize$
46$endif$
46$endif$
47.\" color used for strikeout
47.\" color used for strikeout
src/Text/Pandoc/Class.hs+3−3
@@ -142,11 +142,11 @@ import qualified System.Environment as IO (lookupEnv)
142import System.FilePath.Glob (match, compile)
142import System.FilePath.Glob (match, compile)
143import System.Directory (createDirectoryIfMissing, getDirectoryContents,
143import System.Directory (createDirectoryIfMissing, getDirectoryContents,
144 doesDirectoryExist)
144 doesDirectoryExist)
145−import System.FilePath ((</>), (<.>), takeDirectory,
145+import System.FilePath
146− takeExtension, dropExtension, isRelative, normalise)
146+ ((</>), (<.>), takeDirectory, takeExtension, dropExtension,
147+ isRelative, normalise, splitDirectories)
147import qualified System.FilePath.Glob as IO (glob)
148import qualified System.FilePath.Glob as IO (glob)
148import qualified System.FilePath.Posix as Posix
149import qualified System.FilePath.Posix as Posix
149−import System.FilePath (splitDirectories)
150import qualified System.Directory as IO (getModificationTime)
150import qualified System.Directory as IO (getModificationTime)
151import Control.Monad as M (fail)
151import Control.Monad as M (fail)
152import Control.Monad.State.Strict
152import Control.Monad.State.Strict
src/Text/Pandoc/Filter.hs+1−1
@@ -51,7 +51,7 @@ applyFilters :: ReaderOptions
51 -> [String]
51 -> [String]
52 -> Pandoc
52 -> Pandoc
53 -> PandocIO Pandoc
53 -> PandocIO Pandoc
54−applyFilters ropts filters args d = do
54+applyFilters ropts filters args d =
55 foldrM ($) d $ map applyFilter filters
55 foldrM ($) d $ map applyFilter filters
56 where
56 where
57 applyFilter (JSONFilter f) = JSONFilter.apply ropts args f
57 applyFilter (JSONFilter f) = JSONFilter.apply ropts args f
src/Text/Pandoc/Lua.hs+1−1
@@ -65,7 +65,7 @@ runLuaFilter' ropts filterPath format pd = do
65 newtop <- Lua.gettop
65 newtop <- Lua.gettop
66 -- Use the returned filters, or the implicitly defined global filter if
66 -- Use the returned filters, or the implicitly defined global filter if
67 -- nothing was returned.
67 -- nothing was returned.
68− luaFilters <- if (newtop - top >= 1)
68+ luaFilters <- if newtop - top >= 1
69 then peek (-1)
69 then peek (-1)
70 else Lua.getglobal "_G" *> fmap (:[]) popValue
70 else Lua.getglobal "_G" *> fmap (:[]) popValue
71 runAll luaFilters pd
71 runAll luaFilters pd
src/Text/Pandoc/Lua/Packages.hs−1
@@ -113,4 +113,3 @@ dataDirScript datadir moduleFile = do
113 return $ case res of
113 return $ case res of
114 Left _ -> Nothing
114 Left _ -> Nothing
115 Right s -> Just (unpack s)
115 Right s -> Just (unpack s)
116−
src/Text/Pandoc/Lua/StackInstances.hs−1
@@ -383,4 +383,3 @@ instance ToLuaStack ReaderOptions where
383 LuaUtil.addValue "defaultImageExtension" defaultImageExtension
383 LuaUtil.addValue "defaultImageExtension" defaultImageExtension
384 LuaUtil.addValue "trackChanges" trackChanges
384 LuaUtil.addValue "trackChanges" trackChanges
385 LuaUtil.addValue "stripComments" stripComments
385 LuaUtil.addValue "stripComments" stripComments
386−
src/Text/Pandoc/Parsing.hs+10−14
@@ -189,12 +189,12 @@ where
189
189
190import Control.Monad.Identity
190import Control.Monad.Identity
191import Control.Monad.Reader
191import Control.Monad.Reader
192−import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isHexDigit, isPunctuation, isSpace,
192+import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isHexDigit,
193− ord, toLower, toUpper)
193+ isPunctuation, isSpace, ord, toLower, toUpper)
194import Data.Default
194import Data.Default
195import Data.List (intercalate, isSuffixOf, transpose)
195import Data.List (intercalate, isSuffixOf, transpose)
196import qualified Data.Map as M
196import qualified Data.Map as M
197−import Data.Maybe (mapMaybe)
197+import Data.Maybe (mapMaybe, fromMaybe)
198import Data.Monoid ((<>))
198import Data.Monoid ((<>))
199import qualified Data.Set as Set
199import qualified Data.Set as Set
200import Data.Text (Text)
200import Data.Text (Text)
@@ -304,7 +304,7 @@ indentWith :: Stream s m Char
304 => Int -> ParserT s st m [Char]
304 => Int -> ParserT s st m [Char]
305indentWith num = do
305indentWith num = do
306 tabStop <- getOption readerTabStop
306 tabStop <- getOption readerTabStop
307− if (num < tabStop)
307+ if num < tabStop
308 then count num (char ' ')
308 then count num (char ' ')
309 else choice [ try (count num (char ' '))
309 else choice [ try (count num (char ' '))
310 , try (char '\t' >> indentWith (num - tabStop)) ]
310 , try (char '\t' >> indentWith (num - tabStop)) ]
@@ -573,7 +573,7 @@ uri = try $ do
573 let uriChunk = skipMany1 wordChar
573 let uriChunk = skipMany1 wordChar
574 <|> percentEscaped
574 <|> percentEscaped
575 <|> entity
575 <|> entity
576− <|> (try $ punct >>
576+ <|> try (punct >>
577 lookAhead (void (satisfy isWordChar) <|> percentEscaped))
577 lookAhead (void (satisfy isWordChar) <|> percentEscaped))
578 str <- snd <$> withRaw (skipMany1 ( () <$
578 str <- snd <$> withRaw (skipMany1 ( () <$
579 (enclosed (char '(') (char ')') uriChunk
579 (enclosed (char '(') (char ')') uriChunk
@@ -755,7 +755,7 @@ romanOne = (char 'i' >> return (LowerRoman, 1)) <|>
755
755
756-- | Parses an ordered list marker and returns list attributes.
756-- | Parses an ordered list marker and returns list attributes.
757anyOrderedListMarker :: Stream s m Char => ParserT s ParserState m ListAttributes
757anyOrderedListMarker :: Stream s m Char => ParserT s ParserState m ListAttributes
758−anyOrderedListMarker = choice $
758+anyOrderedListMarker = choice
759 [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens],
759 [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens],
760 numParser <- [decimal, exampleNum, defaultNum, romanOne,
760 numParser <- [decimal, exampleNum, defaultNum, romanOne,
761 lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
761 lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
@@ -896,7 +896,7 @@ widthsFromIndices numColumns' indices =
896 quotient = if totLength > numColumns
896 quotient = if totLength > numColumns
897 then fromIntegral totLength
897 then fromIntegral totLength
898 else fromIntegral numColumns
898 else fromIntegral numColumns
899− fracs = map (\l -> (fromIntegral l) / quotient) lengths in
899+ fracs = map (\l -> fromIntegral l / quotient) lengths in
900 tail fracs
900 tail fracs
901
901
902---
902---
@@ -977,7 +977,7 @@ gridTableHeader headless blocks = try $ do
977 then replicate (length underDashes) ""
977 then replicate (length underDashes) ""
978 else map (unlines . map trim) $ transpose
978 else map (unlines . map trim) $ transpose
979 $ map (gridTableSplitLine indices) rawContent
979 $ map (gridTableSplitLine indices) rawContent
980− heads <- fmap sequence $ mapM (parseFromString blocks . trim) rawHeads
980+ heads <- sequence <$> mapM (parseFromString blocks . trim) rawHeads
981 return (heads, aligns, indices)
981 return (heads, aligns, indices)
982
982
983gridTableRawLine :: Stream s m Char => [Int] -> ParserT s st m [String]
983gridTableRawLine :: Stream s m Char => [Int] -> ParserT s st m [String]
@@ -1323,9 +1323,7 @@ failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t)
1323 -> ParserT s st m ()
1323 -> ParserT s st m ()
1324failIfInQuoteContext context = do
1324failIfInQuoteContext context = do
1325 context' <- getQuoteContext
1325 context' <- getQuoteContext
1326− if context' == context
1327− then fail "already inside quotes"
1326+ when (context' == context) $ fail "already inside quotes"
1328− else return ()
1329
1327
1330charOrRef :: Stream s m Char => String -> ParserT s st m Char
1328charOrRef :: Stream s m Char => String -> ParserT s st m Char
1331charOrRef cs =
1329charOrRef cs =
@@ -1418,9 +1416,7 @@ a <+?> b = a >>= flip fmap (try b <|> return mempty) . (<>)
1418extractIdClass :: Attr -> Attr
1416extractIdClass :: Attr -> Attr
1419extractIdClass (ident, cls, kvs) = (ident', cls', kvs')
1417extractIdClass (ident, cls, kvs) = (ident', cls', kvs')
1420 where
1418 where
1421− ident' = case lookup "id" kvs of
1419+ ident' = fromMaybe ident (lookup "id" kvs)
1422− Just v -> v
1423− Nothing -> ident
1424 cls' = case lookup "class" kvs of
1420 cls' = case lookup "class" kvs of
1425 Just cl -> words cl
1421 Just cl -> words cl
1426 Nothing -> cls
1422 Nothing -> cls
src/Text/Pandoc/Readers/Docx.hs+7−9
@@ -81,7 +81,7 @@ import qualified Data.ByteString.Lazy as B
81import Data.Default (Default)
81import Data.Default (Default)
82import Data.List (delete, intersect)
82import Data.List (delete, intersect)
83import qualified Data.Map as M
83import qualified Data.Map as M
84−import Data.Maybe (isJust)
84+import Data.Maybe (isJust, fromMaybe)
85import Data.Sequence (ViewL (..), viewl)
85import Data.Sequence (ViewL (..), viewl)
86import qualified Data.Sequence as Seq
86import qualified Data.Sequence as Seq
87import qualified Data.Set as Set
87import qualified Data.Set as Set
@@ -187,7 +187,7 @@ bodyPartsToMeta' :: PandocMonad m => [BodyPart] -> DocxContext m (M.Map String M
187bodyPartsToMeta' [] = return M.empty
187bodyPartsToMeta' [] = return M.empty
188bodyPartsToMeta' (bp : bps)
188bodyPartsToMeta' (bp : bps)
189 | (Paragraph pPr parParts) <- bp
189 | (Paragraph pPr parParts) <- bp
190− , (c : _)<- intersect (pStyle pPr) (M.keys metaStyles)
190+ , (c : _)<- (pStyle pPr) `intersect` (M.keys metaStyles)
191 , (Just metaField) <- M.lookup c metaStyles = do
191 , (Just metaField) <- M.lookup c metaStyles = do
192 inlines <- smushInlines <$> mapM parPartToInlines parParts
192 inlines <- smushInlines <$> mapM parPartToInlines parParts
193 remaining <- bodyPartsToMeta' bps
193 remaining <- bodyPartsToMeta' bps
@@ -340,7 +340,7 @@ blocksToInlinesWarn cmtId blks = do
340 notParaOrPlain (Para _) = False
340 notParaOrPlain (Para _) = False
341 notParaOrPlain (Plain _) = False
341 notParaOrPlain (Plain _) = False
342 notParaOrPlain _ = True
342 notParaOrPlain _ = True
343− unless (null $ filter notParaOrPlain blkList) $
343+ unless ( not (any notParaOrPlain blkList)) $
344 lift $ P.report $ DocxParserWarning $
344 lift $ P.report $ DocxParserWarning $
345 "Docx comment " ++ cmtId ++ " will not retain formatting"
345 "Docx comment " ++ cmtId ++ " will not retain formatting"
346 return $ blocksToInlines' blkList
346 return $ blocksToInlines' blkList
@@ -351,7 +351,7 @@ blocksToInlinesWarn cmtId blks = do
351parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
351parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
352parPartToInlines parPart =
352parPartToInlines parPart =
353 case parPart of
353 case parPart of
354− (BookMark _ anchor) | not $ anchor `elem` dummyAnchors -> do
354+ (BookMark _ anchor) | notElem anchor dummyAnchors -> do
355 inHdrBool <- asks docxInHeaderBlock
355 inHdrBool <- asks docxInHeaderBlock
356 ils <- parPartToInlines' parPart
356 ils <- parPartToInlines' parPart
357 immedPrevAnchor <- gets docxImmedPrevAnchor
357 immedPrevAnchor <- gets docxImmedPrevAnchor
@@ -444,9 +444,9 @@ parPartToInlines' (ExternalHyperLink target runs) = do
444 return $ link target "" ils
444 return $ link target "" ils
445parPartToInlines' (PlainOMath exps) =
445parPartToInlines' (PlainOMath exps) =
446 return $ math $ writeTeX exps
446 return $ math $ writeTeX exps
447−parPartToInlines' (SmartTag runs) = do
447+parPartToInlines' (SmartTag runs) =
448 smushInlines <$> mapM runToInlines runs
448 smushInlines <$> mapM runToInlines runs
449−parPartToInlines' (Field info runs) = do
449+parPartToInlines' (Field info runs) =
450 case info of
450 case info of
451 HyperlinkField url -> parPartToInlines' $ ExternalHyperLink url runs
451 HyperlinkField url -> parPartToInlines' $ ExternalHyperLink url runs
452 UnknownField -> smushInlines <$> mapM runToInlines runs
452 UnknownField -> smushInlines <$> mapM runToInlines runs
@@ -626,9 +626,7 @@ bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do
626 (_, fmt,txt, startFromLevelInfo) = levelInfo
626 (_, fmt,txt, startFromLevelInfo) = levelInfo
627 start = case startFromState of
627 start = case startFromState of
628 Just n -> n + 1
628 Just n -> n + 1
629− Nothing -> case startFromLevelInfo of
629+ Nothing -> fromMaybe 1 startFromLevelInfo
630− Just n' -> n'
631− Nothing -> 1
632 kvs = [ ("level", lvl)
630 kvs = [ ("level", lvl)
633 , ("num-id", numId)
631 , ("num-id", numId)
634 , ("format", fmt)
632 , ("format", fmt)
src/Text/Pandoc/Readers/Docx/Fields.hs+4−4
@@ -46,7 +46,7 @@ parseFieldInfo = parse fieldInfo ""
46
46
47fieldInfo :: Parser FieldInfo
47fieldInfo :: Parser FieldInfo
48fieldInfo =
48fieldInfo =
49− (try $ HyperlinkField <$> hyperlink)
49+ try (HyperlinkField <$> hyperlink)
50 <|>
50 <|>
51 return UnknownField
51 return UnknownField
52
52
@@ -54,7 +54,7 @@ escapedQuote :: Parser String
54escapedQuote = string "\\\""
54escapedQuote = string "\\\""
55
55
56inQuotes :: Parser String
56inQuotes :: Parser String
57−inQuotes = do
57+inQuotes =
58 (try escapedQuote) <|> (anyChar >>= (\c -> return [c]))
58 (try escapedQuote) <|> (anyChar >>= (\c -> return [c]))
59
59
60quotedString :: Parser String
60quotedString :: Parser String
@@ -63,7 +63,7 @@ quotedString = do
63 concat <$> manyTill inQuotes (try (char '"'))
63 concat <$> manyTill inQuotes (try (char '"'))
64
64
65unquotedString :: Parser String
65unquotedString :: Parser String
66−unquotedString = manyTill anyChar (try (space))
66+unquotedString = manyTill anyChar (try space)
67
67
68fieldArgument :: Parser String
68fieldArgument :: Parser String
69fieldArgument = quotedString <|> unquotedString
69fieldArgument = quotedString <|> unquotedString
@@ -82,7 +82,7 @@ hyperlink = do
82 string "HYPERLINK"
82 string "HYPERLINK"
83 spaces
83 spaces
84 farg <- fieldArgument
84 farg <- fieldArgument
85− switches <- (spaces *> many hyperlinkSwitch)
85+ switches <- spaces *> many hyperlinkSwitch
86 let url = case switches of
86 let url = case switches of
87 ("\\l", s) : _ -> farg ++ ('#': s)
87 ("\\l", s) : _ -> farg ++ ('#': s)
88 _ -> farg
88 _ -> farg
src/Text/Pandoc/Readers/Docx/Lists.hs+4−4
@@ -44,14 +44,14 @@ isListItem (Div (_, classes, _) _) | "list-item" `elem` classes = True
44isListItem _ = False
44isListItem _ = False
45
45
46getLevel :: Block -> Maybe Integer
46getLevel :: Block -> Maybe Integer
47−getLevel (Div (_, _, kvs) _) = fmap read $ lookup "level" kvs
47+getLevel (Div (_, _, kvs) _) = read <$> lookup "level" kvs
48getLevel _ = Nothing
48getLevel _ = Nothing
49
49
50getLevelN :: Block -> Integer
50getLevelN :: Block -> Integer
51getLevelN b = fromMaybe (-1) (getLevel b)
51getLevelN b = fromMaybe (-1) (getLevel b)
52
52
53getNumId :: Block -> Maybe Integer
53getNumId :: Block -> Maybe Integer
54−getNumId (Div (_, _, kvs) _) = fmap read $ lookup "num-id" kvs
54+getNumId (Div (_, _, kvs) _) = read <$> lookup "num-id" kvs
55getNumId _ = Nothing
55getNumId _ = Nothing
56
56
57getNumIdN :: Block -> Integer
57getNumIdN :: Block -> Integer
@@ -140,8 +140,8 @@ flatToBullets' num xs@(b : elems)
140 (children, remaining) =
140 (children, remaining) =
141 span
141 span
142 (\b' ->
142 (\b' ->
143− (getLevelN b') > bLevel ||
143+ getLevelN b' > bLevel ||
144− ((getLevelN b') == bLevel && (getNumIdN b') == bNumId))
144+ (getLevelN b' == bLevel && getNumIdN b' == bNumId))
145 xs
145 xs
146 in
146 in
147 case getListType b of
147 case getListType b of
src/Text/Pandoc/Readers/Docx/Parse.hs+4−7
@@ -358,9 +358,7 @@ archiveToDocument zf = do
358 docElem <- maybeToD $ (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
358 docElem <- maybeToD $ (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
359 let namespaces = elemToNameSpaces docElem
359 let namespaces = elemToNameSpaces docElem
360 bodyElem <- maybeToD $ findChildByName namespaces "w" "body" docElem
360 bodyElem <- maybeToD $ findChildByName namespaces "w" "body" docElem
361− let bodyElem' = case walkDocument namespaces bodyElem of
361+ let bodyElem' = fromMaybe bodyElem (walkDocument namespaces bodyElem)
362− Just e -> e
363− Nothing -> bodyElem
364 body <- elemToBody namespaces bodyElem'
362 body <- elemToBody namespaces bodyElem'
365 return $ Document namespaces body
363 return $ Document namespaces body
366
364
@@ -603,7 +601,7 @@ elemToTblLook ns element | isElem ns "w" "tblLook" element =
603 Just bitMask -> testBitMask bitMask 0x020
601 Just bitMask -> testBitMask bitMask 0x020
604 Nothing -> False
602 Nothing -> False
605 in
603 in
606− return $ TblLook{firstRowFormatting = firstRowFmt}
604+ return TblLook{firstRowFormatting = firstRowFmt}
607elemToTblLook _ _ = throwError WrongElem
605elemToTblLook _ _ = throwError WrongElem
608
606
609elemToRow :: NameSpaces -> Element -> D Row
607elemToRow :: NameSpaces -> Element -> D Row
@@ -623,7 +621,7 @@ elemToCell _ _ = throwError WrongElem
623
621
624elemToParIndentation :: NameSpaces -> Element -> Maybe ParIndentation
622elemToParIndentation :: NameSpaces -> Element -> Maybe ParIndentation
625elemToParIndentation ns element | isElem ns "w" "ind" element =
623elemToParIndentation ns element | isElem ns "w" "ind" element =
626− Just $ ParIndentation {
624+ Just ParIndentation {
627 leftParIndent =
625 leftParIndent =
628 findAttrByName ns "w" "left" element >>=
626 findAttrByName ns "w" "left" element >>=
629 stringToInteger
627 stringToInteger
@@ -1173,8 +1171,7 @@ elemToRunElems ns element
1173 let font = do
1171 let font = do
1174 fontElem <- findElement (qualName "rFonts") element
1172 fontElem <- findElement (qualName "rFonts") element
1175 stringToFont =<<
1173 stringToFont =<<
1176− foldr (<|>) Nothing (
1177− map (flip findAttr fontElem . qualName) ["ascii", "hAnsi"])
1174+ foldr ((<|>) . (flip findAttr fontElem . qualName)) Nothing ["ascii", "hAnsi"]
1178 local (setFont font) (mapD (elemToRunElem ns) (elChildren element))
1175 local (setFont font) (mapD (elemToRunElem ns) (elChildren element))
1179elemToRunElems _ _ = throwError WrongElem
1176elemToRunElems _ _ = throwError WrongElem
1180
1177
src/Text/Pandoc/Readers/HTML.hs+4−4
@@ -43,14 +43,14 @@ module Text.Pandoc.Readers.HTML ( readHtml
43 ) where
43 ) where
44
44
45import Control.Applicative ((<|>))
45import Control.Applicative ((<|>))
46−import Control.Arrow ((***))
46+import Control.Arrow (first)
47import Control.Monad (guard, mplus, msum, mzero, unless, void)
47import Control.Monad (guard, mplus, msum, mzero, unless, void)
48import Control.Monad.Except (throwError)
48import Control.Monad.Except (throwError)
49import Control.Monad.Reader (ReaderT, ask, asks, lift, local, runReaderT)
49import Control.Monad.Reader (ReaderT, ask, asks, lift, local, runReaderT)
50import Data.Char (isAlphaNum, isDigit, isLetter)
50import Data.Char (isAlphaNum, isDigit, isLetter)
51import Data.Default (Default (..), def)
51import Data.Default (Default (..), def)
52import Data.Foldable (for_)
52import Data.Foldable (for_)
53−import Data.List (intercalate, isPrefixOf)
53+import Data.List (isPrefixOf)
54import Data.List.Split (wordsBy, splitWhen)
54import Data.List.Split (wordsBy, splitWhen)
55import qualified Data.Map as M
55import qualified Data.Map as M
56import Data.Maybe (fromMaybe, isJust, isNothing)
56import Data.Maybe (fromMaybe, isJust, isNothing)
@@ -777,7 +777,7 @@ pCode = try $ do
777 (TagOpen open attr') <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
777 (TagOpen open attr') <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
778 let attr = toStringAttr attr'
778 let attr = toStringAttr attr'
779 result <- manyTill pAnyTag (pCloses open)
779 result <- manyTill pAnyTag (pCloses open)
780− return $ B.codeWith (mkAttr attr) $ intercalate " " $ lines $ T.unpack $
780+ return $ B.codeWith (mkAttr attr) $ unwords $ lines $ T.unpack $
781 innerText result
781 innerText result
782
782
783pSpan :: PandocMonad m => TagParser m Inlines
783pSpan :: PandocMonad m => TagParser m Inlines
@@ -1227,7 +1227,7 @@ stripPrefixes = map stripPrefix
1227
1227
1228stripPrefix :: Tag Text -> Tag Text
1228stripPrefix :: Tag Text -> Tag Text
1229stripPrefix (TagOpen s as) =
1229stripPrefix (TagOpen s as) =
1230− TagOpen (stripPrefix' s) (map (stripPrefix' *** id) as)
1230+ TagOpen (stripPrefix' s) (map (first stripPrefix') as)
1231stripPrefix (TagClose s) = TagClose (stripPrefix' s)
1231stripPrefix (TagClose s) = TagClose (stripPrefix' s)
1232stripPrefix x = x
1232stripPrefix x = x
1233
1233
src/Text/Pandoc/Readers/JATS.hs−1
@@ -494,4 +494,3 @@ parseInline (Elem e) =
494 "" -> []
494 "" -> []
495 l -> [l]
495 l -> [l]
496 return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e
496 return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e
497−
src/Text/Pandoc/Readers/LaTeX.hs+10−10
@@ -272,7 +272,7 @@ rawLaTeXBlock = do
272 lookAhead (try (char '\\' >> letter))
272 lookAhead (try (char '\\' >> letter))
273 -- we don't want to apply newly defined latex macros to their own
273 -- we don't want to apply newly defined latex macros to their own
274 -- definitions:
274 -- definitions:
275− (snd <$> rawLaTeXParser macroDef)
275+ snd <$> rawLaTeXParser macroDef
276 <|> ((snd <$> rawLaTeXParser (environment <|> blockCommand)) >>= applyMacros)
276 <|> ((snd <$> rawLaTeXParser (environment <|> blockCommand)) >>= applyMacros)
277
277
278rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
278rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
@@ -351,7 +351,7 @@ totoks pos t =
351 Tok pos (Arg i) ("#" <> t1)
351 Tok pos (Arg i) ("#" <> t1)
352 : totoks (incSourceColumn pos (1 + T.length t1)) t2
352 : totoks (incSourceColumn pos (1 + T.length t1)) t2
353 Nothing ->
353 Nothing ->
354− Tok pos Symbol ("#")
354+ Tok pos Symbol "#"
355 : totoks (incSourceColumn pos 1) t2
355 : totoks (incSourceColumn pos 1) t2
356 | c == '^' ->
356 | c == '^' ->
357 case T.uncons rest of
357 case T.uncons rest of
@@ -369,10 +369,10 @@ totoks pos t =
369 | d < '\128' ->
369 | d < '\128' ->
370 Tok pos Esc1 (T.pack ['^','^',d])
370 Tok pos Esc1 (T.pack ['^','^',d])
371 : totoks (incSourceColumn pos 3) rest''
371 : totoks (incSourceColumn pos 3) rest''
372− _ -> Tok pos Symbol ("^") :
372+ _ -> Tok pos Symbol "^" :
373− Tok (incSourceColumn pos 1) Symbol ("^") :
373+ Tok (incSourceColumn pos 1) Symbol "^" :
374 totoks (incSourceColumn pos 2) rest'
374 totoks (incSourceColumn pos 2) rest'
375− _ -> Tok pos Symbol ("^")
375+ _ -> Tok pos Symbol "^"
376 : totoks (incSourceColumn pos 1) rest
376 : totoks (incSourceColumn pos 1) rest
377 | otherwise ->
377 | otherwise ->
378 Tok pos Symbol (T.singleton c) : totoks (incSourceColumn pos 1) rest
378 Tok pos Symbol (T.singleton c) : totoks (incSourceColumn pos 1) rest
@@ -454,7 +454,7 @@ doMacros n = do
454 addTok _ (Tok _ (CtrlSeq x) txt)
454 addTok _ (Tok _ (CtrlSeq x) txt)
455 acc@(Tok _ Word _ : _)
455 acc@(Tok _ Word _ : _)
456 | not (T.null txt) &&
456 | not (T.null txt) &&
457− (isLetter (T.last txt)) =
457+ isLetter (T.last txt) =
458 Tok spos (CtrlSeq x) (txt <> " ") : acc
458 Tok spos (CtrlSeq x) (txt <> " ") : acc
459 addTok _ t acc = setpos spos t : acc
459 addTok _ t acc = setpos spos t : acc
460 ts' <- getInput
460 ts' <- getInput
@@ -1244,7 +1244,7 @@ inlineEnvironments = M.fromList [
1244 ]
1244 ]
1245
1245
1246inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
1246inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
1247−inlineCommands = M.union inlineLanguageCommands $ M.fromList $
1247+inlineCommands = M.union inlineLanguageCommands $ M.fromList
1248 [ ("emph", extractSpaces emph <$> tok)
1248 [ ("emph", extractSpaces emph <$> tok)
1249 , ("textit", extractSpaces emph <$> tok)
1249 , ("textit", extractSpaces emph <$> tok)
1250 , ("textsl", extractSpaces emph <$> tok)
1250 , ("textsl", extractSpaces emph <$> tok)
@@ -1501,7 +1501,7 @@ foreignlanguage :: PandocMonad m => LP m Inlines
1501foreignlanguage = do
1501foreignlanguage = do
1502 babelLang <- T.unpack . untokenize <$> braced
1502 babelLang <- T.unpack . untokenize <$> braced
1503 case babelLangToBCP47 babelLang of
1503 case babelLangToBCP47 babelLang of
1504− Just lang -> spanWith ("", [], [("lang", renderLang $ lang)]) <$> tok
1504+ Just lang -> spanWith ("", [], [("lang", renderLang lang)]) <$> tok
1505 _ -> tok
1505 _ -> tok
1506
1506
1507inlineLanguageCommands :: PandocMonad m => M.Map Text (LP m Inlines)
1507inlineLanguageCommands :: PandocMonad m => M.Map Text (LP m Inlines)
@@ -2021,7 +2021,7 @@ closing = do
2021 return $ para (trimInlines contents) <> sigs
2021 return $ para (trimInlines contents) <> sigs
2022
2022
2023blockCommands :: PandocMonad m => M.Map Text (LP m Blocks)
2023blockCommands :: PandocMonad m => M.Map Text (LP m Blocks)
2024−blockCommands = M.fromList $
2024+blockCommands = M.fromList
2025 [ ("par", mempty <$ skipopts)
2025 [ ("par", mempty <$ skipopts)
2026 , ("parbox", skipopts >> braced >> grouped blocks)
2026 , ("parbox", skipopts >> braced >> grouped blocks)
2027 , ("title", mempty <$ (skipopts *>
2027 , ("title", mempty <$ (skipopts *>
@@ -2444,7 +2444,7 @@ parseAligns = try $ do
2444 spaces
2444 spaces
2445 spec <- braced
2445 spec <- braced
2446 case safeRead ds of
2446 case safeRead ds of
2447− Just n -> do
2447+ Just n ->
2448 getInput >>= setInput . (mconcat (replicate n spec) ++)
2448 getInput >>= setInput . (mconcat (replicate n spec) ++)
2449 Nothing -> fail $ "Could not parse " ++ ds ++ " as number"
2449 Nothing -> fail $ "Could not parse " ++ ds ++ " as number"
2450 bgroup
2450 bgroup
src/Text/Pandoc/Readers/Markdown.hs+28−30
@@ -36,7 +36,7 @@ import Control.Monad
36import Control.Monad.Except (throwError)
36import Control.Monad.Except (throwError)
37import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)
37import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)
38import qualified Data.HashMap.Strict as H
38import qualified Data.HashMap.Strict as H
39−import Data.List (findIndex, intercalate, sortBy, transpose)
39+import Data.List (intercalate, sortBy, transpose, elemIndex)
40import qualified Data.Map as M
40import qualified Data.Map as M
41import Data.Maybe
41import Data.Maybe
42import Data.Monoid ((<>))
42import Data.Monoid ((<>))
@@ -162,16 +162,14 @@ inlinesInBalancedBrackets =
162 stripBracket xs = if last xs == ']' then init xs else xs
162 stripBracket xs = if last xs == ']' then init xs else xs
163 go :: PandocMonad m => Int -> MarkdownParser m ()
163 go :: PandocMonad m => Int -> MarkdownParser m ()
164 go 0 = return ()
164 go 0 = return ()
165− go openBrackets = do
165+ go openBrackets =
166 (() <$ (escapedChar <|>
166 (() <$ (escapedChar <|>
167− code <|>
167+ code <|>
168− rawHtmlInline <|>
168+ rawHtmlInline <|>
169− rawLaTeXInline') >> go openBrackets)
169+ rawLaTeXInline') >> go openBrackets)
170 <|>
170 <|>
171 (do char ']'
171 (do char ']'
172− if openBrackets > 1
173− then go (openBrackets - 1)
172+ Control.Monad.when (openBrackets > 1) $ go (openBrackets - 1))
174− else return ())
175 <|>
173 <|>
176 (char '[' >> go (openBrackets + 1))
174 (char '[' >> go (openBrackets + 1))
177 <|>
175 <|>
@@ -257,13 +255,13 @@ yamlMetaBlock = try $ do
257 v' <- yamlToMeta v
255 v' <- yamlToMeta v
258 let k' = T.unpack k
256 let k' = T.unpack k
259 updateState $ \st -> st{ stateMeta' =
257 updateState $ \st -> st{ stateMeta' =
260− (do m <- stateMeta' st
258+ do m <- stateMeta' st
261− -- if there's already a value, leave it unchanged
259+ -- if there's already a value, leave it unchanged
262− case lookupMeta k' m of
260+ case lookupMeta k' m of
263− Just _ -> return m
261+ Just _ -> return m
264− Nothing -> do
262+ Nothing -> do
265− v'' <- v'
263+ v'' <- v'
266− return $ B.setMeta (T.unpack k) v'' m)}
264+ return $ B.setMeta (T.unpack k) v'' m}
267 ) alist
265 ) alist
268 Right Yaml.Null -> return ()
266 Right Yaml.Null -> return ()
269 Right _ -> do
267 Right _ -> do
@@ -596,7 +594,7 @@ setextHeader = try $ do
596 underlineChar <- oneOf setextHChars
594 underlineChar <- oneOf setextHChars
597 many (char underlineChar)
595 many (char underlineChar)
598 blanklines
596 blanklines
599− let level = fromMaybe 0 (findIndex (== underlineChar) setextHChars) + 1
597+ let level = fromMaybe 0 (elemIndex underlineChar setextHChars) + 1
600 attr' <- registerHeader attr (runF text defaultParserState)
598 attr' <- registerHeader attr (runF text defaultParserState)
601 guardDisabled Ext_implicit_header_references
599 guardDisabled Ext_implicit_header_references
602 <|> registerImplicitHeader raw attr'
600 <|> registerImplicitHeader raw attr'
@@ -851,7 +849,7 @@ orderedListStart mbstydelim = try $ do
851 return (num, style, delim))
849 return (num, style, delim))
852
850
853listStart :: PandocMonad m => MarkdownParser m ()
851listStart :: PandocMonad m => MarkdownParser m ()
854−listStart = bulletListStart <|> (Control.Monad.void (orderedListStart Nothing))
852+listStart = bulletListStart <|> Control.Monad.void (orderedListStart Nothing)
855
853
856listLine :: PandocMonad m => Int -> MarkdownParser m String
854listLine :: PandocMonad m => Int -> MarkdownParser m String
857listLine continuationIndent = try $ do
855listLine continuationIndent = try $ do
@@ -881,7 +879,7 @@ rawListItem fourSpaceRule start = try $ do
881 pos2 <- getPosition
879 pos2 <- getPosition
882 let continuationIndent = if fourSpaceRule
880 let continuationIndent = if fourSpaceRule
883 then 4
881 then 4
884− else (sourceColumn pos2 - sourceColumn pos1)
882+ else sourceColumn pos2 - sourceColumn pos1
885 first <- listLineCommon
883 first <- listLineCommon
886 rest <- many (do notFollowedBy listStart
884 rest <- many (do notFollowedBy listStart
887 notFollowedBy (() <$ codeBlockFenced)
885 notFollowedBy (() <$ codeBlockFenced)
@@ -912,10 +910,10 @@ listContinuation continuationIndent = try $ do
912 return $ concat (x:xs) ++ blanks
910 return $ concat (x:xs) ++ blanks
913
911
914notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
912notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
915−notFollowedByDivCloser = do
913+notFollowedByDivCloser =
916 guardDisabled Ext_fenced_divs <|>
914 guardDisabled Ext_fenced_divs <|>
917− do divLevel <- stateFencedDivLevel <$> getState
915+ do divLevel <- stateFencedDivLevel <$> getState
918− guard (divLevel < 1) <|> notFollowedBy divFenceEnd
916+ guard (divLevel < 1) <|> notFollowedBy divFenceEnd
919
917
920notFollowedByHtmlCloser :: PandocMonad m => MarkdownParser m ()
918notFollowedByHtmlCloser :: PandocMonad m => MarkdownParser m ()
921notFollowedByHtmlCloser = do
919notFollowedByHtmlCloser = do
@@ -1222,7 +1220,7 @@ simpleTableHeader headless = try $ do
1222 if headless
1220 if headless
1223 then lookAhead anyLine
1221 then lookAhead anyLine
1224 else return rawContent
1222 else return rawContent
1225− let aligns = zipWith alignType (map ((: [])) rawHeads) lengths
1223+ let aligns = zipWith alignType (map (: []) rawHeads) lengths
1226 let rawHeads' = if headless
1224 let rawHeads' = if headless
1227 then replicate (length dashes) ""
1225 then replicate (length dashes) ""
1228 else rawHeads
1226 else rawHeads
@@ -1418,11 +1416,11 @@ pipeTableHeaderPart = try $ do
1418 skipMany spaceChar
1416 skipMany spaceChar
1419 let len = length pipe + maybe 0 (const 1) left + maybe 0 (const 1) right
1417 let len = length pipe + maybe 0 (const 1) left + maybe 0 (const 1) right
1420 return
1418 return
1421− ((case (left,right) of
1419+ (case (left,right) of
1422− (Nothing,Nothing) -> AlignDefault
1420+ (Nothing,Nothing) -> AlignDefault
1423− (Just _,Nothing) -> AlignLeft
1421+ (Just _,Nothing) -> AlignLeft
1424− (Nothing,Just _) -> AlignRight
1422+ (Nothing,Just _) -> AlignRight
1425− (Just _,Just _) -> AlignCenter), len)
1423+ (Just _,Just _) -> AlignCenter, len)
1426
1424
1427-- Succeed only if current line contains a pipe.
1425-- Succeed only if current line contains a pipe.
1428scanForPipe :: PandocMonad m => ParserT [Char] st m ()
1426scanForPipe :: PandocMonad m => ParserT [Char] st m ()
@@ -1929,7 +1927,7 @@ rawConTeXtEnvironment = try $ do
1929 (try $ string "\\stop" >> string completion)
1927 (try $ string "\\stop" >> string completion)
1930 return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion
1928 return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion
1931
1929
1932−inBrackets :: PandocMonad m => (ParserT [Char] st m Char) -> ParserT [Char] st m String
1930+inBrackets :: PandocMonad m => ParserT [Char] st m Char -> ParserT [Char] st m String
1933inBrackets parser = do
1931inBrackets parser = do
1934 char '['
1932 char '['
1935 contents <- many parser
1933 contents <- many parser
@@ -2150,6 +2148,6 @@ doubleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
2150doubleQuoted = try $ do
2148doubleQuoted = try $ do
2151 doubleQuoteStart
2149 doubleQuoteStart
2152 contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
2150 contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
2153− (withQuoteContext InDoubleQuote $ doubleQuoteEnd >> return
2151+ withQuoteContext InDoubleQuote (doubleQuoteEnd >> return
2154 (fmap B.doubleQuoted . trimInlinesF $ contents))
2152 (fmap B.doubleQuoted . trimInlinesF $ contents))
2155− <|> (return $ return (B.str "\8220") <> contents)
2153+ <|> return (return (B.str "\8220") <> contents)
src/Text/Pandoc/Readers/Muse.hs+1−1
@@ -482,7 +482,7 @@ definitionList :: PandocMonad m => MuseParser m (F Blocks)
482definitionList = try $ do
482definitionList = try $ do
483 many spaceChar
483 many spaceChar
484 pos <- getPosition
484 pos <- getPosition
485− (guardDisabled Ext_amuse) <|> (guard (sourceColumn pos /= 1)) -- Initial space is required by Amusewiki, but not Emacs Muse
485+ guardDisabled Ext_amuse <|> guard (sourceColumn pos /= 1) -- Initial space is required by Amusewiki, but not Emacs Muse
486 first <- definitionListItem 0
486 first <- definitionListItem 0
487 rest <- many $ try (optionMaybe blankline >> definitionListItem (sourceColumn pos - 1))
487 rest <- many $ try (optionMaybe blankline >> definitionListItem (sourceColumn pos - 1))
488 return $ B.definitionList <$> sequence (first : rest)
488 return $ B.definitionList <$> sequence (first : rest)
src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs+2−2
@@ -211,9 +211,9 @@ a ^>>?% f = arr a >>?^ (uncurry f)
211---
211---
212(>>?%?) :: (ArrowChoice a)
212(>>?%?) :: (ArrowChoice a)
213 => FallibleArrow a x f (b,b')
213 => FallibleArrow a x f (b,b')
214− -> (b -> b' -> (Either f c))
214+ -> (b -> b' -> Either f c)
215 -> FallibleArrow a x f c
215 -> FallibleArrow a x f c
216−a >>?%? f = a >>?^? (uncurry f)
216+a >>?%? f = a >>?^? uncurry f
217
217
218infixr 1 >>?, >>?^, >>?^?
218infixr 1 >>?, >>?^, >>?^?
219infixr 1 ^>>?, >>?!
219infixr 1 ^>>?, >>?!
src/Text/Pandoc/Readers/Odt/ContentReader.hs+9−10
@@ -322,7 +322,7 @@ type InlineModifier = Inlines -> Inlines
322modifierFromStyleDiff :: PropertyTriple -> InlineModifier
322modifierFromStyleDiff :: PropertyTriple -> InlineModifier
323modifierFromStyleDiff propertyTriple =
323modifierFromStyleDiff propertyTriple =
324 composition $
324 composition $
325− (getVPosModifier propertyTriple)
325+ getVPosModifier propertyTriple
326 : map (first ($ propertyTriple) >>> ifThen_else ignore)
326 : map (first ($ propertyTriple) >>> ifThen_else ignore)
327 [ (hasEmphChanged , emph )
327 [ (hasEmphChanged , emph )
328 , (hasChanged isStrong , strong )
328 , (hasChanged isStrong , strong )
@@ -352,7 +352,7 @@ modifierFromStyleDiff propertyTriple =
352 ]
352 ]
353
353
354 hasChanged property triple@(_, property -> newProperty, _) =
354 hasChanged property triple@(_, property -> newProperty, _) =
355− maybe True (/=newProperty) (lookupPreviousValue property triple)
355+ (/= Just newProperty) (lookupPreviousValue property triple)
356
356
357 hasChangedM property triple@(_, textProps,_) =
357 hasChangedM property triple@(_, textProps,_) =
358 fromMaybe False $ (/=) <$> property textProps <*> lookupPreviousValueM property triple
358 fromMaybe False $ (/=) <$> property textProps <*> lookupPreviousValueM property triple
@@ -362,7 +362,7 @@ modifierFromStyleDiff propertyTriple =
362 lookupPreviousValueM f = lookupPreviousStyleValue ((f =<<).textProperties)
362 lookupPreviousValueM f = lookupPreviousStyleValue ((f =<<).textProperties)
363
363
364 lookupPreviousStyleValue f (ReaderState{..},_,mFamily)
364 lookupPreviousStyleValue f (ReaderState{..},_,mFamily)
365− = ( findBy f $ extendedStylePropertyChain styleTrace styleSet )
365+ = findBy f (extendedStylePropertyChain styleTrace styleSet)
366 <|> ( f =<< fmap (lookupDefaultStyle' styleSet) mFamily )
366 <|> ( f =<< fmap (lookupDefaultStyle' styleSet) mFamily )
367
367
368
368
@@ -793,8 +793,7 @@ read_image_src = matchingElement NsDraw "image"
793 Left _ -> returnV "" -< ()
793 Left _ -> returnV "" -< ()
794
794
795read_frame_title :: InlineMatcher
795read_frame_title :: InlineMatcher
796−read_frame_title = matchingElement NsSVG "title"
796+read_frame_title = matchingElement NsSVG "title" (matchChildContent [] read_plain_text)
797− $ (matchChildContent [] read_plain_text)
798
797
799read_frame_text_box :: InlineMatcher
798read_frame_text_box :: InlineMatcher
800read_frame_text_box = matchingElement NsDraw "text-box"
799read_frame_text_box = matchingElement NsDraw "text-box"
@@ -803,12 +802,12 @@ read_frame_text_box = matchingElement NsDraw "text-box"
803 arr read_img_with_caption -< toList paragraphs
802 arr read_img_with_caption -< toList paragraphs
804
803
805read_img_with_caption :: [Block] -> Inlines
804read_img_with_caption :: [Block] -> Inlines
806−read_img_with_caption ((Para [Image attr alt (src,title)]) : _) =
805+read_img_with_caption (Para [Image attr alt (src,title)] : _) =
807 singleton (Image attr alt (src, 'f':'i':'g':':':title)) -- no text, default caption
806 singleton (Image attr alt (src, 'f':'i':'g':':':title)) -- no text, default caption
808read_img_with_caption (Para (Image attr _ (src,title) : txt) : _) =
807read_img_with_caption (Para (Image attr _ (src,title) : txt) : _) =
809 singleton (Image attr txt (src, 'f':'i':'g':':':title) ) -- override caption with the text that follows
808 singleton (Image attr txt (src, 'f':'i':'g':':':title) ) -- override caption with the text that follows
810−read_img_with_caption ( (Para (_ : xs)) : ys) =
809+read_img_with_caption ( Para (_ : xs) : ys) =
811− read_img_with_caption ((Para xs) : ys)
810+ read_img_with_caption (Para xs : ys)
812read_img_with_caption _ =
811read_img_with_caption _ =
813 mempty
812 mempty
814
813
@@ -909,8 +908,8 @@ post_process (Pandoc m blocks) =
909 Pandoc m (post_process' blocks)
908 Pandoc m (post_process' blocks)
910
909
911post_process' :: [Block] -> [Block]
910post_process' :: [Block] -> [Block]
912−post_process' ((Table _ a w h r) : (Div ("", ["caption"], _) [Para inlines] ) : xs) =
911+post_process' (Table _ a w h r : Div ("", ["caption"], _) [Para inlines] : xs) =
913− (Table inlines a w h r) : ( post_process' xs )
912+ Table inlines a w h r : post_process' xs
914post_process' bs = bs
913post_process' bs = bs
915
914
916read_body :: OdtReader _x (Pandoc, MediaBag)
915read_body :: OdtReader _x (Pandoc, MediaBag)
src/Text/Pandoc/Readers/Odt/Namespaces.hs+1−1
@@ -48,7 +48,7 @@ instance NameSpaceID Namespace where
48
48
49
49
50findID :: NameSpaceIRI -> Maybe Namespace
50findID :: NameSpaceIRI -> Maybe Namespace
51−findID iri = listToMaybe [nsID | (iri',~nsID) <- nsIDs, iri' `isPrefixOf` iri]
51+findID iri = listToMaybe [nsID | (iri',nsID) <- nsIDs, iri' `isPrefixOf` iri]
52
52
53nsIDmap :: NameSpaceIRIs Namespace
53nsIDmap :: NameSpaceIRIs Namespace
54nsIDmap = foldr (uncurry $ flip M.insert) M.empty nsIDs
54nsIDmap = foldr (uncurry $ flip M.insert) M.empty nsIDs
src/Text/Pandoc/Readers/Odt/StyleReader.hs+20−23
@@ -131,13 +131,12 @@ type StyleReaderSafe a b = XMLReaderSafe FontPitches a b
131-- | A reader for font pitches
131-- | A reader for font pitches
132fontPitchReader :: XMLReader _s _x FontPitches
132fontPitchReader :: XMLReader _s _x FontPitches
133fontPitchReader = executeIn NsOffice "font-face-decls" (
133fontPitchReader = executeIn NsOffice "font-face-decls" (
134− ( withEveryL NsStyle "font-face" $ liftAsSuccess (
134+ withEveryL NsStyle "font-face" (liftAsSuccess (
135 findAttr' NsStyle "name"
135 findAttr' NsStyle "name"
136 &&&
136 &&&
137 lookupDefaultingAttr NsStyle "font-pitch"
137 lookupDefaultingAttr NsStyle "font-pitch"
138− )
138+ ))
139− )
140− >>?^ ( M.fromList . (foldl accumLegalPitches []) )
139+ >>?^ ( M.fromList . foldl accumLegalPitches [] )
141 )
140 )
142 where accumLegalPitches ls (Nothing,_) = ls
141 where accumLegalPitches ls (Nothing,_) = ls
143 accumLegalPitches ls (Just n,p) = (n,p):ls
142 accumLegalPitches ls (Just n,p) = (n,p):ls
@@ -383,11 +382,11 @@ data ListLevelStyle = ListLevelStyle { listLevelType :: ListLevelType
383
382
384instance Show ListLevelStyle where
383instance Show ListLevelStyle where
385 show ListLevelStyle{..} = "<LLS|"
384 show ListLevelStyle{..} = "<LLS|"
386− ++ (show listLevelType)
385+ ++ show listLevelType
387 ++ "|"
386 ++ "|"
388− ++ (maybeToString listItemPrefix)
387+ ++ maybeToString listItemPrefix
389− ++ (show listItemFormat)
388+ ++ show listItemFormat
390− ++ (maybeToString listItemSuffix)
389+ ++ maybeToString listItemSuffix
391 ++ ">"
390 ++ ">"
392 where maybeToString = fromMaybe ""
391 where maybeToString = fromMaybe ""
393
392
@@ -483,14 +482,14 @@ readTextProperties =
483 ( liftA6 PropT
482 ( liftA6 PropT
484 ( searchAttr NsXSL_FO "font-style" False isFontEmphasised )
483 ( searchAttr NsXSL_FO "font-style" False isFontEmphasised )
485 ( searchAttr NsXSL_FO "font-weight" False isFontBold )
484 ( searchAttr NsXSL_FO "font-weight" False isFontBold )
486− ( findPitch )
485+ findPitch
487 ( getAttr NsStyle "text-position" )
486 ( getAttr NsStyle "text-position" )
488− ( readUnderlineMode )
487+ readUnderlineMode
489− ( readStrikeThroughMode )
488+ readStrikeThroughMode
490 )
489 )
491 where isFontEmphasised = [("normal",False),("italic",True),("oblique",True)]
490 where isFontEmphasised = [("normal",False),("italic",True),("oblique",True)]
492 isFontBold = ("normal",False):("bold",True)
491 isFontBold = ("normal",False):("bold",True)
493− :(map ((,True).show) ([100,200..900]::[Int]))
492+ :map ((,True).show) ([100,200..900]::[Int])
494
493
495readUnderlineMode :: StyleReaderSafe _x (Maybe UnderlineMode)
494readUnderlineMode :: StyleReaderSafe _x (Maybe UnderlineMode)
496readUnderlineMode = readLineMode "text-underline-mode"
495readUnderlineMode = readLineMode "text-underline-mode"
@@ -510,7 +509,7 @@ readLineMode modeAttr styleAttr = proc x -> do
510 Nothing -> returnA -< Just UnderlineModeNormal
509 Nothing -> returnA -< Just UnderlineModeNormal
511 else returnA -< Nothing
510 else returnA -< Nothing
512 where
511 where
513− isLinePresent = [("none",False)] ++ map (,True)
512+ isLinePresent = ("none",False) : map (,True)
514 [ "dash" , "dot-dash" , "dot-dot-dash" , "dotted"
513 [ "dash" , "dot-dash" , "dot-dot-dash" , "dotted"
515 , "long-dash" , "solid" , "wave"
514 , "long-dash" , "solid" , "wave"
516 ]
515 ]
@@ -547,20 +546,18 @@ readListStyle =
547 findAttr NsStyle "name"
546 findAttr NsStyle "name"
548 >>?! keepingTheValue
547 >>?! keepingTheValue
549 ( liftA ListStyle
548 ( liftA ListStyle
550− $ ( liftA3 SM.union3
549+ $ liftA3 SM.union3
551 ( readListLevelStyles NsText "list-level-style-number" LltNumbered )
550 ( readListLevelStyles NsText "list-level-style-number" LltNumbered )
552 ( readListLevelStyles NsText "list-level-style-bullet" LltBullet )
551 ( readListLevelStyles NsText "list-level-style-bullet" LltBullet )
553− ( readListLevelStyles NsText "list-level-style-image" LltImage )
552+ ( readListLevelStyles NsText "list-level-style-image" LltImage ) >>^ M.mapMaybe chooseMostSpecificListLevelStyle
554− ) >>^ M.mapMaybe chooseMostSpecificListLevelStyle
555 )
553 )
556--
554--
557readListLevelStyles :: Namespace -> ElementName
555readListLevelStyles :: Namespace -> ElementName
558 -> ListLevelType
556 -> ListLevelType
559 -> StyleReaderSafe _x (SM.SetMap Int ListLevelStyle)
557 -> StyleReaderSafe _x (SM.SetMap Int ListLevelStyle)
560readListLevelStyles namespace elementName levelType =
558readListLevelStyles namespace elementName levelType =
561− ( tryAll namespace elementName (readListLevelStyle levelType)
559+ tryAll namespace elementName (readListLevelStyle levelType)
562 >>^ SM.fromList
560 >>^ SM.fromList
563− )
564
561
565--
562--
566readListLevelStyle :: ListLevelType -> StyleReader _x (Int, ListLevelStyle)
563readListLevelStyle :: ListLevelType -> StyleReader _x (Int, ListLevelStyle)
@@ -632,7 +629,7 @@ parents style styles = unfoldr findNextParent style -- Ha!
632getStyleFamily :: Style -> Styles -> Maybe StyleFamily
629getStyleFamily :: Style -> Styles -> Maybe StyleFamily
633getStyleFamily style@Style{..} styles
630getStyleFamily style@Style{..} styles
634 = styleFamily
631 = styleFamily
635− <|> (F.asum $ map (`getStyleFamily` styles) $ parents style styles)
632+ <|> F.asum (map (`getStyleFamily` styles) $ parents style styles)
636
633
637-- | Each 'Style' has certain 'StyleProperties'. But sometimes not all property
634-- | Each 'Style' has certain 'StyleProperties'. But sometimes not all property
638-- values are specified. Instead, a value might be inherited from a
635-- values are specified. Instead, a value might be inherited from a
@@ -654,7 +651,7 @@ stylePropertyChain style styles
654--
651--
655extendedStylePropertyChain :: [Style] -> Styles -> [StyleProperties]
652extendedStylePropertyChain :: [Style] -> Styles -> [StyleProperties]
656extendedStylePropertyChain [] _ = []
653extendedStylePropertyChain [] _ = []
657−extendedStylePropertyChain [style] styles = (stylePropertyChain style styles)
654+extendedStylePropertyChain [style] styles = stylePropertyChain style styles
658− ++ (maybeToList (fmap (lookupDefaultStyle' styles) (getStyleFamily style styles)))
655+ ++ maybeToList (fmap (lookupDefaultStyle' styles) (getStyleFamily style styles))
659−extendedStylePropertyChain (style:trace) styles = (stylePropertyChain style styles)
656+extendedStylePropertyChain (style:trace) styles = stylePropertyChain style styles
660− ++ (extendedStylePropertyChain trace styles)
657+ ++ extendedStylePropertyChain trace styles
src/Text/Pandoc/Readers/Org/Blocks.hs+1−1
@@ -516,7 +516,7 @@ include = try $ do
516 blocksParser <- case includeArgs of
516 blocksParser <- case includeArgs of
517 ("example" : _) -> return $ pure . B.codeBlock <$> parseRaw
517 ("example" : _) -> return $ pure . B.codeBlock <$> parseRaw
518 ["export"] -> return . returnF $ B.fromList []
518 ["export"] -> return . returnF $ B.fromList []
519− ("export" : format : []) -> return $ pure . B.rawBlock format <$> parseRaw
519+ ["export", format] -> return $ pure . B.rawBlock format <$> parseRaw
520 ("src" : rest) -> do
520 ("src" : rest) -> do
521 let attr = case rest of
521 let attr = case rest of
522 [lang] -> (mempty, [lang], mempty)
522 [lang] -> (mempty, [lang], mempty)
src/Text/Pandoc/Readers/RST.hs+4−4
@@ -1263,7 +1263,7 @@ simpleTableHeader headless = try $ do
1263 let rawHeads = if headless
1263 let rawHeads = if headless
1264 then replicate (length dashes) ""
1264 then replicate (length dashes) ""
1265 else simpleTableSplitLine indices rawContent
1265 else simpleTableSplitLine indices rawContent
1266− heads <- mapM ( (parseFromString' (mconcat <$> many plain)) . trim) rawHeads
1266+ heads <- mapM ( parseFromString' (mconcat <$> many plain) . trim) rawHeads
1267 return (heads, aligns, indices)
1267 return (heads, aligns, indices)
1268
1268
1269-- Parse a simple table.
1269-- Parse a simple table.
@@ -1414,7 +1414,7 @@ renderRole contents fmt role attr = case role of
1414 pepUrl = "http://www.python.org/dev/peps/pep-" ++ padNo ++ "/"
1414 pepUrl = "http://www.python.org/dev/peps/pep-" ++ padNo ++ "/"
1415
1415
1416addClass :: String -> Attr -> Attr
1416addClass :: String -> Attr -> Attr
1417−addClass c (ident, classes, keyValues) = (ident, union classes [c], keyValues)
1417+addClass c (ident, classes, keyValues) = (ident, classes `union` [c], keyValues)
1418
1418
1419roleName :: PandocMonad m => RSTParser m String
1419roleName :: PandocMonad m => RSTParser m String
1420roleName = many1 (letter <|> char '-')
1420roleName = many1 (letter <|> char '-')
@@ -1454,7 +1454,7 @@ endline = try $ do
1454 notFollowedBy blankline
1454 notFollowedBy blankline
1455 -- parse potential list-starts at beginning of line differently in a list:
1455 -- parse potential list-starts at beginning of line differently in a list:
1456 st <- getState
1456 st <- getState
1457− when ((stateParserContext st) == ListItemState) $ notFollowedBy (anyOrderedListMarker >> spaceChar) >>
1457+ when (stateParserContext st == ListItemState) $ notFollowedBy (anyOrderedListMarker >> spaceChar) >>
1458 notFollowedBy' bulletListStart
1458 notFollowedBy' bulletListStart
1459 return B.softbreak
1459 return B.softbreak
1460
1460
@@ -1577,7 +1577,7 @@ note = try $ do
1577 -- not yet in this implementation.
1577 -- not yet in this implementation.
1578 updateState $ \st -> st{ stateNotes = [] }
1578 updateState $ \st -> st{ stateNotes = [] }
1579 contents <- parseFromString' parseBlocks raw
1579 contents <- parseFromString' parseBlocks raw
1580− let newnotes = if (ref == "*" || ref == "#") -- auto-numbered
1580+ let newnotes = if ref == "*" || ref == "#" -- auto-numbered
1581 -- delete the note so the next auto-numbered note
1581 -- delete the note so the next auto-numbered note
1582 -- doesn't get the same contents:
1582 -- doesn't get the same contents:
1583 then deleteFirstsBy (==) notes [(ref,raw)]
1583 then deleteFirstsBy (==) notes [(ref,raw)]
src/Text/Pandoc/Readers/Textile.hs+7−6
@@ -110,7 +110,7 @@ noteBlock = try $ do
110 startPos <- getPosition
110 startPos <- getPosition
111 ref <- noteMarker
111 ref <- noteMarker
112 optional blankline
112 optional blankline
113− contents <- fmap unlines $ many1Till anyLine (blanklines <|> noteBlock)
113+ contents <- unlines <$> many1Till anyLine (blanklines <|> noteBlock)
114 endPos <- getPosition
114 endPos <- getPosition
115 let newnote = (ref, contents ++ "\n")
115 let newnote = (ref, contents ++ "\n")
116 st <- getState
116 st <- getState
@@ -360,7 +360,7 @@ cellAttributes = try $ do
360tableCell :: PandocMonad m => ParserT [Char] ParserState m ((Bool, Alignment), Blocks)
360tableCell :: PandocMonad m => ParserT [Char] ParserState m ((Bool, Alignment), Blocks)
361tableCell = try $ do
361tableCell = try $ do
362 char '|'
362 char '|'
363− (isHeader, alignment) <- option (False, AlignDefault) $ cellAttributes
363+ (isHeader, alignment) <- option (False, AlignDefault) cellAttributes
364 notFollowedBy blankline
364 notFollowedBy blankline
365 raw <- trim <$>
365 raw <- trim <$>
366 many (noneOf "|\n" <|> try (char '\n' <* notFollowedBy blankline))
366 many (noneOf "|\n" <|> try (char '\n' <* notFollowedBy blankline))
@@ -499,7 +499,7 @@ copy = do
499
499
500note :: PandocMonad m => ParserT [Char] ParserState m Inlines
500note :: PandocMonad m => ParserT [Char] ParserState m Inlines
501note = try $ do
501note = try $ do
502− ref <- (char '[' *> many1 digit <* char ']')
502+ ref <- char '[' *> many1 digit <* char ']'
503 notes <- stateNotes <$> getState
503 notes <- stateNotes <$> getState
504 case lookup ref notes of
504 case lookup ref notes of
505 Nothing -> fail "note not found"
505 Nothing -> fail "note not found"
@@ -530,7 +530,7 @@ hyphenedWords = do
530wordChunk :: PandocMonad m => ParserT [Char] ParserState m String
530wordChunk :: PandocMonad m => ParserT [Char] ParserState m String
531wordChunk = try $ do
531wordChunk = try $ do
532 hd <- noneOf wordBoundaries
532 hd <- noneOf wordBoundaries
533− tl <- many ( (noneOf wordBoundaries) <|>
533+ tl <- many ( noneOf wordBoundaries <|>
534 try (notFollowedBy' note *> oneOf markupChars
534 try (notFollowedBy' note *> oneOf markupChars
535 <* lookAhead (noneOf wordBoundaries) ) )
535 <* lookAhead (noneOf wordBoundaries) ) )
536 return $ hd:tl
536 return $ hd:tl
@@ -614,7 +614,7 @@ escapedEqs = B.str <$>
614-- | literal text escaped btw <notextile> tags
614-- | literal text escaped btw <notextile> tags
615escapedTag :: PandocMonad m => ParserT [Char] ParserState m Inlines
615escapedTag :: PandocMonad m => ParserT [Char] ParserState m Inlines
616escapedTag = B.str <$>
616escapedTag = B.str <$>
617− (try $ string "<notextile>" *>
617+ try (string "<notextile>" *>
618 manyTill anyChar' (try $ string "</notextile>"))
618 manyTill anyChar' (try $ string "</notextile>"))
619
619
620-- | Any special symbol defined in wordBoundaries
620-- | Any special symbol defined in wordBoundaries
@@ -630,7 +630,8 @@ code = code1 <|> code2
630-- any character except a newline before a blank line
630-- any character except a newline before a blank line
631anyChar' :: PandocMonad m => ParserT [Char] ParserState m Char
631anyChar' :: PandocMonad m => ParserT [Char] ParserState m Char
632anyChar' =
632anyChar' =
633+ satisfy (/='\n') <|>
633− satisfy (/='\n') <|> (try $ char '\n' <* notFollowedBy blankline)
634+ try (char '\n' <* notFollowedBy blankline)
634
635
635code1 :: PandocMonad m => ParserT [Char] ParserState m Inlines
636code1 :: PandocMonad m => ParserT [Char] ParserState m Inlines
636code1 = B.code <$> surrounded (char '@') anyChar'
637code1 = B.code <$> surrounded (char '@') anyChar'
src/Text/Pandoc/Readers/TikiWiki.hs+7−7
@@ -168,7 +168,7 @@ table = try $ do
168 where
168 where
169 -- The headers are as many empty srings as the number of columns
169 -- The headers are as many empty srings as the number of columns
170 -- in the first row
170 -- in the first row
171− headers rows = map (B.plain . B.str) $replicate (length $ rows !! 0) ""
171+ headers rows = map (B.plain . B.str) $replicate (length $ head rows) ""
172
172
173para :: PandocMonad m => TikiWikiParser m B.Blocks
173para :: PandocMonad m => TikiWikiParser m B.Blocks
174para = fmap (result . mconcat) ( many1Till inline endOfParaElement)
174para = fmap (result . mconcat) ( many1Till inline endOfParaElement)
@@ -238,8 +238,8 @@ fixListNesting [first] = [recurseOnList first]
238fixListNesting (first:second:rest) =
238fixListNesting (first:second:rest) =
239 let secondBlock = head $ B.toList second in
239 let secondBlock = head $ B.toList second in
240 case secondBlock of
240 case secondBlock of
241− BulletList _ -> fixListNesting $ (mappend (recurseOnList first) (recurseOnList second)) : rest
241+ BulletList _ -> fixListNesting $ mappend (recurseOnList first) (recurseOnList second) : rest
242− OrderedList _ _ -> fixListNesting $ (mappend (recurseOnList first) (recurseOnList second)) : rest
242+ OrderedList _ _ -> fixListNesting $ mappend (recurseOnList first) (recurseOnList second) : rest
243 _ -> recurseOnList first : fixListNesting (second:rest)
243 _ -> recurseOnList first : fixListNesting (second:rest)
244
244
245-- This function walks the Block structure for fixListNesting,
245-- This function walks the Block structure for fixListNesting,
@@ -285,7 +285,7 @@ spanFoldUpList ln (first:rest) =
285-- level and of the same type.
285-- level and of the same type.
286splitListNesting :: ListNesting -> (ListNesting, B.Blocks) -> Bool
286splitListNesting :: ListNesting -> (ListNesting, B.Blocks) -> Bool
287splitListNesting ln1 (ln2, _)
287splitListNesting ln1 (ln2, _)
288− | (lnnest ln1) < (lnnest ln2) =
288+ | lnnest ln1 < lnnest ln2 =
289 True
289 True
290 | ln1 == ln2 =
290 | ln1 == ln2 =
291 True
291 True
@@ -341,7 +341,7 @@ listItemLine nest = lineContent >>= parseContent
341 lineContent = do
341 lineContent = do
342 content <- anyLine
342 content <- anyLine
343 continuation <- optionMaybe listContinuation
343 continuation <- optionMaybe listContinuation
344− return $ filterSpaces content ++ "\n" ++ maybe "" id continuation
344+ return $ filterSpaces content ++ "\n" ++ Data.Maybe.fromMaybe "" continuation
345 filterSpaces = reverse . dropWhile (== ' ') . reverse
345 filterSpaces = reverse . dropWhile (== ' ') . reverse
346 listContinuation = string (replicate nest '+') >> lineContent
346 listContinuation = string (replicate nest '+') >> lineContent
347 parseContent x = do
347 parseContent x = do
@@ -410,7 +410,7 @@ inline = choice [ whitespace
410 ] <?> "inline"
410 ] <?> "inline"
411
411
412whitespace :: PandocMonad m => TikiWikiParser m B.Inlines
412whitespace :: PandocMonad m => TikiWikiParser m B.Inlines
413−whitespace = (lb <|> regsp)
413+whitespace = lb <|> regsp
414 where lb = try $ skipMany spaceChar >> linebreak >> return B.space
414 where lb = try $ skipMany spaceChar >> linebreak >> return B.space
415 regsp = try $ skipMany1 spaceChar >> return B.space
415 regsp = try $ skipMany1 spaceChar >> return B.space
416
416
@@ -501,7 +501,7 @@ escapedChar = try $ do
501 string "~"
501 string "~"
502 inner <- many1 $ oneOf "0123456789"
502 inner <- many1 $ oneOf "0123456789"
503 string "~"
503 string "~"
504− return $B.str [(toEnum (read inner :: Int)) :: Char]
504+ return $B.str [toEnum (read inner :: Int) :: Char]
505
505
506-- UNSUPPORTED, as there doesn't seem to be any facility in calibre
506-- UNSUPPORTED, as there doesn't seem to be any facility in calibre
507-- for this
507-- for this
src/Text/Pandoc/Readers/Txt2Tags.hs+2−2
@@ -36,7 +36,7 @@ import Control.Monad.Except (catchError, throwError)
36import Control.Monad.Reader (Reader, asks, runReader)
36import Control.Monad.Reader (Reader, asks, runReader)
37import Data.Char (toLower)
37import Data.Char (toLower)
38import Data.Default
38import Data.Default
39−import Data.List (intercalate, intersperse, transpose)
39+import Data.List (intercalate, transpose)
40import Data.Maybe (fromMaybe)
40import Data.Maybe (fromMaybe)
41import Data.Monoid ((<>))
41import Data.Monoid ((<>))
42import Data.Text (Text)
42import Data.Text (Text)
@@ -463,7 +463,7 @@ titleLink = try $ do
463 char ']'
463 char ']'
464 let link' = last tokens
464 let link' = last tokens
465 guard $ not $ null link'
465 guard $ not $ null link'
466− let tit = concat (intersperse " " (init tokens))
466+ let tit = unwords (init tokens)
467 return $ B.link link' "" (B.text tit)
467 return $ B.link link' "" (B.text tit)
468
468
469-- Link with image
469-- Link with image
src/Text/Pandoc/Readers/Vimwiki.hs+1−3
@@ -388,9 +388,7 @@ bulletListMarkers = "ul" <$ (char '*' <|> char '-')
388
388
389orderedListMarkers :: PandocMonad m => VwParser m String
389orderedListMarkers :: PandocMonad m => VwParser m String
390orderedListMarkers =
390orderedListMarkers =
391− ("ol" <$choice (orderedListMarker Decimal Period:(($OneParen)
392− <$> orderedListMarker
393− <$> [Decimal, LowerRoman, UpperRoman, LowerAlpha, UpperAlpha])))
391+ ("ol" <$choice (orderedListMarker Decimal Period:(($OneParen) . orderedListMarker <$> [Decimal, LowerRoman, UpperRoman, LowerAlpha, UpperAlpha])))
394 <|> ("ol" <$ char '#')
392 <|> ("ol" <$ char '#')
395
393
396--many need trimInlines
394--many need trimInlines
src/Text/Pandoc/Shared.hs+1−1
@@ -494,7 +494,7 @@ hierarchicalizeWithIds (Header level attr@(_,classes,_) title':xs) = do
494 return $ Sec level newnum attr title' sectionContents' : rest'
494 return $ Sec level newnum attr title' sectionContents' : rest'
495hierarchicalizeWithIds (Div ("",["references"],[])
495hierarchicalizeWithIds (Div ("",["references"],[])
496 (Header level (ident,classes,kvs) title' : xs):ys) =
496 (Header level (ident,classes,kvs) title' : xs):ys) =
497− hierarchicalizeWithIds (Header level (ident,("references":classes),kvs)
497+ hierarchicalizeWithIds (Header level (ident,"references":classes,kvs)
498 title' : (xs ++ ys))
498 title' : (xs ++ ys))
499hierarchicalizeWithIds (x:rest) = do
499hierarchicalizeWithIds (x:rest) = do
500 rest' <- hierarchicalizeWithIds rest
500 rest' <- hierarchicalizeWithIds rest
src/Text/Pandoc/Writers/AsciiDoc.hs+2−3
@@ -265,8 +265,7 @@ blockToAsciiDoc opts (OrderedList (_start, sty, _delim) items) = do
265 let markers' = map (\m -> if length m < 3
265 let markers' = map (\m -> if length m < 3
266 then m ++ replicate (3 - length m) ' '
266 then m ++ replicate (3 - length m) ' '
267 else m) markers
267 else m) markers
268− contents <- mapM (uncurry (orderedListItemToAsciiDoc opts)) $
268+ contents <- zipWithM (orderedListItemToAsciiDoc opts) markers' items
269− zip markers' items
270 return $ cat contents <> blankline
269 return $ cat contents <> blankline
271blockToAsciiDoc opts (DefinitionList items) = do
270blockToAsciiDoc opts (DefinitionList items) = do
272 contents <- mapM (definitionListItemToAsciiDoc opts) items
271 contents <- mapM (definitionListItemToAsciiDoc opts) items
@@ -452,7 +451,7 @@ inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
452 else prefix <> text src <> "[" <> linktext <> "]"
451 else prefix <> text src <> "[" <> linktext <> "]"
453inlineToAsciiDoc opts (Image attr alternate (src, tit)) = do
452inlineToAsciiDoc opts (Image attr alternate (src, tit)) = do
454-- image:images/logo.png[Company logo, title="blah"]
453-- image:images/logo.png[Company logo, title="blah"]
455− let txt = if (null alternate) || (alternate == [Str ""])
454+ let txt = if null alternate || (alternate == [Str ""])
456 then [Str "image"]
455 then [Str "image"]
457 else alternate
456 else alternate
458 linktext <- inlineListToAsciiDoc opts txt
457 linktext <- inlineListToAsciiDoc opts txt
src/Text/Pandoc/Writers/Docx.hs+5−8
@@ -1057,12 +1057,9 @@ getParaProps displayMathPara = do
1057 props <- asks envParaProperties
1057 props <- asks envParaProperties
1058 listLevel <- asks envListLevel
1058 listLevel <- asks envListLevel
1059 numid <- asks envListNumId
1059 numid <- asks envListNumId
1060+ let listPr = [mknode "w:numPr" []
1061+ [ mknode "w:numId" [("w:val",show numid)] ()
1060− let listPr = if listLevel >= 0 && not displayMathPara
1062+ , mknode "w:ilvl" [("w:val",show listLevel)] () ] | listLevel >= 0 && not displayMathPara]
1061− then [ mknode "w:numPr" []
1062− [ mknode "w:numId" [("w:val",show numid)] ()
1063− , mknode "w:ilvl" [("w:val",show listLevel)] () ]
1064− ]
1065− else []
1066 return $ case props ++ listPr of
1063 return $ case props ++ listPr of
1067 [] -> []
1064 [] -> []
1068 ps -> [mknode "w:pPr" [] ps]
1065 ps -> [mknode "w:pPr" [] ps]
@@ -1145,7 +1142,7 @@ inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
1145 return $ \f -> do
1142 return $ \f -> do
1146 x <- f
1143 x <- f
1147 return [ mknode "w:ins"
1144 return [ mknode "w:ins"
1148− [("w:id", (show insId)),
1145+ [("w:id", show insId),
1149 ("w:author", author),
1146 ("w:author", author),
1150 ("w:date", date)] x ]
1147 ("w:date", date)] x ]
1151 else return id
1148 else return id
@@ -1272,7 +1269,7 @@ inlineToOpenXML' opts (Image attr alt (src, title)) = do
1272 Nothing ->
1269 Nothing ->
1273 catchError
1270 catchError
1274 (do (img, mt) <- P.fetchItem src
1271 (do (img, mt) <- P.fetchItem src
1275− ident <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
1272+ ident <- ("rId"++) `fmap` (lift . lift) getUniqueId
1276 let (xpt,ypt) = desiredSizeInPoints opts attr
1273 let (xpt,ypt) = desiredSizeInPoints opts attr
1277 (either (const def) id (imageSize opts img))
1274 (either (const def) id (imageSize opts img))
1278 -- 12700 emu = 1 pt
1275 -- 12700 emu = 1 pt
src/Text/Pandoc/Writers/FB2.hs+1−2
@@ -131,8 +131,7 @@ description meta' = do
131 _ -> return []
131 _ -> return []
132 return $ el "description"
132 return $ el "description"
133 [ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
133 [ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
134− , el "document-info" ([ el "program-used" "pandoc" ] -- FIXME: +version
134+ , el "document-info" (el "program-used" "pandoc" : coverpage)
135− ++ coverpage)
136 ]
135 ]
137
136
138booktitle :: PandocMonad m => Meta -> FBM m [Content]
137booktitle :: PandocMonad m => Meta -> FBM m [Content]
src/Text/Pandoc/Writers/HTML.hs+7−6
@@ -56,7 +56,8 @@ import qualified Data.Text.Lazy as TL
56import Network.HTTP (urlEncode)
56import Network.HTTP (urlEncode)
57import Network.URI (URI (..), parseURIReference, unEscapeString)
57import Network.URI (URI (..), parseURIReference, unEscapeString)
58import Numeric (showHex)
58import Numeric (showHex)
59−import Text.Blaze.Internal (customLeaf, MarkupM(Empty))
59+import Text.Blaze.Internal
60+ (customLeaf, MarkupM(Empty), preEscapedString, preEscapedText)
60import Text.Blaze.Html hiding (contents)
61import Text.Blaze.Html hiding (contents)
61import Text.Pandoc.Definition
62import Text.Pandoc.Definition
62import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtmlInline, highlight,
63import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtmlInline, highlight,
@@ -424,7 +425,7 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
424 modify (\st -> st{ stElement = False})
425 modify (\st -> st{ stElement = False})
425 return res
426 return res
426
427
427− let isSec (Sec{}) = True
428+ let isSec Sec{} = True
428 isSec (Blk _) = False
429 isSec (Blk _) = False
429 let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
430 let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
430 isPause _ = False
431 isPause _ = False
@@ -618,7 +619,7 @@ imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf",
618
619
619treatAsImage :: FilePath -> Bool
620treatAsImage :: FilePath -> Bool
620treatAsImage fp =
621treatAsImage fp =
621− let path = fromMaybe fp (uriPath `fmap` parseURIReference fp)
622+ let path = maybe fp uriPath (parseURIReference fp)
622 ext = map toLower $ drop 1 $ takeExtension path
623 ext = map toLower $ drop 1 $ takeExtension path
623 in null ext || ext `elem` imageExts
624 in null ext || ext `elem` imageExts
624
625
@@ -797,8 +798,8 @@ blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
797 let numstyle' = case numstyle of
798 let numstyle' = case numstyle of
798 Example -> "decimal"
799 Example -> "decimal"
799 _ -> camelCaseToHyphenated $ show numstyle
800 _ -> camelCaseToHyphenated $ show numstyle
800− let attribs = ([A.start $ toValue startnum | startnum /= 1]) ++
801+ let attribs = [A.start $ toValue startnum | startnum /= 1] ++
801− ([A.class_ "example" | numstyle == Example]) ++
802+ [A.class_ "example" | numstyle == Example] ++
802 (if numstyle /= DefaultStyle
803 (if numstyle /= DefaultStyle
803 then if html5
804 then if html5
804 then [A.type_ $
805 then [A.type_ $
@@ -819,7 +820,7 @@ blockToHtml opts (DefinitionList lst) = do
819 do term' <- if null term
820 do term' <- if null term
820 then return mempty
821 then return mempty
821 else liftM H.dt $ inlineListToHtml opts term
822 else liftM H.dt $ inlineListToHtml opts term
822− defs' <- mapM (liftM (\x -> H.dd $ (x >> nl opts)) .
823+ defs' <- mapM (liftM (\x -> H.dd (x >> nl opts)) .
823 blockListToHtml opts) defs
824 blockListToHtml opts) defs
824 return $ mconcat $ nl opts : term' : nl opts :
825 return $ mconcat $ nl opts : term' : nl opts :
825 intersperse (nl opts) defs') lst
826 intersperse (nl opts) defs') lst
src/Text/Pandoc/Writers/Haddock.hs+1−2
@@ -168,8 +168,7 @@ blockToHaddock opts (OrderedList (start,_,delim) items) = do
168 let markers' = map (\m -> if length m < 3
168 let markers' = map (\m -> if length m < 3
169 then m ++ replicate (3 - length m) ' '
169 then m ++ replicate (3 - length m) ' '
170 else m) markers
170 else m) markers
171− contents <- mapM (uncurry (orderedListItemToHaddock opts)) $
171+ contents <- zipWithM (orderedListItemToHaddock opts) markers' items
172− zip markers' items
173 return $ cat contents <> blankline
172 return $ cat contents <> blankline
174blockToHaddock opts (DefinitionList items) = do
173blockToHaddock opts (DefinitionList items) = do
175 contents <- mapM (definitionListItemToHaddock opts) items
174 contents <- mapM (definitionListItemToHaddock opts) items
src/Text/Pandoc/Writers/ICML.hs+2−2
@@ -154,7 +154,7 @@ writeICML opts (Pandoc meta blocks) = do
154-- | Auxilary functions for parStylesToDoc and charStylesToDoc.
154-- | Auxilary functions for parStylesToDoc and charStylesToDoc.
155contains :: String -> (String, (String, String)) -> [(String, String)]
155contains :: String -> (String, (String, String)) -> [(String, String)]
156contains s rule =
156contains s rule =
157− [snd rule | isInfixOf (fst rule) s]
157+ [snd rule | (fst rule) `isInfixOf` s]
158
158
159-- | The monospaced font to use as default.
159-- | The monospaced font to use as default.
160monospacedFont :: Doc
160monospacedFont :: Doc
@@ -282,7 +282,7 @@ hyperlinksToDoc (x:xs) = hyp x $$ hyperlinksToDoc xs
282 ("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")]
282 ("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")]
283 $ inTags True "Properties" []
283 $ inTags True "Properties" []
284 $ inTags False "BorderColor" [("type","enumeration")] (text "Black")
284 $ inTags False "BorderColor" [("type","enumeration")] (text "Black")
285− $$ inTags False "Destination" [("type","object")] (text $ "HyperlinkURLDestination/"++(escapeColons (escapeStringForXML url))) -- HyperlinkURLDestination with more than one colon crashes CS6
285+ $$ inTags False "Destination" [("type","object")] (text $ "HyperlinkURLDestination/"++escapeColons (escapeStringForXML url)) -- HyperlinkURLDestination with more than one colon crashes CS6
286
286
287
287
288-- | Convert a list of Pandoc blocks to ICML.
288-- | Convert a list of Pandoc blocks to ICML.
src/Text/Pandoc/Writers/LaTeX.hs+4−4
@@ -41,7 +41,7 @@ import Data.Char (isAlphaNum, isAscii, isDigit, isLetter, isPunctuation, ord,
41 toLower)
41 toLower)
42import Data.List (foldl', intercalate, intersperse, isInfixOf, nubBy,
42import Data.List (foldl', intercalate, intersperse, isInfixOf, nubBy,
43 stripPrefix, (\\))
43 stripPrefix, (\\))
44−import Data.Maybe (catMaybes, fromMaybe, isJust, mapMaybe)
44+import Data.Maybe (catMaybes, fromMaybe, isJust, mapMaybe, isNothing)
45import Data.Text (Text)
45import Data.Text (Text)
46import qualified Data.Text as T
46import qualified Data.Text as T
47import Network.URI (unEscapeString)
47import Network.URI (unEscapeString)
@@ -401,7 +401,7 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts)
401 let frameoptions = ["allowdisplaybreaks", "allowframebreaks", "fragile",
401 let frameoptions = ["allowdisplaybreaks", "allowframebreaks", "fragile",
402 "b", "c", "t", "environment",
402 "b", "c", "t", "environment",
403 "label", "plain", "shrink", "standout"]
403 "label", "plain", "shrink", "standout"]
404− let optionslist = ["fragile" | fragile && lookup "fragile" kvs == Nothing] ++
404+ let optionslist = ["fragile" | fragile && isNothing (lookup "fragile" kvs)] ++
405 [k | k <- classes, k `elem` frameoptions] ++
405 [k | k <- classes, k `elem` frameoptions] ++
406 [k ++ "=" ++ v | (k,v) <- kvs, k `elem` frameoptions]
406 [k ++ "=" ++ v | (k,v) <- kvs, k `elem` frameoptions]
407 let options = if null optionslist
407 let options = if null optionslist
@@ -819,7 +819,7 @@ listItemToLaTeX lst
819 -- we need to put some text before a header if it's the first
819 -- we need to put some text before a header if it's the first
820 -- element in an item. This will look ugly in LaTeX regardless, but
820 -- element in an item. This will look ugly in LaTeX regardless, but
821 -- this will keep the typesetter from throwing an error.
821 -- this will keep the typesetter from throwing an error.
822− | (Header _ _ _ :_) <- lst =
822+ | (Header{} :_) <- lst =
823 blockListToLaTeX lst >>= return . (text "\\item ~" $$) . nest 2
823 blockListToLaTeX lst >>= return . (text "\\item ~" $$) . nest 2
824 | otherwise = blockListToLaTeX lst >>= return . (text "\\item" $$) .
824 | otherwise = blockListToLaTeX lst >>= return . (text "\\item" $$) .
825 nest 2
825 nest 2
@@ -856,7 +856,7 @@ sectionHeader unnumbered ident level lst = do
856 plain <- stringToLaTeX TextString $ concatMap stringify lst
856 plain <- stringToLaTeX TextString $ concatMap stringify lst
857 let removeInvalidInline (Note _) = []
857 let removeInvalidInline (Note _) = []
858 removeInvalidInline (Span (id', _, _) _) | not (null id') = []
858 removeInvalidInline (Span (id', _, _) _) | not (null id') = []
859− removeInvalidInline (Image{}) = []
859+ removeInvalidInline Image{} = []
860 removeInvalidInline x = [x]
860 removeInvalidInline x = [x]
861 let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
861 let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
862 txtNoNotes <- inlineListToLaTeX lstNoNotes
862 txtNoNotes <- inlineListToLaTeX lstNoNotes
src/Text/Pandoc/Writers/Man.hs+1−1
@@ -114,7 +114,7 @@ notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState
114notesToMan opts notes =
114notesToMan opts notes =
115 if null notes
115 if null notes
116 then return empty
116 then return empty
117− else mapM (uncurry (noteToMan opts)) (zip [1..] notes) >>=
117+ else zipWithM (noteToMan opts) [1..] notes >>=
118 return . (text ".SH NOTES" $$) . vcat
118 return . (text ".SH NOTES" $$) . vcat
119
119
120-- | Return man representation of a note.
120-- | Return man representation of a note.
src/Text/Pandoc/Writers/Muse.hs+1−1
@@ -218,7 +218,7 @@ blockToMuse (DefinitionList items) = do
218 descriptionToMuse :: PandocMonad m
218 descriptionToMuse :: PandocMonad m
219 => [Block]
219 => [Block]
220 -> StateT WriterState m Doc
220 -> StateT WriterState m Doc
221− descriptionToMuse desc = (hang 4 " :: ") <$> blockListToMuse desc
221+ descriptionToMuse desc = hang 4 " :: " <$> blockListToMuse desc
222blockToMuse (Header level (ident,_,_) inlines) = do
222blockToMuse (Header level (ident,_,_) inlines) = do
223 opts <- gets stOptions
223 opts <- gets stOptions
224 contents <- inlineListToMuse inlines
224 contents <- inlineListToMuse inlines
src/Text/Pandoc/Writers/OOXML.hs+1−1
@@ -104,5 +104,5 @@ fitToPage :: (Double, Double) -> Integer -> (Integer, Integer)
104fitToPage (x, y) pageWidth
104fitToPage (x, y) pageWidth
105 -- Fixes width to the page width and scales the height
105 -- Fixes width to the page width and scales the height
106 | x > fromIntegral pageWidth =
106 | x > fromIntegral pageWidth =
107− (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y)
107+ (pageWidth, floor $ (fromIntegral pageWidth / x) * y)
108 | otherwise = (floor x, floor y)
108 | otherwise = (floor x, floor y)
src/Text/Pandoc/Writers/OpenDocument.hs+1−1
@@ -594,7 +594,7 @@ paraStyle attrs = do
594 tight = if t then [ ("fo:margin-top" , "0in" )
594 tight = if t then [ ("fo:margin-top" , "0in" )
595 , ("fo:margin-bottom" , "0in" )]
595 , ("fo:margin-bottom" , "0in" )]
596 else []
596 else []
597− indent = if (i /= 0 || b)
597+ indent = if i /= 0 || b
598 then [ ("fo:margin-left" , indentVal)
598 then [ ("fo:margin-left" , indentVal)
599 , ("fo:margin-right" , "0in" )
599 , ("fo:margin-right" , "0in" )
600 , ("fo:text-indent" , "0in" )
600 , ("fo:text-indent" , "0in" )
src/Text/Pandoc/Writers/Powerpoint.hs+1−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE PatternGuards #-}
1+
2
2
3{-
3{-
4Copyright (C) 2017-2018 Jesse Rosenthal <jrosenthal@jhu.edu>
4Copyright (C) 2017-2018 Jesse Rosenthal <jrosenthal@jhu.edu>
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs+36−38
@@ -72,7 +72,7 @@ import qualified Text.Pandoc.Shared as Shared -- so we don't overlap "Element"
72import Text.Pandoc.Writers.Shared (metaValueToInlines)
72import Text.Pandoc.Writers.Shared (metaValueToInlines)
73import qualified Data.Map as M
73import qualified Data.Map as M
74import qualified Data.Set as S
74import qualified Data.Set as S
75−import Data.Maybe (maybeToList)
75+import Data.Maybe (maybeToList, fromMaybe)
76import Text.Pandoc.Highlighting
76import Text.Pandoc.Highlighting
77import qualified Data.Text as T
77import qualified Data.Text as T
78import Control.Applicative ((<|>))
78import Control.Applicative ((<|>))
@@ -136,7 +136,7 @@ reservedSlideIds = S.fromList [ metadataSlideId
136
136
137uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId
137uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId
138uniqueSlideId' n idSet s =
138uniqueSlideId' n idSet s =
139− let s' = if n == 0 then s else (s ++ "-" ++ show n)
139+ let s' = if n == 0 then s else s ++ "-" ++ show n
140 in if SlideId s' `S.member` idSet
140 in if SlideId s' `S.member` idSet
141 then uniqueSlideId' (n+1) idSet s
141 then uniqueSlideId' (n+1) idSet s
142 else SlideId s'
142 else SlideId s'
@@ -152,7 +152,7 @@ runUniqueSlideId s = do
152 return sldId
152 return sldId
153
153
154addLogMessage :: LogMessage -> Pres ()
154addLogMessage :: LogMessage -> Pres ()
155−addLogMessage msg = modify $ \st -> st{stLog = msg : (stLog st)}
155+addLogMessage msg = modify $ \st -> st{stLog = msg : stLog st}
156
156
157type Pres = ReaderT WriterEnv (State WriterState)
157type Pres = ReaderT WriterEnv (State WriterState)
158
158
@@ -180,7 +180,7 @@ data DocProps = DocProps { dcTitle :: Maybe String
180
180
181data Slide = Slide { slideId :: SlideId
181data Slide = Slide { slideId :: SlideId
182 , slideLayout :: Layout
182 , slideLayout :: Layout
183− , slideNotes :: (Maybe Notes)
183+ , slideNotes :: Maybe Notes
184 } deriving (Show, Eq)
184 } deriving (Show, Eq)
185
185
186newtype SlideId = SlideId String
186newtype SlideId = SlideId String
@@ -345,12 +345,12 @@ inlineToParElems (SmallCaps ils) =
345inlineToParElems Space = inlineToParElems (Str " ")
345inlineToParElems Space = inlineToParElems (Str " ")
346inlineToParElems SoftBreak = inlineToParElems (Str " ")
346inlineToParElems SoftBreak = inlineToParElems (Str " ")
347inlineToParElems LineBreak = return [Break]
347inlineToParElems LineBreak = return [Break]
348−inlineToParElems (Link _ ils (url, title)) = do
348+inlineToParElems (Link _ ils (url, title)) =
349 local (\r ->r{envRunProps = (envRunProps r){rLink = Just $ ExternalTarget (url, title)}}) $
349 local (\r ->r{envRunProps = (envRunProps r){rLink = Just $ ExternalTarget (url, title)}}) $
350− inlinesToParElems ils
350+ inlinesToParElems ils
351−inlineToParElems (Code _ str) = do
351+inlineToParElems (Code _ str) =
352 local (\r ->r{envRunProps = (envRunProps r){rPropCode = True}}) $
352 local (\r ->r{envRunProps = (envRunProps r){rPropCode = True}}) $
353− inlineToParElems $ Str str
353+ inlineToParElems $ Str str
354inlineToParElems (Math mathtype str) =
354inlineToParElems (Math mathtype str) =
355 return [MathElem mathtype (TeXString str)]
355 return [MathElem mathtype (TeXString str)]
356inlineToParElems (Note blks) = do
356inlineToParElems (Note blks) = do
@@ -409,7 +409,7 @@ blockToParagraphs (CodeBlock attr str) =
409 Just sty ->
409 Just sty ->
410 case highlight synMap (formatSourceLines sty) attr str of
410 case highlight synMap (formatSourceLines sty) attr str of
411 Right pElems -> do pProps <- asks envParaProps
411 Right pElems -> do pProps <- asks envParaProps
412− return $ [Paragraph pProps pElems]
412+ return [Paragraph pProps pElems]
413 Left _ -> blockToParagraphs $ Para [Str str]
413 Left _ -> blockToParagraphs $ Para [Str str]
414 Nothing -> blockToParagraphs $ Para [Str str]
414 Nothing -> blockToParagraphs $ Para [Str str]
415-- We can't yet do incremental lists, but we should render a
415-- We can't yet do incremental lists, but we should render a
@@ -463,7 +463,7 @@ blockToParagraphs (DefinitionList entries) = do
463 definition <- concatMapM (blockToParagraphs . BlockQuote) blksLst
463 definition <- concatMapM (blockToParagraphs . BlockQuote) blksLst
464 return $ term ++ definition
464 return $ term ++ definition
465 concatMapM go entries
465 concatMapM go entries
466−blockToParagraphs (Div (_, ("notes" : []), _) _) = return []
466+blockToParagraphs (Div (_, "notes" : [], _) _) = return []
467blockToParagraphs (Div _ blks) = concatMapM blockToParagraphs blks
467blockToParagraphs (Div _ blks) = concatMapM blockToParagraphs blks
468blockToParagraphs blk = do
468blockToParagraphs blk = do
469 addLogMessage $ BlockNotRendered blk
469 addLogMessage $ BlockNotRendered blk
@@ -481,7 +481,7 @@ multiParBullet (b:bs) = do
481
481
482cellToParagraphs :: Alignment -> TableCell -> Pres [Paragraph]
482cellToParagraphs :: Alignment -> TableCell -> Pres [Paragraph]
483cellToParagraphs algn tblCell = do
483cellToParagraphs algn tblCell = do
484− paras <- mapM (blockToParagraphs) tblCell
484+ paras <- mapM blockToParagraphs tblCell
485 let alignment = case algn of
485 let alignment = case algn of
486 AlignLeft -> Just AlgnLeft
486 AlignLeft -> Just AlgnLeft
487 AlignRight -> Just AlgnRight
487 AlignRight -> Just AlgnRight
@@ -494,7 +494,7 @@ rowToParagraphs :: [Alignment] -> [TableCell] -> Pres [[Paragraph]]
494rowToParagraphs algns tblCells = do
494rowToParagraphs algns tblCells = do
495 -- We have to make sure we have the right number of alignments
495 -- We have to make sure we have the right number of alignments
496 let pairs = zip (algns ++ repeat AlignDefault) tblCells
496 let pairs = zip (algns ++ repeat AlignDefault) tblCells
497− mapM (\(a, tc) -> cellToParagraphs a tc) pairs
497+ mapM (uncurry cellToParagraphs) pairs
498
498
499withAttr :: Attr -> Shape -> Shape
499withAttr :: Attr -> Shape -> Shape
500withAttr attr (Pic picPr url caption) =
500withAttr attr (Pic picPr url caption) =
@@ -507,17 +507,17 @@ withAttr _ sp = sp
507
507
508blockToShape :: Block -> Pres Shape
508blockToShape :: Block -> Pres Shape
509blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
509blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
510− (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
510+ (withAttr attr . Pic def url) <$> inlinesToParElems ils
511blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
511blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
512− (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
512+ (withAttr attr . Pic def url) <$> inlinesToParElems ils
513blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
513blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
514 , Image attr ils (url, _) <- il' =
514 , Image attr ils (url, _) <- il' =
515 (withAttr attr . Pic def {picPropLink = Just $ ExternalTarget target} url) <$>
515 (withAttr attr . Pic def {picPropLink = Just $ ExternalTarget target} url) <$>
516− (inlinesToParElems ils)
516+ inlinesToParElems ils
517blockToShape (Para (il:_)) | Link _ (il':_) target <- il
517blockToShape (Para (il:_)) | Link _ (il':_) target <- il
518 , Image attr ils (url, _) <- il' =
518 , Image attr ils (url, _) <- il' =
519 (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>
519 (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>
520− (inlinesToParElems ils)
520+ inlinesToParElems ils
521blockToShape (Table caption algn _ hdrCells rows) = do
521blockToShape (Table caption algn _ hdrCells rows) = do
522 caption' <- inlinesToParElems caption
522 caption' <- inlinesToParElems caption
523 hdrCells' <- rowToParagraphs algn hdrCells
523 hdrCells' <- rowToParagraphs algn hdrCells
@@ -537,11 +537,11 @@ blockToShape blk = do paras <- blockToParagraphs blk
537
537
538combineShapes :: [Shape] -> [Shape]
538combineShapes :: [Shape] -> [Shape]
539combineShapes [] = []
539combineShapes [] = []
540−combineShapes (s : []) = [s]
540+combineShapes[s] = [s]
541−combineShapes (pic@(Pic _ _ _) : ss) = pic : combineShapes ss
541+combineShapes (pic@(Pic{}) : ss) = pic : combineShapes ss
542−combineShapes ((TextBox []) : ss) = combineShapes ss
542+combineShapes (TextBox [] : ss) = combineShapes ss
543combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
543combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
544−combineShapes ((TextBox (p:ps)) : (TextBox (p':ps')) : ss) =
544+combineShapes (TextBox (p:ps) : TextBox (p':ps') : ss) =
545 combineShapes $ TextBox ((p:ps) ++ (p':ps')) : ss
545 combineShapes $ TextBox ((p:ps) ++ (p':ps')) : ss
546combineShapes (s:ss) = s : combineShapes ss
546combineShapes (s:ss) = s : combineShapes ss
547
547
@@ -549,8 +549,8 @@ blocksToShapes :: [Block] -> Pres [Shape]
549blocksToShapes blks = combineShapes <$> mapM blockToShape blks
549blocksToShapes blks = combineShapes <$> mapM blockToShape blks
550
550
551isImage :: Inline -> Bool
551isImage :: Inline -> Bool
552−isImage (Image _ _ _) = True
552+isImage (Image{}) = True
553−isImage (Link _ ((Image _ _ _) : _) _) = True
553+isImage (Link _ (Image _ _ _ : _) _) = True
554isImage _ = False
554isImage _ = False
555
555
556splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
556splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
@@ -565,27 +565,27 @@ splitBlocks' cur acc (h@(Header n _ _) : blks) = do
565 GT -> splitBlocks' (cur ++ [h]) acc blks
565 GT -> splitBlocks' (cur ++ [h]) acc blks
566-- `blockToParagraphs` treats Plain and Para the same, so we can save
566-- `blockToParagraphs` treats Plain and Para the same, so we can save
567-- some code duplication by treating them the same here.
567-- some code duplication by treating them the same here.
568−splitBlocks' cur acc ((Plain ils) : blks) = splitBlocks' cur acc ((Para ils) : blks)
568+splitBlocks' cur acc (Plain ils : blks) = splitBlocks' cur acc (Para ils : blks)
569−splitBlocks' cur acc ((Para (il:ils)) : blks) | isImage il = do
569+splitBlocks' cur acc (Para (il:ils) : blks) | isImage il = do
570 slideLevel <- asks envSlideLevel
570 slideLevel <- asks envSlideLevel
571 case cur of
571 case cur of
572− (Header n _ _) : [] | n == slideLevel ->
572+ [(Header n _ _)] | n == slideLevel ->
573 splitBlocks' []
573 splitBlocks' []
574 (acc ++ [cur ++ [Para [il]]])
574 (acc ++ [cur ++ [Para [il]]])
575− (if null ils then blks else (Para ils) : blks)
575+ (if null ils then blks else Para ils : blks)
576 _ -> splitBlocks' []
576 _ -> splitBlocks' []
577 (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
577 (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
578− (if null ils then blks else (Para ils) : blks)
578+ (if null ils then blks else Para ils : blks)
579−splitBlocks' cur acc (tbl@(Table _ _ _ _ _) : blks) = do
579+splitBlocks' cur acc (tbl@(Table{}) : blks) = do
580 slideLevel <- asks envSlideLevel
580 slideLevel <- asks envSlideLevel
581 case cur of
581 case cur of
582− (Header n _ _) : [] | n == slideLevel ->
582+ [(Header n _ _)] | n == slideLevel ->
583 splitBlocks' [] (acc ++ [cur ++ [tbl]]) blks
583 splitBlocks' [] (acc ++ [cur ++ [tbl]]) blks
584 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl]]) blks
584 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl]]) blks
585splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes = do
585splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes = do
586 slideLevel <- asks envSlideLevel
586 slideLevel <- asks envSlideLevel
587 case cur of
587 case cur of
588− (Header n _ _) : [] | n == slideLevel ->
588+ [(Header n _ _)] | n == slideLevel ->
589 splitBlocks' [] (acc ++ [cur ++ [d]]) blks
589 splitBlocks' [] (acc ++ [cur ++ [d]]) blks
590 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d]]) blks
590 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d]]) blks
591splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
591splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
@@ -594,12 +594,12 @@ splitBlocks :: [Block] -> Pres [[Block]]
594splitBlocks = splitBlocks' [] []
594splitBlocks = splitBlocks' [] []
595
595
596blocksToSlide' :: Int -> [Block] -> Pres Slide
596blocksToSlide' :: Int -> [Block] -> Pres Slide
597−blocksToSlide' lvl ((Header n (ident, _, _) ils) : blks)
597+blocksToSlide' lvl (Header n (ident, _, _) ils : blks)
598 | n < lvl = do
598 | n < lvl = do
599 registerAnchorId ident
599 registerAnchorId ident
600 sldId <- asks envCurSlideId
600 sldId <- asks envCurSlideId
601 hdr <- inlinesToParElems ils
601 hdr <- inlinesToParElems ils
602− return $ Slide sldId (TitleSlide {titleSlideHeader = hdr}) Nothing
602+ return $ Slide sldId TitleSlide {titleSlideHeader = hdr} Nothing
603 | n == lvl = do
603 | n == lvl = do
604 registerAnchorId ident
604 registerAnchorId ident
605 hdr <- inlinesToParElems ils
605 hdr <- inlinesToParElems ils
@@ -614,7 +614,7 @@ blocksToSlide' lvl ((Header n (ident, _, _) ils) : blks)
614blocksToSlide' _ (blk : blks)
614blocksToSlide' _ (blk : blks)
615 | Div (_, classes, _) divBlks <- blk
615 | Div (_, classes, _) divBlks <- blk
616 , "columns" `elem` classes
616 , "columns" `elem` classes
617− , (Div (_, clsL, _) blksL) : (Div (_, clsR, _) blksR) : remaining <- divBlks
617+ , Div (_, clsL, _) blksL : Div (_, clsR, _) blksR : remaining <- divBlks
618 , "column" `elem` clsL, "column" `elem` clsR = do
618 , "column" `elem` clsL, "column" `elem` clsR = do
619 unless (null blks)
619 unless (null blks)
620 (mapM (addLogMessage . BlockNotRendered) blks >> return ())
620 (mapM (addLogMessage . BlockNotRendered) blks >> return ())
@@ -672,7 +672,7 @@ makeNoteEntry n blks =
672 in
672 in
673 case blks of
673 case blks of
674 (Para ils : blks') -> (Para $ enum : Space : ils) : blks'
674 (Para ils : blks') -> (Para $ enum : Space : ils) : blks'
675− _ -> (Para [enum]) : blks
675+ _ -> Para [enum] : blks
676
676
677forceFontSize :: Pixels -> Pres a -> Pres a
677forceFontSize :: Pixels -> Pres a -> Pres a
678forceFontSize px x = do
678forceFontSize px x = do
@@ -860,7 +860,7 @@ blocksToPresentationSlides blks = do
860 (\env -> env { envCurSlideId = endNotesSlideId
860 (\env -> env { envCurSlideId = endNotesSlideId
861 , envInNoteSlide = True
861 , envInNoteSlide = True
862 })
862 })
863− (blocksToSlide $ endNotesSlideBlocks)
863+ (blocksToSlide endNotesSlideBlocks)
864 return [endNotesSlide]
864 return [endNotesSlide]
865
865
866 let slides = metadataslides ++ tocSlides ++ bodyslides ++ endNotesSlides
866 let slides = metadataslides ++ tocSlides ++ bodyslides ++ endNotesSlides
@@ -889,9 +889,7 @@ documentToPresentation :: WriterOptions
889documentToPresentation opts (Pandoc meta blks) =
889documentToPresentation opts (Pandoc meta blks) =
890 let env = def { envOpts = opts
890 let env = def { envOpts = opts
891 , envMetadata = meta
891 , envMetadata = meta
892− , envSlideLevel = case writerSlideLevel opts of
892+ , envSlideLevel = fromMaybe (getSlideLevel blks) (writerSlideLevel opts)
893− Just lvl -> lvl
894− Nothing -> getSlideLevel blks
895 }
893 }
896 (presSlides, msgs) = runPres env def $ blocksToPresentationSlides blks
894 (presSlides, msgs) = runPres env def $ blocksToPresentationSlides blks
897 docProps = metaToDocProps meta
895 docProps = metaToDocProps meta
src/Text/Pandoc/Writers/RST.hs+7−8
@@ -132,7 +132,7 @@ keyToRST (label, (src, _)) = do
132-- | Return RST representation of notes.
132-- | Return RST representation of notes.
133notesToRST :: PandocMonad m => [[Block]] -> RST m Doc
133notesToRST :: PandocMonad m => [[Block]] -> RST m Doc
134notesToRST notes =
134notesToRST notes =
135− mapM (uncurry noteToRST) (zip [1..] notes) >>=
135+ zipWithM noteToRST [1..] notes >>=
136 return . vsep
136 return . vsep
137
137
138-- | Return RST representation of a note.
138-- | Return RST representation of a note.
@@ -306,8 +306,7 @@ blockToRST (OrderedList (start, style', delim) items) = do
306 let maxMarkerLength = maximum $ map length markers
306 let maxMarkerLength = maximum $ map length markers
307 let markers' = map (\m -> let s = maxMarkerLength - length m
307 let markers' = map (\m -> let s = maxMarkerLength - length m
308 in m ++ replicate s ' ') markers
308 in m ++ replicate s ' ') markers
309− contents <- mapM (uncurry orderedListItemToRST) $
309+ contents <- zipWithM orderedListItemToRST markers' items
310− zip markers' items
311 -- ensure that sublists have preceding blank line
310 -- ensure that sublists have preceding blank line
312 return $ blankline $$ chomp (vcat contents) $$ blankline
311 return $ blankline $$ chomp (vcat contents) $$ blankline
313blockToRST (DefinitionList items) = do
312blockToRST (DefinitionList items) = do
@@ -356,12 +355,12 @@ blockListToRST' topLevel blocks = do
356 let fixBlocks (b1:b2@(BlockQuote _):bs)
355 let fixBlocks (b1:b2@(BlockQuote _):bs)
357 | toClose b1 = b1 : commentSep : b2 : fixBlocks bs
356 | toClose b1 = b1 : commentSep : b2 : fixBlocks bs
358 where
357 where
359− toClose (Plain{}) = False
358+ toClose Plain{} = False
360− toClose (Header{}) = False
359+ toClose Header{} = False
361− toClose (LineBlock{}) = False
360+ toClose LineBlock{} = False
362− toClose (HorizontalRule) = False
361+ toClose HorizontalRule = False
363 toClose (Para [Image _ _ (_,'f':'i':'g':':':_)]) = True
362 toClose (Para [Image _ _ (_,'f':'i':'g':':':_)]) = True
364− toClose (Para{}) = False
363+ toClose Para{} = False
365 toClose _ = True
364 toClose _ = True
366 commentSep = RawBlock "rst" "..\n\n"
365 commentSep = RawBlock "rst" "..\n\n"
367 fixBlocks (b:bs) = b : fixBlocks bs
366 fixBlocks (b:bs) = b : fixBlocks bs
src/Text/Pandoc/Writers/RTF.hs+4−4
@@ -31,6 +31,7 @@ Conversion of 'Pandoc' documents to RTF (rich text format).
31module Text.Pandoc.Writers.RTF ( writeRTF
31module Text.Pandoc.Writers.RTF ( writeRTF
32 ) where
32 ) where
33import Control.Monad.Except (catchError, throwError)
33import Control.Monad.Except (catchError, throwError)
34+import Control.Monad
34import qualified Data.ByteString as B
35import qualified Data.ByteString as B
35import Data.Char (chr, isDigit, ord)
36import Data.Char (chr, isDigit, ord)
36import Data.List (intercalate, isSuffixOf)
37import Data.List (intercalate, isSuffixOf)
@@ -278,8 +279,7 @@ blockToRTF indent alignment (BulletList lst) = (spaceAtEnd . concat) <$>
278 mapM (listItemToRTF alignment indent (bulletMarker indent)) lst
279 mapM (listItemToRTF alignment indent (bulletMarker indent)) lst
279blockToRTF indent alignment (OrderedList attribs lst) =
280blockToRTF indent alignment (OrderedList attribs lst) =
280 (spaceAtEnd . concat) <$>
281 (spaceAtEnd . concat) <$>
281− mapM (uncurry (listItemToRTF alignment indent))
282− (zip (orderedMarkers indent attribs) lst)
282+ zipWithM (listItemToRTF alignment indent) (orderedMarkers indent attribs) lst
283blockToRTF indent alignment (DefinitionList lst) = (spaceAtEnd . concat) <$>
283blockToRTF indent alignment (DefinitionList lst) = (spaceAtEnd . concat) <$>
284 mapM (definitionListItemToRTF alignment indent) lst
284 mapM (definitionListItemToRTF alignment indent) lst
285blockToRTF indent _ HorizontalRule = return $
285blockToRTF indent _ HorizontalRule = return $
@@ -303,8 +303,8 @@ tableRowToRTF header indent aligns sizes' cols = do
303 let sizes = if all (== 0) sizes'
303 let sizes = if all (== 0) sizes'
304 then replicate (length cols) (1.0 / fromIntegral (length cols))
304 then replicate (length cols) (1.0 / fromIntegral (length cols))
305 else sizes'
305 else sizes'
306+ columns <- concat <$>
306− columns <- concat <$> mapM (uncurry (tableItemToRTF indent))
307+ zipWithM (tableItemToRTF indent) aligns cols
307− (zip aligns cols)
308 let rightEdges = tail $ scanl (\sofar new -> sofar + floor (new * totalTwips))
308 let rightEdges = tail $ scanl (\sofar new -> sofar + floor (new * totalTwips))
309 (0 :: Integer) sizes
309 (0 :: Integer) sizes
310 let cellDefs = map (\edge -> (if header
310 let cellDefs = map (\edge -> (if header
src/Text/Pandoc/Writers/Texinfo.hs+1−1
@@ -475,7 +475,7 @@ inlineToTexinfo (Link _ txt (src@('#':_), _)) = do
475inlineToTexinfo (Link _ txt (src, _)) =
475inlineToTexinfo (Link _ txt (src, _)) =
476 case txt of
476 case txt of
477 [Str x] | escapeURI x == src -> -- autolink
477 [Str x] | escapeURI x == src -> -- autolink
478− do return $ text $ "@url{" ++ x ++ "}"
478+ return $ text $ "@url{" ++ x ++ "}"
479 _ -> do contents <- escapeCommas $ inlineListToTexinfo txt
479 _ -> do contents <- escapeCommas $ inlineListToTexinfo txt
480 let src1 = stringToTexinfo src
480 let src1 = stringToTexinfo src
481 return $ text ("@uref{" ++ src1 ++ ",") <> contents <>
481 return $ text ("@uref{" ++ src1 ++ ",") <> contents <>
test/Tests/Command.hs+3−3
@@ -40,7 +40,7 @@ runTest testname pandocpath cmd inp norm = testCase testname $ do
40 -- filter \r so the tests will work on Windows machines
40 -- filter \r so the tests will work on Windows machines
41 let out = filter (/= '\r') $ err' ++ out'
41 let out = filter (/= '\r') $ err' ++ out'
42 result <- if ec == ExitSuccess
42 result <- if ec == ExitSuccess
43− then do
43+ then
44 if out == norm
44 if out == norm
45 then return TestPassed
45 then return TestPassed
46 else return
46 else return
@@ -52,6 +52,7 @@ runTest testname pandocpath cmd inp norm = testCase testname $ do
52 assertBool (show result) (result == TestPassed)
52 assertBool (show result) (result == TestPassed)
53
53
54tests :: TestTree
54tests :: TestTree
55+{-# NOINLINE tests #-}
55tests = unsafePerformIO $ do
56tests = unsafePerformIO $ do
56 pandocpath <- findPandoc
57 pandocpath <- findPandoc
57 files <- filter (".md" `isSuffixOf`) <$>
58 files <- filter (".md" `isSuffixOf`) <$>
@@ -89,7 +90,6 @@ extractCommandTest pandocpath fp = unsafePerformIO $ do
89 contents <- UTF8.toText <$> BS.readFile ("command" </> fp)
90 contents <- UTF8.toText <$> BS.readFile ("command" </> fp)
90 Pandoc _ blocks <- runIOorExplode (readMarkdown
91 Pandoc _ blocks <- runIOorExplode (readMarkdown
91 def{ readerExtensions = pandocExtensions } contents)
92 def{ readerExtensions = pandocExtensions } contents)
92− let codeblocks = map extractCode $ filter isCodeBlock $ blocks
93+ let codeblocks = map extractCode $ filter isCodeBlock blocks
93 let cases = map (runCommandTest pandocpath) $ zip [1..] codeblocks
94 let cases = map (runCommandTest pandocpath) $ zip [1..] codeblocks
94 return $ testGroup fp cases
95 return $ testGroup fp cases
95−
test/Tests/Readers/Creole.hs+1−1
@@ -224,7 +224,7 @@ tests = [
224 <> " bar")
224 <> " bar")
225 , "escaped auto link" =:
225 , "escaped auto link" =:
226 "foo ~http://foo.example.com/bar/baz.html bar"
226 "foo ~http://foo.example.com/bar/baz.html bar"
227− =?> para ("foo http://foo.example.com/bar/baz.html bar")
227+ =?> para "foo http://foo.example.com/bar/baz.html bar"
228 , "wiki link simple" =:
228 , "wiki link simple" =:
229 "foo [[http://foo.example.com/foo.png]] bar"
229 "foo [[http://foo.example.com/foo.png]] bar"
230 =?> para ("foo "
230 =?> para ("foo "
test/Tests/Readers/Docx.hs+5−6
@@ -5,6 +5,7 @@ import qualified Data.ByteString as BS
5import qualified Data.ByteString.Lazy as B
5import qualified Data.ByteString.Lazy as B
6import qualified Data.Map as M
6import qualified Data.Map as M
7import qualified Data.Text as T
7import qualified Data.Text as T
8+import Data.Maybe
8import System.IO.Unsafe
9import System.IO.Unsafe
9import Test.Tasty
10import Test.Tasty
10import Test.Tasty.HUnit
11import Test.Tasty.HUnit
@@ -46,7 +47,7 @@ compareOutput opts docxFile nativeFile = do
46 nf <- UTF8.toText <$> BS.readFile nativeFile
47 nf <- UTF8.toText <$> BS.readFile nativeFile
47 p <- runIOorExplode $ readDocx opts df
48 p <- runIOorExplode $ readDocx opts df
48 df' <- runIOorExplode $ readNative def nf
49 df' <- runIOorExplode $ readNative def nf
49− return $ (noNorm p, noNorm df')
50+ return (noNorm p, noNorm df')
50
51
51testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree
52testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree
52testCompareWithOptsIO opts name docxFile nativeFile = do
53testCompareWithOptsIO opts name docxFile nativeFile = do
@@ -87,11 +88,9 @@ compareMediaPathIO mediaPath mediaBag docxPath = do
87 Nothing -> error ("couldn't find " ++
88 Nothing -> error ("couldn't find " ++
88 mediaPath ++
89 mediaPath ++
89 " in media bag")
90 " in media bag")
90− docxBS = case docxMedia of
91− Just bs -> bs
92− Nothing -> error ("couldn't find " ++
91+ docxBS = fromMaybe (error ("couldn't find " ++
93− mediaPath ++
92+ mediaPath ++
94− " in media bag")
93+ " in media bag")) docxMedia
95 return $ mbBS == docxBS
94 return $ mbBS == docxBS
96
95
97compareMediaBagIO :: FilePath -> IO Bool
96compareMediaBagIO :: FilePath -> IO Bool
test/Tests/Readers/EPUB.hs+1−1
@@ -17,7 +17,7 @@ getMediaBag fp = do
17
17
18testMediaBag :: FilePath -> [(String, String, Int)] -> IO ()
18testMediaBag :: FilePath -> [(String, String, Int)] -> IO ()
19testMediaBag fp bag = do
19testMediaBag fp bag = do
20− actBag <- (mediaDirectory <$> getMediaBag fp)
20+ actBag <- mediaDirectory <$> getMediaBag fp
21 assertBool (show "MediaBag did not match:\nExpected: "
21 assertBool (show "MediaBag did not match:\nExpected: "
22 ++ show bag
22 ++ show bag
23 ++ "\nActual: "
23 ++ "\nActual: "
test/Tests/Readers/Muse.hs+3−3
@@ -30,8 +30,8 @@ spcSep = mconcat . intersperse space
30-- Tables and definition lists don't round-trip yet
30-- Tables and definition lists don't round-trip yet
31
31
32makeRoundTrip :: Block -> Block
32makeRoundTrip :: Block -> Block
33−makeRoundTrip (Table{}) = Para [Str "table was here"]
33+makeRoundTrip Table{} = Para [Str "table was here"]
34−makeRoundTrip (DefinitionList{}) = Para [Str "deflist was here"]
34+makeRoundTrip DefinitionList{} = Para [Str "deflist was here"]
35makeRoundTrip x = x
35makeRoundTrip x = x
36
36
37-- Demand that any AST produced by Muse reader and written by Muse writer can be read back exactly the same way.
37-- Demand that any AST produced by Muse reader and written by Muse writer can be read back exactly the same way.
@@ -44,7 +44,7 @@ roundTrip b = d'' == d'''
44 d'' = rewrite d'
44 d'' = rewrite d'
45 d''' = rewrite d''
45 d''' = rewrite d''
46 rewrite = amuse . T.pack . (++ "\n") . T.unpack .
46 rewrite = amuse . T.pack . (++ "\n") . T.unpack .
47− (purely $ writeMuse def { writerExtensions = extensionsFromList [Ext_amuse]
47+ purely (writeMuse def { writerExtensions = extensionsFromList [Ext_amuse]
48 , writerWrapText = WrapPreserve
48 , writerWrapText = WrapPreserve
49 })
49 })
50
50
test/Tests/Readers/Org/Block/Header.hs+1−1
@@ -130,7 +130,7 @@ tests =
130 mconcat [ para "foo"
130 mconcat [ para "foo"
131 , headerWith ("thing-other-thing", [], [])
131 , headerWith ("thing-other-thing", [], [])
132 1
132 1
133− ((strikeout "thing") <> " other thing")
133+ (strikeout "thing" <> " other thing")
134 ]
134 ]
135
135
136 , "Comment Trees" =:
136 , "Comment Trees" =:
test/Tests/Readers/Org/Block/List.hs+9−9
@@ -75,16 +75,16 @@ tests =
75 ]
75 ]
76
76
77 , "Bullet List with Decreasing Indent" =:
77 , "Bullet List with Decreasing Indent" =:
78− (" - Discovery\n\
78+ " - Discovery\n\
79− \ - Human After All\n") =?>
79+ \ - Human After All\n" =?>
80 mconcat [ bulletList [ plain "Discovery" ]
80 mconcat [ bulletList [ plain "Discovery" ]
81 , bulletList [ plain ("Human" <> space <> "After" <> space <> "All")]
81 , bulletList [ plain ("Human" <> space <> "After" <> space <> "All")]
82 ]
82 ]
83
83
84 , "Header follows Bullet List" =:
84 , "Header follows Bullet List" =:
85− (" - Discovery\n\
85+ " - Discovery\n\
86 \ - Human After All\n\
86 \ - Human After All\n\
87− \* Homework") =?>
87+ \* Homework" =?>
88 mconcat [ bulletList [ plain "Discovery"
88 mconcat [ bulletList [ plain "Discovery"
89 , plain ("Human" <> space <> "After" <> space <> "All")
89 , plain ("Human" <> space <> "After" <> space <> "All")
90 ]
90 ]
@@ -92,9 +92,9 @@ tests =
92 ]
92 ]
93
93
94 , "Bullet List Unindented with trailing Header" =:
94 , "Bullet List Unindented with trailing Header" =:
95− ("- Discovery\n\
95+ "- Discovery\n\
96 \- Homework\n\
96 \- Homework\n\
97− \* NotValidListItem") =?>
97+ \* NotValidListItem" =?>
98 mconcat [ bulletList [ plain "Discovery"
98 mconcat [ bulletList [ plain "Discovery"
99 , plain "Homework"
99 , plain "Homework"
100 ]
100 ]
@@ -166,14 +166,14 @@ tests =
166 , "Ordered List in Bullet List" =:
166 , "Ordered List in Bullet List" =:
167 ("- Emacs\n" <>
167 ("- Emacs\n" <>
168 " 1. Org\n") =?>
168 " 1. Org\n") =?>
169− bulletList [ (plain "Emacs") <>
169+ bulletList [ plain "Emacs" <>
170− (orderedList [ plain "Org"])
170+ orderedList [ plain "Org"]
171 ]
171 ]
172
172
173 , "Bullet List in Ordered List" =:
173 , "Bullet List in Ordered List" =:
174 ("1. GNU\n" <>
174 ("1. GNU\n" <>
175 " - Freedom\n") =?>
175 " - Freedom\n") =?>
176− orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
176+ orderedList [ plain "GNU" <> bulletList [ plain "Freedom" ] ]
177
177
178 , "Definition List" =:
178 , "Definition List" =:
179 T.unlines [ "- PLL :: phase-locked loop"
179 T.unlines [ "- PLL :: phase-locked loop"
test/Tests/Readers/Org/Directive.hs+2−2
@@ -107,8 +107,8 @@ tests =
107 ] =?>
107 ] =?>
108 mconcat [ para "first block"
108 mconcat [ para "first block"
109 , orderedList
109 , orderedList
110− [ (para "top-level section 1" <>
110+ [ para "top-level section 1" <>
111− orderedList [ para "subsection" ])
111+ orderedList [ para "subsection" ]
112 , para "top-level section 2" ]
112 , para "top-level section 2" ]
113 ]
113 ]
114
114
test/Tests/Readers/Org/Inline.hs+30−29
@@ -36,7 +36,7 @@ tests =
36
36
37 , "Underline" =:
37 , "Underline" =:
38 "_underline_" =?>
38 "_underline_" =?>
39− para (underlineSpan $ "underline")
39+ para (underlineSpan "underline")
40
40
41 , "Strikeout" =:
41 , "Strikeout" =:
42 "+Kill Bill+" =?>
42 "+Kill Bill+" =?>
@@ -127,11 +127,12 @@ tests =
127
127
128 , "Markup should work properly after a blank line" =:
128 , "Markup should work properly after a blank line" =:
129 T.unlines ["foo", "", "/bar/"] =?>
129 T.unlines ["foo", "", "/bar/"] =?>
130+ para (text "foo") <>
130− (para $ text "foo") <> (para $ emph $ text "bar")
131+ para (emph $ text "bar")
131
132
132 , "Inline math must stay within three lines" =:
133 , "Inline math must stay within three lines" =:
133 T.unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?>
134 T.unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?>
134− para ((math "a\nb\nc") <> softbreak <>
135+ para (math "a\nb\nc" <> softbreak <>
135 "$d" <> softbreak <> "e" <> softbreak <>
136 "$d" <> softbreak <> "e" <> softbreak <>
136 "f" <> softbreak <> "g$")
137 "f" <> softbreak <> "g$")
137
138
@@ -139,7 +140,7 @@ tests =
139 "$a$ $b$! $c$?" =?>
140 "$a$ $b$! $c$?" =?>
140 para (spcSep [ math "a"
141 para (spcSep [ math "a"
141 , "$b$!"
142 , "$b$!"
142− , (math "c") <> "?"
143+ , math "c" <> "?"
143 ])
144 ])
144
145
145 , "Markup may not span more than two lines" =:
146 , "Markup may not span more than two lines" =:
@@ -166,12 +167,12 @@ tests =
166 para (mconcat $ intersperse softbreak
167 para (mconcat $ intersperse softbreak
167 [ "a" <> subscript "(a(b)(c)d)"
168 [ "a" <> subscript "(a(b)(c)d)"
168 , "e" <> superscript "(f(g)h)"
169 , "e" <> superscript "(f(g)h)"
169− , "i" <> (subscript "(jk)") <> "l)"
170+ , "i" <> subscript "(jk)" <> "l)"
170− , "m" <> (superscript "()") <> "n"
171+ , "m" <> superscript "()" <> "n"
171 , "o" <> subscript "p{q{}r}"
172 , "o" <> subscript "p{q{}r}"
172 , "s" <> superscript "t{u}v"
173 , "s" <> superscript "t{u}v"
173− , "w" <> (subscript "xy") <> "z}"
174+ , "w" <> subscript "xy" <> "z}"
174− , "1" <> (superscript "") <> "2"
175+ , "1" <> superscript "" <> "2"
175 , "3" <> subscript "{}"
176 , "3" <> subscript "{}"
176 , "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
177 , "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
177 ])
178 ])
@@ -182,17 +183,17 @@ tests =
182 , testGroup "Images"
183 , testGroup "Images"
183 [ "Image" =:
184 [ "Image" =:
184 "[[./sunset.jpg]]" =?>
185 "[[./sunset.jpg]]" =?>
185− (para $ image "./sunset.jpg" "" "")
186+ para (image "./sunset.jpg" "" "")
186
187
187 , "Image with explicit file: prefix" =:
188 , "Image with explicit file: prefix" =:
188 "[[file:sunrise.jpg]]" =?>
189 "[[file:sunrise.jpg]]" =?>
189− (para $ image "sunrise.jpg" "" "")
190+ para (image "sunrise.jpg" "" "")
190
191
191 , "Multiple images within a paragraph" =:
192 , "Multiple images within a paragraph" =:
192 T.unlines [ "[[file:sunrise.jpg]]"
193 T.unlines [ "[[file:sunrise.jpg]]"
193 , "[[file:sunset.jpg]]"
194 , "[[file:sunset.jpg]]"
194 ] =?>
195 ] =?>
195− (para $ (image "sunrise.jpg" "" "")
196+ para ((image "sunrise.jpg" "" "")
196 <> softbreak
197 <> softbreak
197 <> (image "sunset.jpg" "" ""))
198 <> (image "sunset.jpg" "" ""))
198
199
@@ -200,75 +201,75 @@ tests =
200 T.unlines [ "#+ATTR_HTML: :width 50%"
201 T.unlines [ "#+ATTR_HTML: :width 50%"
201 , "[[file:guinea-pig.gif]]"
202 , "[[file:guinea-pig.gif]]"
202 ] =?>
203 ] =?>
203− (para $ imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
204+ para (imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
204 ]
205 ]
205
206
206 , "Explicit link" =:
207 , "Explicit link" =:
207 "[[http://zeitlens.com/][pseudo-random /nonsense/]]" =?>
208 "[[http://zeitlens.com/][pseudo-random /nonsense/]]" =?>
208− (para $ link "http://zeitlens.com/" ""
209+ para (link "http://zeitlens.com/" ""
209 ("pseudo-random" <> space <> emph "nonsense"))
210 ("pseudo-random" <> space <> emph "nonsense"))
210
211
211 , "Self-link" =:
212 , "Self-link" =:
212 "[[http://zeitlens.com/]]" =?>
213 "[[http://zeitlens.com/]]" =?>
213− (para $ link "http://zeitlens.com/" "" "http://zeitlens.com/")
214+ para (link "http://zeitlens.com/" "" "http://zeitlens.com/")
214
215
215 , "Absolute file link" =:
216 , "Absolute file link" =:
216 "[[/url][hi]]" =?>
217 "[[/url][hi]]" =?>
217− (para $ link "file:///url" "" "hi")
218+ para (link "file:///url" "" "hi")
218
219
219 , "Link to file in parent directory" =:
220 , "Link to file in parent directory" =:
220 "[[../file.txt][moin]]" =?>
221 "[[../file.txt][moin]]" =?>
221− (para $ link "../file.txt" "" "moin")
222+ para (link "../file.txt" "" "moin")
222
223
223 , "Empty link (for gitit interop)" =:
224 , "Empty link (for gitit interop)" =:
224 "[[][New Link]]" =?>
225 "[[][New Link]]" =?>
225− (para $ link "" "" "New Link")
226+ para (link "" "" "New Link")
226
227
227 , "Image link" =:
228 , "Image link" =:
228 "[[sunset.png][file:dusk.svg]]" =?>
229 "[[sunset.png][file:dusk.svg]]" =?>
229− (para $ link "sunset.png" "" (image "dusk.svg" "" ""))
230+ para (link "sunset.png" "" (image "dusk.svg" "" ""))
230
231
231 , "Image link with non-image target" =:
232 , "Image link with non-image target" =:
232 "[[http://example.com][./logo.png]]" =?>
233 "[[http://example.com][./logo.png]]" =?>
233− (para $ link "http://example.com" "" (image "./logo.png" "" ""))
234+ para (link "http://example.com" "" (image "./logo.png" "" ""))
234
235
235 , "Plain link" =:
236 , "Plain link" =:
236 "Posts on http://zeitlens.com/ can be funny at times." =?>
237 "Posts on http://zeitlens.com/ can be funny at times." =?>
237− (para $ spcSep [ "Posts", "on"
238+ para (spcSep [ "Posts", "on"
238 , link "http://zeitlens.com/" "" "http://zeitlens.com/"
239 , link "http://zeitlens.com/" "" "http://zeitlens.com/"
239 , "can", "be", "funny", "at", "times."
240 , "can", "be", "funny", "at", "times."
240 ])
241 ])
241
242
242 , "Angle link" =:
243 , "Angle link" =:
243 "Look at <http://moltkeplatz.de> for fnords." =?>
244 "Look at <http://moltkeplatz.de> for fnords." =?>
244− (para $ spcSep [ "Look", "at"
245+ para (spcSep [ "Look", "at"
245 , link "http://moltkeplatz.de" "" "http://moltkeplatz.de"
246 , link "http://moltkeplatz.de" "" "http://moltkeplatz.de"
246 , "for", "fnords."
247 , "for", "fnords."
247 ])
248 ])
248
249
249 , "Absolute file link" =:
250 , "Absolute file link" =:
250 "[[file:///etc/passwd][passwd]]" =?>
251 "[[file:///etc/passwd][passwd]]" =?>
251− (para $ link "file:///etc/passwd" "" "passwd")
252+ para (link "file:///etc/passwd" "" "passwd")
252
253
253 , "File link" =:
254 , "File link" =:
254 "[[file:target][title]]" =?>
255 "[[file:target][title]]" =?>
255− (para $ link "target" "" "title")
256+ para (link "target" "" "title")
256
257
257 , "Anchor" =:
258 , "Anchor" =:
258 "<<anchor>> Link here later." =?>
259 "<<anchor>> Link here later." =?>
259− (para $ spanWith ("anchor", [], []) mempty <>
260+ para (spanWith ("anchor", [], []) mempty <>
260 "Link" <> space <> "here" <> space <> "later.")
261 "Link" <> space <> "here" <> space <> "later.")
261
262
262 , "Inline code block" =:
263 , "Inline code block" =:
263 "src_emacs-lisp{(message \"Hello\")}" =?>
264 "src_emacs-lisp{(message \"Hello\")}" =?>
264− (para $ codeWith ( ""
265+ para (codeWith ( ""
265 , [ "commonlisp" ]
266 , [ "commonlisp" ]
266 , [ ("org-language", "emacs-lisp") ])
267 , [ ("org-language", "emacs-lisp") ])
267 "(message \"Hello\")")
268 "(message \"Hello\")")
268
269
269 , "Inline code block with arguments" =:
270 , "Inline code block with arguments" =:
270 "src_sh[:export both :results output]{echo 'Hello, World'}" =?>
271 "src_sh[:export both :results output]{echo 'Hello, World'}" =?>
271− (para $ codeWith ( ""
272+ para (codeWith ( ""
272 , [ "bash" ]
273 , [ "bash" ]
273 , [ ("org-language", "sh")
274 , [ ("org-language", "sh")
274 , ("export", "both")
275 , ("export", "both")
@@ -279,7 +280,7 @@ tests =
279
280
280 , "Inline code block with toggle" =:
281 , "Inline code block with toggle" =:
281 "src_sh[:toggle]{echo $HOME}" =?>
282 "src_sh[:toggle]{echo $HOME}" =?>
282− (para $ codeWith ( ""
283+ para (codeWith ( ""
283 , [ "bash" ]
284 , [ "bash" ]
284 , [ ("org-language", "sh")
285 , [ ("org-language", "sh")
285 , ("toggle", "yes")
286 , ("toggle", "yes")
@@ -415,7 +416,7 @@ tests =
415 in [
416 in [
416 "Berkeley-style in-text citation" =:
417 "Berkeley-style in-text citation" =:
417 "See @Dominik201408." =?>
418 "See @Dominik201408." =?>
418− (para $ "See "
419+ para ("See "
419 <> cite [dominikInText] "@Dominik201408"
420 <> cite [dominikInText] "@Dominik201408"
420 <> ".")
421 <> ".")
421
422
@@ -468,7 +469,7 @@ tests =
468
469
469 , "MathML symbol in LaTeX-style" =:
470 , "MathML symbol in LaTeX-style" =:
470 "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
471 "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
471− para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")
472+ para "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ')."
472
473
473 , "MathML symbol in LaTeX-style, including braces" =:
474 , "MathML symbol in LaTeX-style, including braces" =:
474 "\\Aacute{}stor" =?>
475 "\\Aacute{}stor" =?>
test/Tests/Readers/Org/Inline/Note.hs−1
@@ -84,4 +84,3 @@ tests =
84 , para "next"
84 , para "next"
85 ]
85 ]
86 ]
86 ]
87−
test/Tests/Readers/Org/Inline/Smart.hs+2−2
@@ -38,9 +38,9 @@ tests =
38
38
39 , test orgSmart "Single quotes can be followed by emphasized text"
39 , test orgSmart "Single quotes can be followed by emphasized text"
40 ("Singles on the '/meat market/'" =?>
40 ("Singles on the '/meat market/'" =?>
41− para ("Singles on the " <> (singleQuoted $ emph "meat market")))
41+ para ("Singles on the " <> singleQuoted (emph "meat market")))
42
42
43 , test orgSmart "Double quotes can be followed by emphasized text"
43 , test orgSmart "Double quotes can be followed by emphasized text"
44 ("Double income, no kids: \"/DINK/\"" =?>
44 ("Double income, no kids: \"/DINK/\"" =?>
45− para ("Double income, no kids: " <> (doubleQuoted $ emph "DINK")))
45+ para ("Double income, no kids: " <> doubleQuoted (emph "DINK")))
46 ]
46 ]
test/Tests/Readers/Org/Meta.hs+14−14
@@ -30,32 +30,32 @@ tests =
30 , "Title" =:
30 , "Title" =:
31 "#+TITLE: Hello, World" =?>
31 "#+TITLE: Hello, World" =?>
32 let titleInline = toList $ "Hello," <> space <> "World"
32 let titleInline = toList $ "Hello," <> space <> "World"
33− meta = setMeta "title" (MetaInlines titleInline) $ nullMeta
33+ meta = setMeta "title" (MetaInlines titleInline) nullMeta
34 in Pandoc meta mempty
34 in Pandoc meta mempty
35
35
36 , "Author" =:
36 , "Author" =:
37 "#+author: John /Emacs-Fanboy/ Doe" =?>
37 "#+author: John /Emacs-Fanboy/ Doe" =?>
38 let author = toList . spcSep $ [ "John", emph "Emacs-Fanboy", "Doe" ]
38 let author = toList . spcSep $ [ "John", emph "Emacs-Fanboy", "Doe" ]
39− meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta
39+ meta = setMeta "author" (MetaList [MetaInlines author]) nullMeta
40 in Pandoc meta mempty
40 in Pandoc meta mempty
41
41
42 , "Multiple authors" =:
42 , "Multiple authors" =:
43 "#+author: James Dewey Watson, Francis Harry Compton Crick " =?>
43 "#+author: James Dewey Watson, Francis Harry Compton Crick " =?>
44 let watson = MetaInlines $ toList "James Dewey Watson"
44 let watson = MetaInlines $ toList "James Dewey Watson"
45 crick = MetaInlines $ toList "Francis Harry Compton Crick"
45 crick = MetaInlines $ toList "Francis Harry Compton Crick"
46− meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta
46+ meta = setMeta "author" (MetaList [watson, crick]) nullMeta
47 in Pandoc meta mempty
47 in Pandoc meta mempty
48
48
49 , "Date" =:
49 , "Date" =:
50 "#+Date: Feb. *28*, 2014" =?>
50 "#+Date: Feb. *28*, 2014" =?>
51− let date = toList . spcSep $ [ "Feb.", (strong "28") <> ",", "2014" ]
51+ let date = toList . spcSep $ [ "Feb.", strong "28" <> ",", "2014" ]
52− meta = setMeta "date" (MetaInlines date) $ nullMeta
52+ meta = setMeta "date" (MetaInlines date) nullMeta
53 in Pandoc meta mempty
53 in Pandoc meta mempty
54
54
55 , "Description" =:
55 , "Description" =:
56 "#+DESCRIPTION: Explanatory text" =?>
56 "#+DESCRIPTION: Explanatory text" =?>
57 let description = "Explanatory text"
57 let description = "Explanatory text"
58− meta = setMeta "description" (MetaString description) $ nullMeta
58+ meta = setMeta "description" (MetaString description) nullMeta
59 in Pandoc meta mempty
59 in Pandoc meta mempty
60
60
61 , "Properties drawer" =:
61 , "Properties drawer" =:
@@ -94,7 +94,7 @@ tests =
94 , "#+author: Max"
94 , "#+author: Max"
95 ] =?>
95 ] =?>
96 let author = MetaInlines [Str "Max"]
96 let author = MetaInlines [Str "Max"]
97− meta = setMeta "author" (MetaList [author]) $ nullMeta
97+ meta = setMeta "author" (MetaList [author]) nullMeta
98 in Pandoc meta mempty
98 in Pandoc meta mempty
99
99
100 , "Logbook drawer" =:
100 , "Logbook drawer" =:
@@ -135,7 +135,7 @@ tests =
135
135
136 , "Search links are read as emph" =:
136 , "Search links are read as emph" =:
137 "[[Wally][Where's Wally?]]" =?>
137 "[[Wally][Where's Wally?]]" =?>
138− (para (emph $ "Where's" <> space <> "Wally?"))
138+ para (emph $ "Where's" <> space <> "Wally?")
139
139
140 , "Link to nonexistent anchor" =:
140 , "Link to nonexistent anchor" =:
141 T.unlines [ "<<link-here>> Target."
141 T.unlines [ "<<link-here>> Target."
@@ -149,25 +149,25 @@ tests =
149 T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s"
149 T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s"
150 , "[[wp:Org_mode][Wikipedia on Org-mode]]"
150 , "[[wp:Org_mode][Wikipedia on Org-mode]]"
151 ] =?>
151 ] =?>
152− (para (link "https://en.wikipedia.org/wiki/Org_mode" ""
152+ para (link "https://en.wikipedia.org/wiki/Org_mode" ""
153− ("Wikipedia" <> space <> "on" <> space <> "Org-mode")))
153+ ("Wikipedia" <> space <> "on" <> space <> "Org-mode"))
154
154
155 , "Link abbreviation, defined after first use" =:
155 , "Link abbreviation, defined after first use" =:
156 T.unlines [ "[[zl:non-sense][Non-sense articles]]"
156 T.unlines [ "[[zl:non-sense][Non-sense articles]]"
157 , "#+LINK: zl http://zeitlens.com/tags/%s.html"
157 , "#+LINK: zl http://zeitlens.com/tags/%s.html"
158 ] =?>
158 ] =?>
159− (para (link "http://zeitlens.com/tags/non-sense.html" ""
159+ para (link "http://zeitlens.com/tags/non-sense.html" ""
160− ("Non-sense" <> space <> "articles")))
160+ ("Non-sense" <> space <> "articles"))
161
161
162 , "Link abbreviation, URL encoded arguments" =:
162 , "Link abbreviation, URL encoded arguments" =:
163 T.unlines [ "#+link: expl http://example.com/%h/foo"
163 T.unlines [ "#+link: expl http://example.com/%h/foo"
164 , "[[expl:Hello, World!][Moin!]]"
164 , "[[expl:Hello, World!][Moin!]]"
165 ] =?>
165 ] =?>
166− (para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!"))
166+ para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!")
167
167
168 , "Link abbreviation, append arguments" =:
168 , "Link abbreviation, append arguments" =:
169 T.unlines [ "#+link: expl http://example.com/"
169 T.unlines [ "#+link: expl http://example.com/"
170 , "[[expl:foo][bar]]"
170 , "[[expl:foo][bar]]"
171 ] =?>
171 ] =?>
172− (para (link "http://example.com/foo" "" "bar"))
172+ para (link "http://example.com/foo" "" "bar")
173 ]
173 ]
test/Tests/Readers/RST.hs+14−15
@@ -36,8 +36,8 @@ tests = [ "line block with blank line" =:
36 , ":Parameter i: integer"
36 , ":Parameter i: integer"
37 , ":Final: item"
37 , ":Final: item"
38 , " on two lines" ]
38 , " on two lines" ]
39− =?> ( doc
39+ =?>
40− $ para "para" <>
40+ doc (para "para" <>
41 definitionList [ (str "Hostname", [para "media08"])
41 definitionList [ (str "Hostname", [para "media08"])
42 , (text "IP address", [para "10.0.0.19"])
42 , (text "IP address", [para "10.0.0.19"])
43 , (str "Size", [para "3ru"])
43 , (str "Size", [para "3ru"])
@@ -56,10 +56,10 @@ tests = [ "line block with blank line" =:
56 , ""
56 , ""
57 , ":Version: 1"
57 , ":Version: 1"
58 ]
58 ]
59− =?> ( setMeta "version" (para "1")
59+ =?>
60− $ setMeta "title" ("Title" :: Inlines)
60+ setMeta "version" (para "1") (setMeta "title" ("Title" :: Inlines)
61 $ setMeta "subtitle" ("Subtitle" :: Inlines)
61 $ setMeta "subtitle" ("Subtitle" :: Inlines)
62− $ doc mempty )
62+ $ doc mempty)
63 , "with inline markup" =: T.unlines
63 , "with inline markup" =: T.unlines
64 [ ":*Date*: today"
64 [ ":*Date*: today"
65 , ""
65 , ""
@@ -73,8 +73,8 @@ tests = [ "line block with blank line" =:
73 , ".. _two: http://example.com"
73 , ".. _two: http://example.com"
74 , ".. _three: http://example.org"
74 , ".. _three: http://example.org"
75 ]
75 ]
76+ =?>
76− =?> ( setMeta "date" (str "today")
77+ setMeta "date" (str "today") (doc
77− $ doc
78 $ definitionList [ (emph "one", [para "emphasis"])
78 $ definitionList [ (emph "one", [para "emphasis"])
79 , (link "http://example.com" "" "two", [para "reference"])
79 , (link "http://example.com" "" "two", [para "reference"])
80 , (link "http://example.org" "" "three", [para "another one"])
80 , (link "http://example.org" "" "three", [para "another one"])
@@ -102,13 +102,12 @@ tests = [ "line block with blank line" =:
102 , " def func(x):"
102 , " def func(x):"
103 , " return y"
103 , " return y"
104 ] =?>
104 ] =?>
105− ( doc $ codeBlockWith
105+ doc (codeBlockWith
106 ( ""
106 ( ""
107 , ["sourceCode", "python", "numberLines", "class1", "class2", "class3"]
107 , ["sourceCode", "python", "numberLines", "class1", "class2", "class3"]
108 , [ ("startFrom", "34") ]
108 , [ ("startFrom", "34") ]
109 )
109 )
110− "def func(x):\n return y"
110+ "def func(x):\n return y")
111− )
112 , "Code directive with number-lines, no line specified" =: T.unlines
111 , "Code directive with number-lines, no line specified" =: T.unlines
113 [ ".. code::python"
112 [ ".. code::python"
114 , " :number-lines: "
113 , " :number-lines: "
@@ -116,13 +115,12 @@ tests = [ "line block with blank line" =:
116 , " def func(x):"
115 , " def func(x):"
117 , " return y"
116 , " return y"
118 ] =?>
117 ] =?>
119− ( doc $ codeBlockWith
118+ doc (codeBlockWith
120 ( ""
119 ( ""
121 , ["sourceCode", "python", "numberLines"]
120 , ["sourceCode", "python", "numberLines"]
122 , [ ("startFrom", "") ]
121 , [ ("startFrom", "") ]
123 )
122 )
124− "def func(x):\n return y"
123+ "def func(x):\n return y")
125− )
126 , testGroup "literal / line / code blocks"
124 , testGroup "literal / line / code blocks"
127 [ "indented literal block" =: T.unlines
125 [ "indented literal block" =: T.unlines
128 [ "::"
126 [ "::"
@@ -131,7 +129,8 @@ tests = [ "line block with blank line" =:
131 , ""
129 , ""
132 , " can go on for many lines"
130 , " can go on for many lines"
133 , "but must stop here"]
131 , "but must stop here"]
134− =?> (doc $
132+ =?>
133+ doc (
135 codeBlock "block quotes\n\ncan go on for many lines" <>
134 codeBlock "block quotes\n\ncan go on for many lines" <>
136 para "but must stop here")
135 para "but must stop here")
137 , "line block with 3 lines" =: "| a\n| b\n| c"
136 , "line block with 3 lines" =: "| a\n| b\n| c"
@@ -185,6 +184,6 @@ tests = [ "line block with blank line" =:
185 , ".. [1]"
184 , ".. [1]"
186 , " bar"
185 , " bar"
187 ] =?>
186 ] =?>
188− (para $ "foo" <> (note $ para "bar"))
187+ para ("foo" <> (note $ para "bar"))
189 ]
188 ]
190 ]
189 ]
test/Tests/Readers/Txt2Tags.hs+4−4
@@ -30,11 +30,11 @@ simpleTable' :: Int
30 -> [Blocks]
30 -> [Blocks]
31 -> [[Blocks]]
31 -> [[Blocks]]
32 -> Blocks
32 -> Blocks
33−simpleTable' n = table "" (take n $ repeat (AlignCenter, 0.0))
33+simpleTable' n = table "" (replicate n (AlignCenter, 0.0))
34
34
35tests :: [TestTree]
35tests :: [TestTree]
36tests =
36tests =
37− [ testGroup "Inlines" $
37+ [ testGroup "Inlines"
38 [ "Plain String" =:
38 [ "Plain String" =:
39 "Hello, World" =?>
39 "Hello, World" =?>
40 para (spcSep [ "Hello,", "World" ])
40 para (spcSep [ "Hello,", "World" ])
@@ -114,7 +114,7 @@ tests =
114
114
115 ]
115 ]
116
116
117− , testGroup "Basic Blocks" $
117+ , testGroup "Basic Blocks"
118 ["Paragraph, lines grouped together" =:
118 ["Paragraph, lines grouped together" =:
119 "A paragraph\n A blank line ends the \n current paragraph\n"
119 "A paragraph\n A blank line ends the \n current paragraph\n"
120 =?> para "A paragraph\n A blank line ends the\n current paragraph"
120 =?> para "A paragraph\n A blank line ends the\n current paragraph"
@@ -197,7 +197,7 @@ tests =
197
197
198 ]
198 ]
199
199
200− , testGroup "Lists" $
200+ , testGroup "Lists"
201 [ "Simple Bullet Lists" =:
201 [ "Simple Bullet Lists" =:
202 ("- Item1\n" <>
202 ("- Item1\n" <>
203 "- Item2\n") =?>
203 "- Item2\n") =?>
test/Tests/Shared.hs+18−18
@@ -19,21 +19,21 @@ tests = [ testGroup "compactifyDL"
19
19
20testCollapse :: [TestTree]
20testCollapse :: [TestTree]
21testCollapse = map (testCase "collapse")
21testCollapse = map (testCase "collapse")
22− [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
22+ [ collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])
23− , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
23+ , collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])
24− , (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]]))
24+ , collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])
25− , (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"]))
25+ , collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])
26− , (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"]))
26+ , collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])
27− , (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"]))
27+ , collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])
28− , (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"]))
28+ , collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])
29− , (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""]))
29+ , collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])
30− , (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""]))
30+ , collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])
31− , (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."]))
31+ , collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])
32− , (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."]))
32+ , collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])
33− , (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."]))
33+ , collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])
34− , (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."]))
34+ , collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])
35− , (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"]))
35+ , collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])
36− , (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"]))
36+ , collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])
37− , (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"]))
37+ , collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])
38− , (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"]))
38+ , collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])
39− , (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))]
39+ , collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"])]
test/Tests/Writers/ConTeXt.hs+3−4
@@ -41,9 +41,9 @@ tests = [ testGroup "inline code"
41 , "without '}'" =: code "]" =?> "\\type{]}"
41 , "without '}'" =: code "]" =?> "\\type{]}"
42 , testProperty "code property" $ \s -> null s ||
42 , testProperty "code property" $ \s -> null s ||
43 if '{' `elem` s || '}' `elem` s
43 if '{' `elem` s || '}' `elem` s
44− then (context' $ code s) == "\\mono{" ++
44+ then context' (code s) == "\\mono{" ++
45− (context' $ str s) ++ "}"
45+ context' (str s) ++ "}"
46− else (context' $ code s) == "\\type{" ++ s ++ "}"
46+ else context' (code s) == "\\type{" ++ s ++ "}"
47 ]
47 ]
48 , testGroup "headers"
48 , testGroup "headers"
49 [ "level 1" =:
49 [ "level 1" =:
@@ -124,4 +124,3 @@ tests = [ testGroup "inline code"
124 , "\\stopplacetable" ]
124 , "\\stopplacetable" ]
125 ]
125 ]
126 ]
126 ]
127−
test/Tests/Writers/Docbook.hs+1−1
@@ -230,7 +230,7 @@ tests = [ testGroup "line blocks"
230 ]
230 ]
231 ]
231 ]
232 ]
232 ]
233− , testGroup "writer options" $
233+ , testGroup "writer options"
234 [ testGroup "top-level division" $
234 [ testGroup "top-level division" $
235 let
235 let
236 headers = header 1 (text "header1")
236 headers = header 1 (text "header1")
test/Tests/Writers/FB2.hs+1−1
@@ -23,7 +23,7 @@ tests = [ testGroup "block elements"
23 ]
23 ]
24 , testGroup "inlines"
24 , testGroup "inlines"
25 [
25 [
26− "Emphasis" =: emph ("emphasized")
26+ "Emphasis" =: emph "emphasized"
27 =?> fb2 "<emphasis>emphasized</emphasis>"
27 =?> fb2 "<emphasis>emphasized</emphasis>"
28 ]
28 ]
29 , "bullet list" =: bulletList [ plain $ text "first"
29 , "bullet list" =: bulletList [ plain $ text "first"
test/Tests/Writers/JATS.hs−2
@@ -120,5 +120,3 @@ tests = [ testGroup "inline code"
120 \</sec>"
120 \</sec>"
121 ]
121 ]
122 ]
122 ]
123−
124−
test/Tests/Writers/Markdown.hs+21−21
@@ -80,7 +80,7 @@ noteTestDoc =
80 ".") <>
80 ".") <>
81 blockQuote (para ("A note inside a block quote." <>
81 blockQuote (para ("A note inside a block quote." <>
82 note (para "The second note.")) <>
82 note (para "The second note.")) <>
83− para ("A second paragraph.")) <>
83+ para "A second paragraph.") <>
84 header 1 "Second Header" <>
84 header 1 "Second Header" <>
85 para "Some more text."
85 para "Some more text."
86
86
@@ -91,7 +91,7 @@ noteTests = testGroup "note and reference location"
91 [ test (markdownWithOpts defopts)
91 [ test (markdownWithOpts defopts)
92 "footnotes at the end of a document" $
92 "footnotes at the end of a document" $
93 noteTestDoc =?>
93 noteTestDoc =?>
94− (unlines $ [ "First Header"
94+ (unlines [ "First Header"
95 , "============"
95 , "============"
96 , ""
96 , ""
97 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
97 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -112,7 +112,7 @@ noteTests = testGroup "note and reference location"
112 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock})
112 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock})
113 "footnotes at the end of blocks" $
113 "footnotes at the end of blocks" $
114 noteTestDoc =?>
114 noteTestDoc =?>
115− (unlines $ [ "First Header"
115+ (unlines [ "First Header"
116 , "============"
116 , "============"
117 , ""
117 , ""
118 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
118 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -133,7 +133,7 @@ noteTests = testGroup "note and reference location"
133 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
133 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
134 "footnotes and reference links at the end of blocks" $
134 "footnotes and reference links at the end of blocks" $
135 noteTestDoc =?>
135 noteTestDoc =?>
136− (unlines $ [ "First Header"
136+ (unlines [ "First Header"
137 , "============"
137 , "============"
138 , ""
138 , ""
139 , "This is a footnote.[^1] And this is a [link]."
139 , "This is a footnote.[^1] And this is a [link]."
@@ -156,7 +156,7 @@ noteTests = testGroup "note and reference location"
156 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfSection})
156 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfSection})
157 "footnotes at the end of section" $
157 "footnotes at the end of section" $
158 noteTestDoc =?>
158 noteTestDoc =?>
159− (unlines $ [ "First Header"
159+ (unlines [ "First Header"
160 , "============"
160 , "============"
161 , ""
161 , ""
162 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
162 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -186,27 +186,27 @@ shortcutLinkRefsTests =
186 (=:) = test (purely (writeMarkdown defopts{writerReferenceLinks = True}) . toPandoc)
186 (=:) = test (purely (writeMarkdown defopts{writerReferenceLinks = True}) . toPandoc)
187 in testGroup "Shortcut reference links"
187 in testGroup "Shortcut reference links"
188 [ "Simple link (shortcutable)"
188 [ "Simple link (shortcutable)"
189− =: (para (link "/url" "title" "foo"))
189+ =: para (link "/url" "title" "foo")
190 =?> "[foo]\n\n [foo]: /url \"title\""
190 =?> "[foo]\n\n [foo]: /url \"title\""
191 , "Followed by another link (unshortcutable)"
191 , "Followed by another link (unshortcutable)"
192− =: (para ((link "/url1" "title1" "first")
192+ =: para ((link "/url1" "title1" "first")
193− <> (link "/url2" "title2" "second")))
193+ <> (link "/url2" "title2" "second"))
194 =?> unlines [ "[first][][second]"
194 =?> unlines [ "[first][][second]"
195 , ""
195 , ""
196 , " [first]: /url1 \"title1\""
196 , " [first]: /url1 \"title1\""
197 , " [second]: /url2 \"title2\""
197 , " [second]: /url2 \"title2\""
198 ]
198 ]
199 , "Followed by space and another link (unshortcutable)"
199 , "Followed by space and another link (unshortcutable)"
200− =: (para ((link "/url1" "title1" "first") <> " "
200+ =: para ((link "/url1" "title1" "first") <> " "
201− <> (link "/url2" "title2" "second")))
201+ <> (link "/url2" "title2" "second"))
202 =?> unlines [ "[first][] [second]"
202 =?> unlines [ "[first][] [second]"
203 , ""
203 , ""
204 , " [first]: /url1 \"title1\""
204 , " [first]: /url1 \"title1\""
205 , " [second]: /url2 \"title2\""
205 , " [second]: /url2 \"title2\""
206 ]
206 ]
207 , "Reference link is used multiple times (unshortcutable)"
207 , "Reference link is used multiple times (unshortcutable)"
208− =: (para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
208+ =: para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
209− <> (link "/url3" "" "foo")))
209+ <> (link "/url3" "" "foo"))
210 =?> unlines [ "[foo][][foo][1][foo][2]"
210 =?> unlines [ "[foo][][foo][1][foo][2]"
211 , ""
211 , ""
212 , " [foo]: /url1"
212 , " [foo]: /url1"
@@ -214,8 +214,8 @@ shortcutLinkRefsTests =
214 , " [2]: /url3"
214 , " [2]: /url3"
215 ]
215 ]
216 , "Reference link is used multiple times (unshortcutable)"
216 , "Reference link is used multiple times (unshortcutable)"
217− =: (para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
217+ =: para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
218− <> " " <> (link "/url3" "" "foo")))
218+ <> " " <> (link "/url3" "" "foo"))
219 =?> unlines [ "[foo][] [foo][1] [foo][2]"
219 =?> unlines [ "[foo][] [foo][1] [foo][2]"
220 , ""
220 , ""
221 , " [foo]: /url1"
221 , " [foo]: /url1"
@@ -223,43 +223,43 @@ shortcutLinkRefsTests =
223 , " [2]: /url3"
223 , " [2]: /url3"
224 ]
224 ]
225 , "Reference link is followed by text in brackets"
225 , "Reference link is followed by text in brackets"
226− =: (para ((link "/url" "" "link") <> "[text in brackets]"))
226+ =: para ((link "/url" "" "link") <> "[text in brackets]")
227 =?> unlines [ "[link][]\\[text in brackets\\]"
227 =?> unlines [ "[link][]\\[text in brackets\\]"
228 , ""
228 , ""
229 , " [link]: /url"
229 , " [link]: /url"
230 ]
230 ]
231 , "Reference link is followed by space and text in brackets"
231 , "Reference link is followed by space and text in brackets"
232− =: (para ((link "/url" "" "link") <> " [text in brackets]"))
232+ =: para ((link "/url" "" "link") <> " [text in brackets]")
233 =?> unlines [ "[link][] \\[text in brackets\\]"
233 =?> unlines [ "[link][] \\[text in brackets\\]"
234 , ""
234 , ""
235 , " [link]: /url"
235 , " [link]: /url"
236 ]
236 ]
237 , "Reference link is followed by RawInline"
237 , "Reference link is followed by RawInline"
238− =: (para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]"))
238+ =: para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]")
239 =?> unlines [ "[link][][rawText]"
239 =?> unlines [ "[link][][rawText]"
240 , ""
240 , ""
241 , " [link]: /url"
241 , " [link]: /url"
242 ]
242 ]
243 , "Reference link is followed by space and RawInline"
243 , "Reference link is followed by space and RawInline"
244− =: (para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]"))
244+ =: para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]")
245 =?> unlines [ "[link][] [rawText]"
245 =?> unlines [ "[link][] [rawText]"
246 , ""
246 , ""
247 , " [link]: /url"
247 , " [link]: /url"
248 ]
248 ]
249 , "Reference link is followed by RawInline with space"
249 , "Reference link is followed by RawInline with space"
250− =: (para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]"))
250+ =: para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]")
251 =?> unlines [ "[link][] [rawText]"
251 =?> unlines [ "[link][] [rawText]"
252 , ""
252 , ""
253 , " [link]: /url"
253 , " [link]: /url"
254 ]
254 ]
255 , "Reference link is followed by citation"
255 , "Reference link is followed by citation"
256− =: (para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
256+ =: para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
257 =?> unlines [ "[link][][@author]"
257 =?> unlines [ "[link][][@author]"
258 , ""
258 , ""
259 , " [link]: /url"
259 , " [link]: /url"
260 ]
260 ]
261 , "Reference link is followed by space and citation"
261 , "Reference link is followed by space and citation"
262− =: (para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
262+ =: para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
263 =?> unlines [ "[link][] [@author]"
263 =?> unlines [ "[link][] [@author]"
264 , ""
264 , ""
265 , " [link]: /url"
265 , " [link]: /url"
test/Tests/Writers/Native.hs+1−1
@@ -18,5 +18,5 @@ p_write_blocks_rt bs =
18tests :: [TestTree]
18tests :: [TestTree]
19tests = [ testProperty "p_write_rt" p_write_rt
19tests = [ testProperty "p_write_rt" p_write_rt
20 , testProperty "p_write_blocks_rt" $ mapSize
20 , testProperty "p_write_blocks_rt" $ mapSize
21− (\x -> if x > 3 then 3 else x) $ p_write_blocks_rt
21+ (\x -> if x > 3 then 3 else x) p_write_blocks_rt
22 ]
22 ]
test/Tests/Writers/Powerpoint.hs+6−6
@@ -72,7 +72,7 @@ numSlideTests = testGroup "Number of slides in output"
72 def
72 def
73 (doc $
73 (doc $
74 para "first slide" <>
74 para "first slide" <>
75− (para $ image "lalune.jpg" "" "") <>
75+ para (image "lalune.jpg" "" "") <>
76 para "foo")
76 para "foo")
77 , testNumberOfSlides
77 , testNumberOfSlides
78 "With image slide, header" 3
78 "With image slide, header" 3
@@ -80,14 +80,14 @@ numSlideTests = testGroup "Number of slides in output"
80 (doc $
80 (doc $
81 para "first slide" <>
81 para "first slide" <>
82 header 2 "image header" <>
82 header 2 "image header" <>
83− (para $ image "lalune.jpg" "" "") <>
83+ para (image "lalune.jpg" "" "") <>
84 para "foo")
84 para "foo")
85 , testNumberOfSlides
85 , testNumberOfSlides
86 "With table, no header" 3
86 "With table, no header" 3
87 def
87 def
88 (doc $
88 (doc $
89 para "first slide" <>
89 para "first slide" <>
90− (simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]]) <>
90+ simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]] <>
91 para "foo")
91 para "foo")
92 , testNumberOfSlides
92 , testNumberOfSlides
93 "With table, header" 3
93 "With table, header" 3
@@ -95,7 +95,7 @@ numSlideTests = testGroup "Number of slides in output"
95 (doc $
95 (doc $
96 para "first slide" <>
96 para "first slide" <>
97 header 2 "table header" <>
97 header 2 "table header" <>
98− (simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]]) <>
98+ simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]] <>
99 para "foo")
99 para "foo")
100 , testNumberOfSlides
100 , testNumberOfSlides
101 "hrule" 2
101 "hrule" 2
@@ -117,7 +117,7 @@ contentTypesFileExists opts pd =
117 testCase "Existence of [Content_Types].xml file" $
117 testCase "Existence of [Content_Types].xml file" $
118 do archive <- getPptxArchive opts pd
118 do archive <- getPptxArchive opts pd
119 assertBool "Missing [Content_Types].xml file" $
119 assertBool "Missing [Content_Types].xml file" $
120− "[Content_Types].xml" `elem` (filesInArchive archive)
120+ "[Content_Types].xml" `elem` filesInArchive archive
121
121
122
122
123
123
@@ -138,7 +138,7 @@ prop_ContentOverrides pd = do
138 Nothing -> throwIO $
138 Nothing -> throwIO $
139 PandocSomeError "Missing [Content_Types].xml file"
139 PandocSomeError "Missing [Content_Types].xml file"
140 typesElem <- case parseXMLDoc contentTypes of
140 typesElem <- case parseXMLDoc contentTypes of
141− Just element -> return $ element
141+ Just element -> return element
142 Nothing -> throwIO $
142 Nothing -> throwIO $
143 PandocSomeError "[Content_Types].xml cannot be parsed"
143 PandocSomeError "[Content_Types].xml cannot be parsed"
144 let ns = findAttr (QName "xmlns" Nothing Nothing) typesElem
144 let ns = findAttr (QName "xmlns" Nothing Nothing) typesElem
test/Tests/Writers/TEI.hs+1−1
@@ -31,7 +31,7 @@ tests = [ testGroup "block elements"
31 ]
31 ]
32 , testGroup "inlines"
32 , testGroup "inlines"
33 [
33 [
34− "Emphasis" =: emph ("emphasized")
34+ "Emphasis" =: emph "emphasized"
35 =?> "<p><hi rendition=\"simple:italic\">emphasized</hi></p>"
35 =?> "<p><hi rendition=\"simple:italic\">emphasized</hi></p>"
36 ,"SingleQuoted" =: singleQuoted (text "quoted material")
36 ,"SingleQuoted" =: singleQuoted (text "quoted material")
37 =?> "<p><quote>quoted material</quote></p>"
37 =?> "<p><quote>quoted material</quote></p>"