git.iko.soy/typeable/pandoc
on master help sign in
Source code reformatting.
commit52ee19a825fad5255e15fccfdf6de8d4203b5fec authorJohn MacFarlane <jgm@berkeley.edu> dateSun 29 Oct 2017, 14:29 (9 years ago) parentf270dd9
25 files changed+202−204
src/Text/Pandoc/Class.hs+1 src/Text/Pandoc/Logging.hs+1−1 src/Text/Pandoc/Parsing.hs+64−65 src/Text/Pandoc/Readers/DocBook.hs+24−24 src/Text/Pandoc/Readers/Docx.hs+2−2 src/Text/Pandoc/Readers/Docx/Lists.hs+1−1 src/Text/Pandoc/Readers/EPUB.hs+3−3 src/Text/Pandoc/Readers/HTML.hs+63−61 src/Text/Pandoc/Readers/Muse.hs+9−9 src/Text/Pandoc/Readers/Odt/ContentReader.hs−1 src/Text/Pandoc/Readers/RST.hs+5−6 src/Text/Pandoc/Readers/Vimwiki.hs+4−6 src/Text/Pandoc/Shared.hs+1−1 src/Text/Pandoc/Slides.hs+1−1 src/Text/Pandoc/Templates.hs+3−3 src/Text/Pandoc/Writers/Docbook.hs+3−3 src/Text/Pandoc/Writers/EPUB.hs+1−1 src/Text/Pandoc/Writers/HTML.hs+2−2 src/Text/Pandoc/Writers/JATS.hs+3−3 src/Text/Pandoc/Writers/LaTeX.hs+2−2 src/Text/Pandoc/Writers/Man.hs+1−1 src/Text/Pandoc/Writers/Ms.hs+3−3 src/Text/Pandoc/Writers/RST.hs+3−3 src/Text/Pandoc/Writers/Texinfo.hs+1−1 src/Text/Pandoc/Writers/ZimWiki.hs+1−1
src/Text/Pandoc/Class.hs+1
@@ -2,6 +2,7 @@
22{-# LANGUAGE PatternGuards #-}
33{-# LANGUAGE DeriveFunctor #-}
44{-# LANGUAGE TypeSynonymInstances #-}
5+{-# LANGUAGE MultiParamTypeClasses #-}
56{-# LANGUAGE FlexibleInstances #-}
67{-# LANGUAGE GeneralizedNewtypeDeriving #-}
78{-# LANGUAGE FlexibleContexts #-}
src/Text/Pandoc/Logging.hs+1−1
@@ -45,8 +45,8 @@ import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
4545 keyOrder)
4646import qualified Data.ByteString.Lazy as BL
4747import Data.Data (Data, toConstr)
48−import Data.Typeable (Typeable)
4948import qualified Data.Text as Text
49+import Data.Typeable (Typeable)
5050import GHC.Generics (Generic)
5151import Text.Pandoc.Definition
5252import Text.Parsec.Pos
src/Text/Pandoc/Parsing.hs+64−65
@@ -1,11 +1,10 @@
1−{-# LANGUAGE
2− FlexibleContexts
3−, GeneralizedNewtypeDeriving
4−, TypeSynonymInstances
5−, MultiParamTypeClasses
6−, FlexibleInstances
7−, IncoherentInstances #-}
8−
1+{-# LANGUAGE ExplicitForAll #-}
2+{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleInstances #-}
4+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+{-# LANGUAGE IncoherentInstances #-}
6+{-# LANGUAGE MultiParamTypeClasses #-}
7+{-# LANGUAGE TypeSynonymInstances #-}
98{-
109Copyright (C) 2006-2017 John MacFarlane <jgm@berkeley.edu>
1110
@@ -187,34 +186,34 @@ module Text.Pandoc.Parsing ( takeWhileP,
187186 )
188187where
189188
189+import Control.Monad.Identity
190+import Control.Monad.Reader
191+import Data.Char (chr, isAlphaNum, isAscii, isHexDigit, isPunctuation, isSpace,
192+ ord, toLower, toUpper)
193+import Data.Default
194+import Data.List (intercalate, isSuffixOf, transpose)
195+import qualified Data.Map as M
196+import Data.Maybe (catMaybes)
197+import Data.Monoid ((<>))
198+import qualified Data.Set as Set
190199import Data.Text (Text)
200+import Text.HTML.TagSoup.Entity (lookupEntity)
201+import Text.Pandoc.Asciify (toAsciiChar)
202+import Text.Pandoc.Builder (Blocks, HasMeta (..), Inlines, trimInlines)
203+import qualified Text.Pandoc.Builder as B
204+import Text.Pandoc.Class (PandocMonad, readFileFromDirs, report)
191205import Text.Pandoc.Definition
206+import Text.Pandoc.Logging
192207import Text.Pandoc.Options
193−import Text.Pandoc.Builder (Blocks, Inlines, HasMeta(..), trimInlines)
194−import qualified Text.Pandoc.Builder as B
195−import Text.Pandoc.XML (fromEntities)
208+import Text.Pandoc.Readers.LaTeX.Types (Macro)
209+import Text.Pandoc.Shared
196210import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
211+import Text.Pandoc.XML (fromEntities)
197212import Text.Parsec hiding (token)
198−import Text.Parsec.Pos (newPos, initialPos, updatePosString)
199−import Data.Char ( toLower, toUpper, ord, chr, isAscii, isAlphaNum,
200− isHexDigit, isSpace, isPunctuation )
201−import Data.List ( intercalate, transpose, isSuffixOf )
202−import Text.Pandoc.Shared
203−import qualified Data.Map as M
204−import Text.Pandoc.Readers.LaTeX.Types (Macro)
205−import Text.HTML.TagSoup.Entity ( lookupEntity )
206−import Text.Pandoc.Asciify (toAsciiChar)
207−import Data.Monoid ((<>))
208−import Text.Pandoc.Class (PandocMonad, readFileFromDirs, report)
209−import Text.Pandoc.Logging
210−import Data.Default
211−import qualified Data.Set as Set
212−import Control.Monad.Reader
213−import Control.Monad.Identity
214−import Data.Maybe (catMaybes)
213+import Text.Parsec.Pos (initialPos, newPos, updatePosString)
215214
216−import Text.Pandoc.Error
217215import Control.Monad.Except
216+import Text.Pandoc.Error
218217
219218type Parser t s = Parsec t s
220219
@@ -670,9 +669,9 @@ withRaw parser = do
670669 let (l2,c2) = (sourceLine pos2, sourceColumn pos2)
671670 let inplines = take ((l2 - l1) + 1) $ lines inp
672671 let raw = case inplines of
673− [] -> ""
674− [l] -> take (c2 - c1) l
675− ls -> unlines (init ls) ++ take (c2 - 1) (last ls)
672+ [] -> ""
673+ [l] -> take (c2 - c1) l
674+ ls -> unlines (init ls) ++ take (c2 - 1) (last ls)
676675 return (result, raw)
677676
678677-- | Parses backslash, then applies character parser.
@@ -688,11 +687,11 @@ characterReference = try $ do
688687 ent <- many1Till nonspaceChar (char ';')
689688 let ent' = case ent of
690689 '#':'X':xs -> '#':'x':xs -- workaround tagsoup bug
691− '#':_ -> ent
692− _ -> ent ++ ";"
690+ '#':_ -> ent
691+ _ -> ent ++ ";"
693692 case lookupEntity ent' of
694− Just (c : _) -> return c
695− _ -> fail "entity not found"
693+ Just (c : _) -> return c
694+ _ -> fail "entity not found"
696695
697696-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
698697upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
@@ -1006,7 +1005,7 @@ removeOneLeadingSpace xs =
10061005 if all startsWithSpace xs
10071006 then map (drop 1) xs
10081007 else xs
1009− where startsWithSpace "" = True
1008+ where startsWithSpace "" = True
10101009 startsWithSpace (y:_) = y == ' '
10111010
10121011-- | Parse footer for a grid table.
@@ -1042,36 +1041,36 @@ testStringWith parser str = UTF8.putStrLn $ show $
10421041
10431042-- | Parsing options.
10441043data ParserState = ParserState
1045− { stateOptions :: ReaderOptions, -- ^ User options
1046− stateParserContext :: ParserContext, -- ^ Inside list?
1047− stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
1048− stateAllowLinks :: Bool, -- ^ Allow parsing of links
1049− stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph
1050− stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed
1051− stateKeys :: KeyTable, -- ^ List of reference keys
1052− stateHeaderKeys :: KeyTable, -- ^ List of implicit header ref keys
1053− stateSubstitutions :: SubstTable, -- ^ List of substitution references
1054− stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
1055− stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
1056− stateNoteRefs :: Set.Set String, -- ^ List of note references used
1057− stateMeta :: Meta, -- ^ Document metadata
1058− stateMeta' :: F Meta, -- ^ Document metadata
1059− stateCitations :: M.Map String String, -- ^ RST-style citations
1060− stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
1061− stateHeaders :: M.Map Inlines String, -- ^ List of headers and ids (used for implicit ref links)
1062− stateIdentifiers :: Set.Set String, -- ^ Header identifiers used
1063− stateNextExample :: Int, -- ^ Number of next example
1064− stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
1065− stateMacros :: M.Map Text Macro, -- ^ Table of macros defined so far
1066− stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role
1067− stateRstCustomRoles :: M.Map String (String, Maybe String, Attr), -- ^ Current rST custom text roles
1044+ { stateOptions :: ReaderOptions, -- ^ User options
1045+ stateParserContext :: ParserContext, -- ^ Inside list?
1046+ stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
1047+ stateAllowLinks :: Bool, -- ^ Allow parsing of links
1048+ stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph
1049+ stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed
1050+ stateKeys :: KeyTable, -- ^ List of reference keys
1051+ stateHeaderKeys :: KeyTable, -- ^ List of implicit header ref keys
1052+ stateSubstitutions :: SubstTable, -- ^ List of substitution references
1053+ stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
1054+ stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
1055+ stateNoteRefs :: Set.Set String, -- ^ List of note references used
1056+ stateMeta :: Meta, -- ^ Document metadata
1057+ stateMeta' :: F Meta, -- ^ Document metadata
1058+ stateCitations :: M.Map String String, -- ^ RST-style citations
1059+ stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
1060+ stateHeaders :: M.Map Inlines String, -- ^ List of headers and ids (used for implicit ref links)
1061+ stateIdentifiers :: Set.Set String, -- ^ Header identifiers used
1062+ stateNextExample :: Int, -- ^ Number of next example
1063+ stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
1064+ stateMacros :: M.Map Text Macro, -- ^ Table of macros defined so far
1065+ stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role
1066+ stateRstCustomRoles :: M.Map String (String, Maybe String, Attr), -- ^ Current rST custom text roles
10681067 -- Triple represents: 1) Base role, 2) Optional format (only for :raw:
10691068 -- roles), 3) Additional classes (rest of Attr is unused)).
1070− stateCaption :: Maybe Inlines, -- ^ Caption in current environment
1071− stateInHtmlBlock :: Maybe String, -- ^ Tag type of HTML block being parsed
1072− stateFencedDivLevel :: Int, -- ^ Depth of fenced div
1073− stateContainers :: [String], -- ^ parent include files
1074− stateLogMessages :: [LogMessage], -- ^ log messages
1069+ stateCaption :: Maybe Inlines, -- ^ Caption in current environment
1070+ stateInHtmlBlock :: Maybe String, -- ^ Tag type of HTML block being parsed
1071+ stateFencedDivLevel :: Int, -- ^ Depth of fenced div
1072+ stateContainers :: [String], -- ^ parent include files
1073+ stateLogMessages :: [LogMessage], -- ^ log messages
10751074 stateMarkdownAttribute :: Bool -- ^ True if in markdown=1 context
10761075 }
10771076
src/Text/Pandoc/Readers/DocBook.hs+24−24
@@ -1,22 +1,22 @@
1+{-# LANGUAGE ExplicitForAll #-}
12module Text.Pandoc.Readers.DocBook ( readDocBook ) where
2−import Data.Char (toUpper, isSpace)
3−import Text.Pandoc.Shared (safeRead, crFilter)
4−import Text.Pandoc.Options
5−import Text.Pandoc.Definition
6−import Text.Pandoc.Builder
7−import Text.XML.Light
8−import Text.HTML.TagSoup.Entity (lookupEntity)
3+import Control.Monad.State.Strict
4+import Data.Char (isSpace, toUpper)
5+import Data.Default
96import Data.Either (rights)
7+import Data.Foldable (asum)
108import Data.Generics
11−import Control.Monad.State.Strict
129import Data.List (intersperse)
1310import Data.Maybe (fromMaybe)
14−import Text.TeXMath (readMathML, writeTeX)
15−import Data.Default
16−import Data.Foldable (asum)
17−import Text.Pandoc.Class (PandocMonad)
1811import Data.Text (Text)
1912import qualified Data.Text as T
13+import Text.HTML.TagSoup.Entity (lookupEntity)
14+import Text.Pandoc.Builder
15+import Text.Pandoc.Class (PandocMonad)
16+import Text.Pandoc.Options
17+import Text.Pandoc.Shared (crFilter, safeRead)
18+import Text.TeXMath (readMathML, writeTeX)
19+import Text.XML.Light
2020
2121{-
2222
@@ -538,12 +538,12 @@ handleInstructions ('<':'?':'a':'s':'c':'i':'i':'d':'o':'c':'-':'b':'r':'?':'>':
538538handleInstructions xs = case break (=='<') xs of
539539 (ys, []) -> ys
540540 ([], '<':zs) -> '<' : handleInstructions zs
541− (ys, zs) -> ys ++ handleInstructions zs
541+ (ys, zs) -> ys ++ handleInstructions zs
542542
543543getFigure :: PandocMonad m => Element -> DB m Blocks
544544getFigure e = do
545545 tit <- case filterChild (named "title") e of
546− Just t -> getInlines t
546+ Just t -> getInlines t
547547 Nothing -> return mempty
548548 modify $ \st -> st{ dbFigureTitle = tit }
549549 res <- getBlocks e
@@ -797,8 +797,8 @@ parseBlock (Elem e) =
797797 return $ p <> b <> x
798798 codeBlockWithLang = do
799799 let classes' = case attrValue "language" e of
800− "" -> []
801− x -> [x]
800+ "" -> []
801+ x -> [x]
802802 return $ codeBlockWith (attrValue "id" e, classes', [])
803803 $ trimNl $ strContentRecursive e
804804 parseBlockquote = do
@@ -871,11 +871,11 @@ parseBlock (Elem e) =
871871 || x == '.') w
872872 Nothing -> 0 :: Double
873873 let numrows = case bodyrows of
874− [] -> 0
875− xs -> maximum $ map length xs
874+ [] -> 0
875+ xs -> maximum $ map length xs
876876 let aligns = case colspecs of
877− [] -> replicate numrows AlignDefault
878− cs -> map toAlignment cs
877+ [] -> replicate numrows AlignDefault
878+ cs -> map toAlignment cs
879879 let widths = case colspecs of
880880 [] -> replicate numrows 0
881881 cs -> let ws = map toWidth cs
@@ -895,7 +895,7 @@ parseBlock (Elem e) =
895895 headerText <- case filterChild (named "title") e `mplus`
896896 (filterChild (named "info") e >>=
897897 filterChild (named "title")) of
898− Just t -> getInlines t
898+ Just t -> getInlines t
899899 Nothing -> return mempty
900900 modify $ \st -> st{ dbSectionLevel = n }
901901 b <- getBlocks e
@@ -989,10 +989,10 @@ parseInline (Elem e) =
989989 return $ linkWith attr href "" ils'
990990 "foreignphrase" -> emph <$> innerInlines
991991 "emphasis" -> case attrValue "role" e of
992− "bold" -> strong <$> innerInlines
993− "strong" -> strong <$> innerInlines
992+ "bold" -> strong <$> innerInlines
993+ "strong" -> strong <$> innerInlines
994994 "strikethrough" -> strikeout <$> innerInlines
995− _ -> emph <$> innerInlines
995+ _ -> emph <$> innerInlines
996996 "footnote" -> (note . mconcat) <$>
997997 mapM parseBlock (elContent e)
998998 "title" -> return mempty
src/Text/Pandoc/Readers/Docx.hs+2−2
@@ -214,14 +214,14 @@ codeDivs :: [String]
214214codeDivs = ["SourceCode"]
215215
216216runElemToInlines :: RunElem -> Inlines
217−runElemToInlines (TextRun s) = text s
217+runElemToInlines (TextRun s) = text s
218218runElemToInlines LnBrk = linebreak
219219runElemToInlines Tab = space
220220runElemToInlines SoftHyphen = text "\xad"
221221runElemToInlines NoBreakHyphen = text "\x2011"
222222
223223runElemToString :: RunElem -> String
224−runElemToString (TextRun s) = s
224+runElemToString (TextRun s) = s
225225runElemToString LnBrk = ['\n']
226226runElemToString Tab = ['\t']
227227runElemToString SoftHyphen = ['\xad']
src/Text/Pandoc/Readers/Docx/Lists.hs+1−1
@@ -157,7 +157,7 @@ flatToBullets elems = flatToBullets' (-1) elems
157157
158158singleItemHeaderToHeader :: Block -> Block
159159singleItemHeaderToHeader (OrderedList _ [[h@Header{}]]) = h
160−singleItemHeaderToHeader blk = blk
160+singleItemHeaderToHeader blk = blk
161161
162162
163163blocksToBullets :: [Block] -> [Block]
src/Text/Pandoc/Readers/EPUB.hs+3−3
@@ -1,7 +1,7 @@
1−{-# LANGUAGE FlexibleContexts #-}
1+{-# LANGUAGE FlexibleContexts #-}
22
3−{-# LANGUAGE TupleSections #-}
4−{-# LANGUAGE ViewPatterns #-}
3+{-# LANGUAGE TupleSections #-}
4+{-# LANGUAGE ViewPatterns #-}
55
66module Text.Pandoc.Readers.EPUB
77 (readEPUB)
src/Text/Pandoc/Readers/HTML.hs+63−61
@@ -1,5 +1,8 @@
1−{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses,
2−ViewPatterns, OverloadedStrings #-}
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE MultiParamTypeClasses #-}
4+{-# LANGUAGE OverloadedStrings #-}
5+{-# LANGUAGE ViewPatterns #-}
36{-
47Copyright (C) 2006-2017 John MacFarlane <jgm@berkeley.edu>
58
@@ -39,43 +42,42 @@ module Text.Pandoc.Readers.HTML ( readHtml
3942 , isCommentTag
4043 ) where
4144
45+import Control.Applicative ((<|>))
46+import Control.Arrow ((***))
47+import Control.Monad (guard, mplus, msum, mzero, unless, void)
48+import Control.Monad.Except (throwError)
49+import Control.Monad.Reader (ReaderT, ask, asks, lift, local, runReaderT)
50+import Data.Char (isAlphaNum, isDigit, isLetter)
51+import Data.Default (Default (..), def)
52+import Data.Foldable (for_)
53+import Data.List (intercalate, isPrefixOf)
54+import Data.List.Split (wordsBy)
55+import qualified Data.Map as M
56+import Data.Maybe (fromMaybe, isJust, isNothing)
57+import Data.Monoid (First (..))
58+import Data.Monoid ((<>))
59+import qualified Data.Set as Set
60+import Data.Text (Text)
61+import qualified Data.Text as T
62+import Network.URI (URI, nonStrictRelativeTo, parseURIReference)
4263import Text.HTML.TagSoup
4364import Text.HTML.TagSoup.Match
44−import Text.Pandoc.Definition
65+import Text.Pandoc.Builder (Blocks, HasMeta (..), Inlines, trimInlines)
4566import qualified Text.Pandoc.Builder as B
46−import Text.Pandoc.Builder (Blocks, Inlines, trimInlines, HasMeta(..))
47−import Text.Pandoc.Shared ( extractSpaces, addMetaField
48− , escapeURI, safeRead, crFilter, underlineSpan )
49−import Text.Pandoc.Options (
50− ReaderOptions(readerExtensions,readerStripComments), extensionEnabled,
51− Extension (Ext_epub_html_exts,
52− Ext_raw_html, Ext_native_divs, Ext_native_spans))
67+import Text.Pandoc.Class (PandocMonad (..))
68+import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
69+import Text.Pandoc.Definition
70+import Text.Pandoc.Error
5371import Text.Pandoc.Logging
72+import Text.Pandoc.Options (Extension (Ext_epub_html_exts, Ext_native_divs, Ext_native_spans, Ext_raw_html),
73+ ReaderOptions (readerExtensions, readerStripComments),
74+ extensionEnabled)
5475import Text.Pandoc.Parsing hiding ((<|>))
76+import Text.Pandoc.Shared (addMetaField, crFilter, escapeURI, extractSpaces,
77+ safeRead, underlineSpan)
5578import Text.Pandoc.Walk
56−import qualified Data.Map as M
57−import Data.Foldable ( for_ )
58−import Data.Maybe ( fromMaybe, isJust, isNothing )
59−import Data.List.Split ( wordsBy )
60−import Data.List ( intercalate, isPrefixOf )
61−import Data.Char ( isDigit, isLetter, isAlphaNum )
62−import Control.Monad ( guard, mzero, void, unless, mplus, msum )
63−import Control.Arrow ((***))
64−import Control.Applicative ( (<|>) )
65−import Data.Monoid (First (..))
66−import Data.Text (Text)
67−import qualified Data.Text as T
68−import Text.TeXMath (readMathML, writeTeX)
69−import Data.Default (Default (..), def)
70−import Control.Monad.Reader (ask, asks, local, ReaderT, runReaderT, lift)
71−import Network.URI (URI, parseURIReference, nonStrictRelativeTo)
72−import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
73−import Data.Monoid ((<>))
7479import Text.Parsec.Error
75−import qualified Data.Set as Set
76−import Text.Pandoc.Error
77−import Text.Pandoc.Class (PandocMonad(..))
78−import Control.Monad.Except (throwError)
80+import Text.TeXMath (readMathML, writeTeX)
7981
8082-- | Convert HTML-formatted string to 'Pandoc' document.
8183readHtml :: PandocMonad m
@@ -123,8 +125,8 @@ data HTMLState =
123125 }
124126
125127data HTMLLocal = HTMLLocal { quoteContext :: QuoteContext
126− , inChapter :: Bool -- ^ Set if in chapter section
127− , inPlain :: Bool -- ^ Set if in pPlain
128+ , inChapter :: Bool -- ^ Set if in chapter section
129+ , inPlain :: Bool -- ^ Set if in pPlain
128130 }
129131
130132setInChapter :: PandocMonad m => HTMLParser m s a -> HTMLParser m s a
@@ -354,16 +356,16 @@ fixPlains :: Bool -> Blocks -> Blocks
354356fixPlains inList bs = if any isParaish bs'
355357 then B.fromList $ map plainToPara bs'
356358 else bs
357− where isParaish (Para _) = True
358− isParaish (CodeBlock _ _) = True
359− isParaish (Header _ _ _) = True
360− isParaish (BlockQuote _) = True
361− isParaish (BulletList _) = not inList
362− isParaish (OrderedList _ _) = not inList
359+ where isParaish (Para _) = True
360+ isParaish (CodeBlock _ _) = True
361+ isParaish (Header _ _ _) = True
362+ isParaish (BlockQuote _) = True
363+ isParaish (BulletList _) = not inList
364+ isParaish (OrderedList _ _) = not inList
363365 isParaish (DefinitionList _) = not inList
364− isParaish _ = False
366+ isParaish _ = False
365367 plainToPara (Plain xs) = Para xs
366− plainToPara x = x
368+ plainToPara x = x
367369 bs' = B.toList bs
368370
369371pRawTag :: PandocMonad m => TagParser m Text
@@ -377,10 +379,10 @@ pRawTag = do
377379pDiv :: PandocMonad m => TagParser m Blocks
378380pDiv = try $ do
379381 guardEnabled Ext_native_divs
380− let isDivLike "div" = True
382+ let isDivLike "div" = True
381383 isDivLike "section" = True
382− isDivLike "main" = True
383− isDivLike _ = False
384+ isDivLike "main" = True
385+ isDivLike _ = False
384386 TagOpen tag attr' <- lookAhead $ pSatisfy $ tagOpen isDivLike (const True)
385387 let attr = toStringAttr attr'
386388 contents <- pInTags tag block
@@ -545,9 +547,9 @@ pCell celltype = try $ do
545547 skipMany pBlank
546548 tag <- lookAhead $
547549 pSatisfy (\t -> t ~== TagOpen celltype [] && noColOrRowSpans t)
548− let extractAlign' [] = ""
550+ let extractAlign' [] = ""
549551 extractAlign' ("text-align":x:_) = x
550− extractAlign' (_:xs) = extractAlign' xs
552+ extractAlign' (_:xs) = extractAlign' xs
551553 let extractAlign = extractAlign' . wordsBy (`elem` [' ','\t',';',':'])
552554 let align = case maybeFromAttrib "align" tag `mplus`
553555 (extractAlign <$> maybeFromAttrib "style" tag) of
@@ -603,18 +605,18 @@ pCodeBlock = try $ do
603605 let rawText = concatMap tagToString contents
604606 -- drop leading newline if any
605607 let result' = case rawText of
606− '\n':xs -> xs
607− _ -> rawText
608+ '\n':xs -> xs
609+ _ -> rawText
608610 -- drop trailing newline if any
609611 let result = case reverse result' of
610− '\n':_ -> init result'
611− _ -> result'
612+ '\n':_ -> init result'
613+ _ -> result'
612614 return $ B.codeBlockWith (mkAttr attr) result
613615
614616tagToString :: Tag Text -> String
615−tagToString (TagText s) = T.unpack s
617+tagToString (TagText s) = T.unpack s
616618tagToString (TagOpen "br" _) = "\n"
617−tagToString _ = ""
619+tagToString _ = ""
618620
619621inline :: PandocMonad m => TagParser m Inlines
620622inline = choice
@@ -893,16 +895,16 @@ pStr = do
893895 return $ B.str result
894896
895897isSpecial :: Char -> Bool
896−isSpecial '"' = True
897−isSpecial '\'' = True
898−isSpecial '.' = True
899−isSpecial '-' = True
900−isSpecial '$' = True
898+isSpecial '"' = True
899+isSpecial '\'' = True
900+isSpecial '.' = True
901+isSpecial '-' = True
902+isSpecial '$' = True
901903isSpecial '\8216' = True
902904isSpecial '\8217' = True
903905isSpecial '\8220' = True
904906isSpecial '\8221' = True
905−isSpecial _ = False
907+isSpecial _ = False
906908
907909pSymbol :: PandocMonad m => InlinesParser m Inlines
908910pSymbol = satisfy isSpecial >>= return . B.str . (:[])
@@ -1123,7 +1125,7 @@ htmlInBalanced' tagname ts = fromMaybe [] $ go 0 ts
11231125
11241126hasTagWarning :: [Tag a] -> Bool
11251127hasTagWarning (TagWarning _:_) = True
1126−hasTagWarning _ = False
1128+hasTagWarning _ = False
11271129
11281130-- | Matches a tag meeting a certain condition.
11291131htmlTag :: (HasReaderOptions st, Monad m)
@@ -1148,7 +1150,7 @@ htmlTag f = try $ do
11481150 -- in XML elemnet names
11491151 let isNameChar c = isAlphaNum c || c == ':' || c == '-' || c == '_'
11501152 let isName s = case s of
1151− [] -> False
1153+ [] -> False
11521154 (c:cs) -> isLetter c && all isNameChar cs
11531155
11541156 let endAngle = try $ do char '>'
src/Text/Pandoc/Readers/Muse.hs+9−9
@@ -1,4 +1,4 @@
1−{-# LANGUAGE FlexibleContexts #-}
1+{-# LANGUAGE FlexibleContexts #-}
22{-
33 Copyright (C) 2017 Alexander Krotov <ilabdsf@gmail.com>
44
@@ -42,23 +42,23 @@ module Text.Pandoc.Readers.Muse (readMuse) where
4242
4343import Control.Monad
4444import Control.Monad.Except (throwError)
45−import qualified Data.Map as M
4645import Data.Char (isLetter)
47−import Data.Text (Text, unpack)
4846import Data.List (stripPrefix)
47+import qualified Data.Map as M
4948import Data.Maybe (fromMaybe)
49+import Data.Text (Text, unpack)
50+import System.FilePath (takeExtension)
5051import Text.HTML.TagSoup
5152import Text.Pandoc.Builder (Blocks, Inlines)
5253import qualified Text.Pandoc.Builder as B
53−import Text.Pandoc.Class (PandocMonad(..))
54+import Text.Pandoc.Class (PandocMonad (..))
5455import Text.Pandoc.Definition
5556import Text.Pandoc.Logging
5657import Text.Pandoc.Options
57−import Text.Pandoc.Shared (crFilter)
5858import Text.Pandoc.Parsing hiding (nested)
5959import Text.Pandoc.Readers.HTML (htmlTag)
60+import Text.Pandoc.Shared (crFilter)
6061import Text.Pandoc.XML (fromEntities)
61−import System.FilePath (takeExtension)
6262
6363-- | Read Muse from an input string and return a Pandoc document.
6464readMuse :: PandocMonad m
@@ -233,7 +233,7 @@ exampleTag = do
233233 return $ return $ B.codeBlockWith attr $ chop contents
234234 where lchop s = case s of
235235 '\n':ss -> ss
236− _ -> s
236+ _ -> s
237237 rchop = reverse . lchop . reverse
238238 -- Trim up to one newline from the beginning and the end,
239239 -- in case opening and/or closing tags are on separate lines.
@@ -315,7 +315,7 @@ noteBlock = try $ do
315315 content <- mconcat <$> blocksTillNote
316316 oldnotes <- stateNotes' <$> getState
317317 case M.lookup ref oldnotes of
318− Just _ -> logMessage $ DuplicateNoteReference ref pos
318+ Just _ -> logMessage $ DuplicateNoteReference ref pos
319319 Nothing -> return ()
320320 updateState $ \s -> s{ stateNotes' = M.insert ref (pos, content) oldnotes }
321321 return mempty
@@ -445,7 +445,7 @@ definitionList = do
445445data MuseTable = MuseTable
446446 { museTableCaption :: Inlines
447447 , museTableHeaders :: [[Blocks]]
448− , museTableRows :: [[Blocks]]
448+ , museTableRows :: [[Blocks]]
449449 , museTableFooters :: [[Blocks]]
450450 }
451451
src/Text/Pandoc/Readers/Odt/ContentReader.hs−1
@@ -49,7 +49,6 @@ import Data.Maybe
4949
5050import qualified Text.XML.Light as XML
5151
52−import Text.Pandoc.Definition
5352import Text.Pandoc.Builder
5453import Text.Pandoc.MediaBag (MediaBag, insertMedia)
5554import Text.Pandoc.Shared
src/Text/Pandoc/Readers/RST.hs+5−6
@@ -36,16 +36,15 @@ import Control.Monad (forM_, guard, liftM, mplus, mzero, when)
3636import Control.Monad.Except (throwError)
3737import Control.Monad.Identity (Identity (..))
3838import Data.Char (isHexDigit, isSpace, toLower, toUpper)
39−import Data.List (deleteFirstsBy, intercalate, isInfixOf,
40− elemIndex, isSuffixOf, nub, sort, transpose, union)
39+import Data.List (deleteFirstsBy, elemIndex, intercalate, isInfixOf, isSuffixOf,
40+ nub, sort, transpose, union)
4141import qualified Data.Map as M
4242import Data.Maybe (fromMaybe, isJust)
4343import Data.Monoid ((<>))
4444import Data.Sequence (ViewR (..), viewr)
4545import Data.Text (Text)
4646import qualified Data.Text as T
47−import Text.Pandoc.Builder
48− (fromList, setMeta, Blocks, Inlines, trimInlines)
47+import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines)
4948import qualified Text.Pandoc.Builder as B
5049import Text.Pandoc.Class (PandocMonad, fetchItem, readFileFromDirs)
5150import Text.Pandoc.CSV (CSVOptions (..), defaultCSVOptions, parseCSV)
@@ -315,7 +314,7 @@ doubleHeader = do
315314 let headerTable = stateHeaderTable state
316315 let (headerTable',level) = case elemIndex (DoubleHeader c) headerTable of
317316 Just ind -> (headerTable, ind + 1)
318− Nothing -> (headerTable ++ [DoubleHeader c], length headerTable + 1)
317+ Nothing -> (headerTable ++ [DoubleHeader c], length headerTable + 1)
319318 setState (state { stateHeaderTable = headerTable' })
320319 attr <- registerHeader nullAttr txt
321320 return $ B.headerWith attr level txt
@@ -344,7 +343,7 @@ singleHeader = do
344343 let headerTable = stateHeaderTable state
345344 let (headerTable',level) = case elemIndex (SingleHeader c) headerTable of
346345 Just ind -> (headerTable, ind + 1)
347− Nothing -> (headerTable ++ [SingleHeader c], length headerTable + 1)
346+ Nothing -> (headerTable ++ [SingleHeader c], length headerTable + 1)
348347 setState (state { stateHeaderTable = headerTable' })
349348 attr <- registerHeader nullAttr txt
350349 return $ B.headerWith attr level txt
src/Text/Pandoc/Readers/Vimwiki.hs+4−6
@@ -91,12 +91,10 @@ import Text.Pandoc.Parsing (F, ParserState, ParserT, blanklines, emailAddress,
9191 registerHeader, runF, spaceChar, stateMeta',
9292 stateOptions, uri)
9393import Text.Pandoc.Shared (crFilter, splitBy, stringify, stripFirstAndLast)
94−import Text.Parsec.Char
95− (alphaNum, anyChar, char, newline, noneOf, spaces, string, oneOf,
96− space)
97−import Text.Parsec.Combinator
98− (choice, count, eof, many1, manyTill, notFollowedBy, option,
99− skipMany1, between, lookAhead)
94+import Text.Parsec.Char (alphaNum, anyChar, char, newline, noneOf, oneOf, space,
95+ spaces, string)
96+import Text.Parsec.Combinator (between, choice, count, eof, lookAhead, many1,
97+ manyTill, notFollowedBy, option, skipMany1)
10098import Text.Parsec.Prim (getState, many, try, updateState, (<|>))
10199
102100readVimwiki :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
src/Text/Pandoc/Shared.hs+1−1
@@ -520,7 +520,7 @@ uniqueIdent title' usedIdents
520520-- | True if block is a Header block.
521521isHeaderBlock :: Block -> Bool
522522isHeaderBlock (Header{}) = True
523−isHeaderBlock _ = False
523+isHeaderBlock _ = False
524524
525525-- | Shift header levels up or down.
526526headerShift :: Int -> Pandoc -> Pandoc
src/Text/Pandoc/Slides.hs+1−1
@@ -42,7 +42,7 @@ getSlideLevel = go 6
4242 go least [] = least
4343 nonHOrHR Header{} = False
4444 nonHOrHR HorizontalRule = False
45− nonHOrHR _ = True
45+ nonHOrHR _ = True
4646
4747-- | Prepare a block list to be passed to hierarchicalize.
4848prepSlides :: Int -> [Block] -> [Block]
src/Text/Pandoc/Templates.hs+3−3
@@ -1,7 +1,7 @@
1−{-# LANGUAGE FlexibleInstances #-}
1+{-# LANGUAGE FlexibleInstances #-}
22
3−{-# LANGUAGE OverloadedStrings #-}
4−{-# LANGUAGE TypeSynonymInstances #-}
3+{-# LANGUAGE OverloadedStrings #-}
4+{-# LANGUAGE TypeSynonymInstances #-}
55{-
66Copyright (C) 2009-2017 John MacFarlane <jgm@berkeley.edu>
77
src/Text/Pandoc/Writers/Docbook.hs+3−3
@@ -76,9 +76,9 @@ authorToDocbook opts name' = do
7676 let namewords = words name
7777 lengthname = length namewords
7878 (firstname, lastname) = case lengthname of
79− 0 -> ("","")
80− 1 -> ("", name)
81− n -> (unwords (take (n-1) namewords), last namewords)
79+ 0 -> ("","")
80+ 1 -> ("", name)
81+ n -> (unwords (take (n-1) namewords), last namewords)
8282 in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$
8383 inTagsSimple "surname" (text $ escapeStringForXML lastname)
8484
src/Text/Pandoc/Writers/EPUB.hs+1−1
@@ -43,7 +43,7 @@ import qualified Data.ByteString.Lazy.Char8 as B8
4343import Data.Char (isAlphaNum, isAscii, isDigit, toLower)
4444import Data.List (intercalate, isInfixOf, isPrefixOf)
4545import qualified Data.Map as M
46−import Data.Maybe (fromMaybe, mapMaybe, isNothing)
46+import Data.Maybe (fromMaybe, isNothing, mapMaybe)
4747import qualified Data.Set as Set
4848import qualified Data.Text as TS
4949import qualified Data.Text.Lazy as TL
src/Text/Pandoc/Writers/HTML.hs+2−2
@@ -421,7 +421,7 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
421421 return res
422422
423423 let isSec (Sec{}) = True
424− isSec (Blk _) = False
424+ isSec (Blk _) = False
425425 let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
426426 isPause _ = False
427427 let fragmentClass = case slideVariant of
@@ -1174,7 +1174,7 @@ isMathEnvironment s = "\\begin{" `isPrefixOf` s &&
11741174
11751175allowsMathEnvironments :: HTMLMathMethod -> Bool
11761176allowsMathEnvironments (MathJax _) = True
1177−allowsMathEnvironments MathML = True
1177+allowsMathEnvironments MathML = True
11781178allowsMathEnvironments (WebTeX _) = True
11791179allowsMathEnvironments _ = False
11801180
src/Text/Pandoc/Writers/JATS.hs+3−3
@@ -76,9 +76,9 @@ authorToJATS opts name' = do
7676 let namewords = words name
7777 lengthname = length namewords
7878 (firstname, lastname) = case lengthname of
79− 0 -> ("","")
80− 1 -> ("", name)
81− n -> (unwords (take (n-1) namewords), last namewords)
79+ 0 -> ("","")
80+ 1 -> ("", name)
81+ n -> (unwords (take (n-1) namewords), last namewords)
8282 in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$
8383 inTagsSimple "surname" (text $ escapeStringForXML lastname)
8484
src/Text/Pandoc/Writers/LaTeX.hs+2−2
@@ -135,7 +135,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do
135135 let blocks' = if method == Biblatex || method == Natbib
136136 then case reverse blocks of
137137 Div (_,["references"],_) _:xs -> reverse xs
138− _ -> blocks
138+ _ -> blocks
139139 else blocks
140140 -- see if there are internal links
141141 let isInternalLink (Link _ _ ('#':xs,_)) = [xs]
@@ -848,7 +848,7 @@ sectionHeader unnumbered ident level lst = do
848848 plain <- stringToLaTeX TextString $ concatMap stringify lst
849849 let removeInvalidInline (Note _) = []
850850 removeInvalidInline (Span (id', _, _) _) | not (null id') = []
851− removeInvalidInline (Image{}) = []
851+ removeInvalidInline (Image{}) = []
852852 removeInvalidInline x = [x]
853853 let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
854854 txtNoNotes <- inlineListToLaTeX lstNoNotes
src/Text/Pandoc/Writers/Man.hs+1−1
@@ -156,7 +156,7 @@ breakSentence [] = ([],[])
156156breakSentence xs =
157157 let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True
158158 isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True
159− isSentenceEndInline LineBreak = True
159+ isSentenceEndInline LineBreak = True
160160 isSentenceEndInline _ = False
161161 (as, bs) = break isSentenceEndInline xs
162162 in case bs of
src/Text/Pandoc/Writers/Ms.hs+3−3
@@ -191,7 +191,7 @@ breakSentence [] = ([],[])
191191breakSentence xs =
192192 let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True
193193 isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True
194− isSentenceEndInline LineBreak = True
194+ isSentenceEndInline LineBreak = True
195195 isSentenceEndInline _ = False
196196 (as, bs) = break isSentenceEndInline xs
197197 in case bs of
@@ -408,8 +408,8 @@ definitionListItemToMs opts (label, defs) = do
408408 else liftM vcat $ forM defs $ \blocks -> do
409409 let (first, rest) = case blocks of
410410 (Para x:y) -> (Plain x,y)
411− (x:y) -> (x,y)
412− [] -> (Plain [], [])
411+ (x:y) -> (x,y)
412+ [] -> (Plain [], [])
413413 -- should not happen
414414 rest' <- liftM vcat $
415415 mapM (\item -> blockToMs opts item) rest
src/Text/Pandoc/Writers/RST.hs+3−3
@@ -344,7 +344,7 @@ definitionListItemToRST (label, defs) = do
344344linesToLineBlock :: PandocMonad m => [[Inline]] -> RST m Doc
345345linesToLineBlock inlineLines = do
346346 lns <- mapM inlineListToRST inlineLines
347− return $
347+ return $
348348 vcat (map (hang 2 (text "| ")) lns) <> blankline
349349
350350-- | Convert list of Pandoc block elements to RST.
@@ -437,8 +437,8 @@ inlineListToRST lst =
437437 isComplex (Strikeout _) = True
438438 isComplex (Superscript _) = True
439439 isComplex (Subscript _) = True
440− isComplex (Link{}) = True
441− isComplex (Image{}) = True
440+ isComplex (Link{}) = True
441+ isComplex (Image{}) = True
442442 isComplex (Code _ _) = True
443443 isComplex (Math _ _) = True
444444 isComplex (Cite _ (x:_)) = isComplex x
src/Text/Pandoc/Writers/Texinfo.hs+1−1
@@ -340,7 +340,7 @@ blockListToTexinfo (x:xs) = do
340340 xs' <- blockListToTexinfo xs
341341 case xs of
342342 (CodeBlock _ _:_) -> return $ x' $$ xs'
343− _ -> return $ x' $+$ xs'
343+ _ -> return $ x' $+$ xs'
344344 _ -> do
345345 xs' <- blockListToTexinfo xs
346346 return $ x' $$ xs'
src/Text/Pandoc/Writers/ZimWiki.hs+1−1
@@ -36,8 +36,8 @@ import Control.Monad (zipWithM)
3636import Control.Monad.State.Strict (StateT, evalStateT, gets, modify)
3737import Data.Default (Default (..))
3838import Data.List (intercalate, isInfixOf, isPrefixOf, transpose)
39−import Data.Maybe (fromMaybe)
4039import qualified Data.Map as Map
40+import Data.Maybe (fromMaybe)
4141import Data.Text (Text, breakOnAll, pack)
4242import Text.Pandoc.Class (PandocMonad, report)
4343import Text.Pandoc.Definition