git.iko.soy/typeable/pandoc
on master help sign in
Stylish-haskell automatic formatting changes.
commite256c8ce1778ff6fbb2e8d59556d48fb3c53393d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 4 Mar 2017, 13:03 (10 years ago) parent0edfbf1
102 files changed+1769−1736
pandoc.hs+5−2 src/Text/Pandoc.hs+45−43 src/Text/Pandoc/App.hs+110−109 src/Text/Pandoc/Asciify.hs+1−1 src/Text/Pandoc/CSS.hs+2−2 src/Text/Pandoc/Error.hs+5−4 src/Text/Pandoc/Extensions.hs+3−2 src/Text/Pandoc/Highlighting.hs+5−5 src/Text/Pandoc/Logging.hs+28−26 src/Text/Pandoc/MIME.hs+3−3 src/Text/Pandoc/MediaBag.hs+13−12 src/Text/Pandoc/Options.hs+43−42 src/Text/Pandoc/PDF.hs+22−20 src/Text/Pandoc/Pretty.hs+34−32 src/Text/Pandoc/Process.hs+4−4 src/Text/Pandoc/Readers/CommonMark.hs+6−6 src/Text/Pandoc/Readers/Docx.hs+43−41 src/Text/Pandoc/Readers/Docx/Combine.hs+16−15 src/Text/Pandoc/Readers/Docx/Lists.hs+15−15 src/Text/Pandoc/Readers/Docx/Parse.hs+42−40 src/Text/Pandoc/Readers/Docx/StyleMap.hs+6−6 src/Text/Pandoc/Readers/Docx/Util.hs+2−2 src/Text/Pandoc/Readers/EPUB.hs+29−31 src/Text/Pandoc/Readers/Haddock.hs+9−9 src/Text/Pandoc/Readers/LaTeX.hs+29−29 src/Text/Pandoc/Readers/Markdown.hs+49−49 src/Text/Pandoc/Readers/MediaWiki.hs+29−27 src/Text/Pandoc/Readers/Native.hs+2−2 src/Text/Pandoc/Readers/OPML.hs+7−8 src/Text/Pandoc/Readers/Org.hs+9−9 src/Text/Pandoc/Readers/Org/BlockStarts.hs+1−1 src/Text/Pandoc/Readers/Org/Blocks.hs+25−25 src/Text/Pandoc/Readers/Org/ExportSettings.hs+5−5 src/Text/Pandoc/Readers/Org/Inlines.hs+24−24 src/Text/Pandoc/Readers/Org/Meta.hs+15−15 src/Text/Pandoc/Readers/Org/ParserState.hs+22−26 src/Text/Pandoc/Readers/Org/Parsing.hs+5−5 src/Text/Pandoc/Readers/Org/Shared.hs+4−4 src/Text/Pandoc/Readers/RST.hs+26−26 src/Text/Pandoc/Readers/TWiki.hs+15−12 src/Text/Pandoc/Readers/Textile.hs+16−16 src/Text/Pandoc/Readers/Txt2Tags.hs+16−16 src/Text/Pandoc/SelfContained.hs+16−16 src/Text/Pandoc/Slides.hs+2−2 src/Text/Pandoc/Templates.hs+9−8 src/Text/Pandoc/UTF8.hs+9−9 src/Text/Pandoc/UUID.hs+3−3 src/Text/Pandoc/Writers/AsciiDoc.hs+23−23 src/Text/Pandoc/Writers/CommonMark.hs+8−8 src/Text/Pandoc/Writers/ConTeXt.hs+27−27 src/Text/Pandoc/Writers/Custom.hs+25−22 src/Text/Pandoc/Writers/Docbook.hs+24−23 src/Text/Pandoc/Writers/Docx.hs+74−71 src/Text/Pandoc/Writers/DokuWiki.hs+27−30 src/Text/Pandoc/Writers/EPUB.hs+95−93 src/Text/Pandoc/Writers/FB2.hs+43−43 src/Text/Pandoc/Writers/HTML.hs+53−50 src/Text/Pandoc/Writers/Haddock.hs+14−12 src/Text/Pandoc/Writers/ICML.hs+25−23 src/Text/Pandoc/Writers/LaTeX.hs+62−62 src/Text/Pandoc/Writers/Man.hs+16−16 src/Text/Pandoc/Writers/Markdown.hs+60−57 src/Text/Pandoc/Writers/Math.hs+1−1 src/Text/Pandoc/Writers/MediaWiki.hs+26−26 src/Text/Pandoc/Writers/Native.hs+3−3 src/Text/Pandoc/Writers/ODT.hs+20−20 src/Text/Pandoc/Writers/OPML.hs+10−10 src/Text/Pandoc/Writers/OpenDocument.hs+24−22 src/Text/Pandoc/Writers/Org.hs+17−17 src/Text/Pandoc/Writers/RST.hs+29−29 src/Text/Pandoc/Writers/RTF.hs+18−18 src/Text/Pandoc/Writers/Shared.hs+14−13 src/Text/Pandoc/Writers/TEI.hs+12−11 src/Text/Pandoc/Writers/Texinfo.hs+15−15 src/Text/Pandoc/Writers/Textile.hs+18−18 src/Text/Pandoc/Writers/ZimWiki.hs+22−22 src/Text/Pandoc/XML.hs+9−9 test/Tests/Command.hs+15−16 test/Tests/Helpers.hs+13−12 test/Tests/Old.hs+14−14 test/Tests/Readers/Docx.hs+7−7 test/Tests/Readers/EPUB.hs+5−5 test/Tests/Readers/HTML.hs+2−3 test/Tests/Readers/LaTeX.hs+2−3 test/Tests/Readers/Markdown.hs+2−3 test/Tests/Readers/Odt.hs+4−4 test/Tests/Readers/Org.hs+3−4 test/Tests/Readers/RST.hs+4−4 test/Tests/Readers/Txt2Tags.hs+3−5 test/Tests/Shared.hs+4−4 test/Tests/Writers/AsciiDoc.hs+3−3 test/Tests/Writers/ConTeXt.hs+3−3 test/Tests/Writers/Docbook.hs+3−3 test/Tests/Writers/Docx.hs+6−6 test/Tests/Writers/HTML.hs+3−3 test/Tests/Writers/Markdown.hs+3−3 test/Tests/Writers/Native.hs+2−3 test/Tests/Writers/Org.hs+3−3 test/Tests/Writers/Plain.hs+3−3 test/Tests/Writers/RST.hs+3−3 test/Tests/Writers/TEI.hs+3−3 test/test-pandoc.hs+13−13
pandoc.hs+5−2
@@ -1,4 +1,7 @@
1−{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables, PatternGuards #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE PatternGuards #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
4+{-# LANGUAGE TupleSections #-}
25{-
36Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu>
47
@@ -30,7 +33,7 @@ Parses command-line options and calls the appropriate readers and
3033writers.
3134-}
3235module Main where
33−import Text.Pandoc.App (defaultOpts, convertWithOpts, parseOptions, options)
36+import Text.Pandoc.App (convertWithOpts, defaultOpts, options, parseOptions)
3437
3538main :: IO ()
3639main = parseOptions options defaultOpts >>= convertWithOpts
src/Text/Pandoc.hs+45−43
@@ -1,4 +1,6 @@
1−{-# LANGUAGE ScopedTypeVariables, FlexibleInstances, GADTs #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE GADTs #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
24{-
35Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu>
46
@@ -143,65 +145,65 @@ module Text.Pandoc
143145 , pandocVersion
144146 ) where
145147
148+import Control.Monad.Except (throwError)
149+import Data.Aeson
150+import qualified Data.ByteString.Lazy as BL
151+import Data.List (intercalate)
152+import Text.Pandoc.Class
146153import Text.Pandoc.Definition
154+import Text.Pandoc.Error
147155import Text.Pandoc.Generic
148−import Text.Pandoc.Readers.Markdown
156+import Text.Pandoc.Logging
157+import Text.Pandoc.Options
149158import Text.Pandoc.Readers.CommonMark
150−import Text.Pandoc.Readers.MediaWiki
151−import Text.Pandoc.Readers.RST
152−import Text.Pandoc.Readers.Org
153159import Text.Pandoc.Readers.DocBook
154−import Text.Pandoc.Readers.OPML
155−import Text.Pandoc.Readers.LaTeX
160+import Text.Pandoc.Readers.Docx
161+import Text.Pandoc.Readers.EPUB
162+import Text.Pandoc.Readers.Haddock
156163import Text.Pandoc.Readers.HTML
157−import Text.Pandoc.Readers.Textile
164+import Text.Pandoc.Readers.LaTeX
165+import Text.Pandoc.Readers.Markdown
166+import Text.Pandoc.Readers.MediaWiki
158167import Text.Pandoc.Readers.Native
159−import Text.Pandoc.Readers.Haddock
160−import Text.Pandoc.Readers.TWiki
161−import Text.Pandoc.Readers.Docx
162168import Text.Pandoc.Readers.Odt
169+import Text.Pandoc.Readers.OPML
170+import Text.Pandoc.Readers.Org
171+import Text.Pandoc.Readers.RST
172+import Text.Pandoc.Readers.Textile
173+import Text.Pandoc.Readers.TWiki
163174import Text.Pandoc.Readers.Txt2Tags
164−import Text.Pandoc.Readers.EPUB
165−import Text.Pandoc.Writers.Native
166−import Text.Pandoc.Writers.Markdown
167−import Text.Pandoc.Writers.RST
168−import Text.Pandoc.Writers.LaTeX
175+import Text.Pandoc.Shared (mapLeft, pandocVersion, safeRead)
176+import Text.Pandoc.Templates
177+import qualified Text.Pandoc.UTF8 as UTF8
178+import Text.Pandoc.Writers.AsciiDoc
179+import Text.Pandoc.Writers.CommonMark
169180import Text.Pandoc.Writers.ConTeXt
170−import Text.Pandoc.Writers.Texinfo
171−import Text.Pandoc.Writers.HTML
172−import Text.Pandoc.Writers.ODT
181+import Text.Pandoc.Writers.Custom
182+import Text.Pandoc.Writers.Docbook
173183import Text.Pandoc.Writers.Docx
184+import Text.Pandoc.Writers.DokuWiki
174185import Text.Pandoc.Writers.EPUB
175186import Text.Pandoc.Writers.FB2
187+import Text.Pandoc.Writers.Haddock
188+import Text.Pandoc.Writers.HTML
176189import Text.Pandoc.Writers.ICML
177−import Text.Pandoc.Writers.Docbook
178−import Text.Pandoc.Writers.OPML
179−import Text.Pandoc.Writers.OpenDocument
190+import Text.Pandoc.Writers.LaTeX
180191import Text.Pandoc.Writers.Man
181−import Text.Pandoc.Writers.RTF
192+import Text.Pandoc.Writers.Markdown
182193import Text.Pandoc.Writers.MediaWiki
183−import Text.Pandoc.Writers.DokuWiki
184−import Text.Pandoc.Writers.ZimWiki
185−import Text.Pandoc.Writers.Textile
194+import Text.Pandoc.Writers.Native
195+import Text.Pandoc.Writers.ODT
196+import Text.Pandoc.Writers.OpenDocument
197+import Text.Pandoc.Writers.OPML
186198import Text.Pandoc.Writers.Org
187−import Text.Pandoc.Writers.AsciiDoc
188−import Text.Pandoc.Writers.Haddock
189−import Text.Pandoc.Writers.CommonMark
190−import Text.Pandoc.Writers.Custom
199+import Text.Pandoc.Writers.RST
200+import Text.Pandoc.Writers.RTF
191201import Text.Pandoc.Writers.TEI
192−import Text.Pandoc.Templates
193−import Text.Pandoc.Options
194−import Text.Pandoc.Logging
195−import Text.Pandoc.Shared (safeRead, mapLeft, pandocVersion)
196−import Text.Pandoc.Error
197−import Text.Pandoc.Class
198−import Data.Aeson
199−import qualified Data.ByteString.Lazy as BL
200−import Data.List (intercalate)
202+import Text.Pandoc.Writers.Texinfo
203+import Text.Pandoc.Writers.Textile
204+import Text.Pandoc.Writers.ZimWiki
201205import Text.Parsec
202206import Text.Parsec.Error
203−import qualified Text.Pandoc.UTF8 as UTF8
204−import Control.Monad.Except (throwError)
205207
206208parseFormatSpec :: String
207209 -> Either ParseError (String, Extensions -> Extensions)
@@ -220,8 +222,8 @@ parseFormatSpec = parse formatSpec ""
220222 | name == "lhs" -> return Ext_literate_haskell
221223 | otherwise -> fail $ "Unknown extension: " ++ name
222224 return $ case polarity of
223− '-' -> disableExtension ext
224− _ -> enableExtension ext
225+ '-' -> disableExtension ext
226+ _ -> enableExtension ext
225227
226228data Reader m = StringReader (ReaderOptions -> String -> m Pandoc)
227229 | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc)
src/Text/Pandoc/App.hs+110−109
@@ -1,4 +1,6 @@
1−{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE TupleSections #-}
24{-
35Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu>
46
@@ -35,51 +37,50 @@ module Text.Pandoc.App (
3537 , parseOptions
3638 , options
3739 ) where
38−import Text.Pandoc
39−import Text.Pandoc.Builder (setMeta)
40−import Text.Pandoc.PDF (makePDF)
41−import Text.Pandoc.Walk (walk)
42−import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8,
43− headerShift, err, openURL, safeRead,
44− readDataFile )
45−import Text.Pandoc.MediaBag ( mediaDirectory, extractMediaBag, MediaBag )
46−import Text.Pandoc.XML ( toEntities )
47−import Text.Pandoc.Highlighting (highlightingStyles)
48−import Text.Pandoc.SelfContained ( makeSelfContained )
49−import Text.Pandoc.Process (pipeProcess)
50−import Skylighting ( Style, defaultSyntaxMap, Syntax(..) )
51−import Text.Printf
52−import System.Environment ( getEnvironment, getProgName, getArgs )
5340import Control.Applicative ((<|>))
54−import System.Exit ( ExitCode (..), exitSuccess )
55−import System.FilePath
56−import Data.Char ( toLower, toUpper )
57−import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
58−import System.Directory ( getAppUserDataDirectory, findExecutable,
59− doesFileExist, Permissions(..), getPermissions )
60−import System.IO ( stdout, stderr )
61−import System.IO.Error ( isDoesNotExistError )
6241import qualified Control.Exception as E
63−import Control.Exception.Extensible ( throwIO )
64−import qualified Text.Pandoc.UTF8 as UTF8
42+import Control.Exception.Extensible (throwIO)
6543import Control.Monad
6644import Control.Monad.Trans
67−import Data.Maybe (fromMaybe, isNothing, isJust)
68−import Data.Foldable (foldrM)
69−import Network.URI (parseURI, isURI, URI(..))
70−import qualified Data.ByteString.Lazy as B
45+import Data.Aeson (eitherDecode', encode)
7146import qualified Data.ByteString as BS
47+import qualified Data.ByteString.Lazy as B
48+import Data.Char (toLower, toUpper)
49+import Data.Foldable (foldrM)
50+import Data.List (intercalate, isPrefixOf, isSuffixOf, sort)
7251import qualified Data.Map as M
73−import Data.Aeson (eitherDecode', encode)
52+import Data.Maybe (fromMaybe, isJust, isNothing)
53+import qualified Data.Text as T
7454import Data.Yaml (decode)
7555import qualified Data.Yaml as Yaml
76−import qualified Data.Text as T
77−import System.Console.GetOpt
78−import Text.Pandoc.Class (withMediaBag, PandocIO, getLog)
56+import Network.URI (URI (..), isURI, parseURI)
7957import Paths_pandoc (getDataDir)
58+import Skylighting (Style, Syntax (..), defaultSyntaxMap)
59+import System.Console.GetOpt
60+import System.Directory (Permissions (..), doesFileExist, findExecutable,
61+ getAppUserDataDirectory, getPermissions)
62+import System.Environment (getArgs, getEnvironment, getProgName)
63+import System.Exit (ExitCode (..), exitSuccess)
64+import System.FilePath
65+import System.IO (stderr, stdout)
66+import System.IO.Error (isDoesNotExistError)
67+import Text.Pandoc
68+import Text.Pandoc.Builder (setMeta)
69+import Text.Pandoc.Class (PandocIO, getLog, withMediaBag)
70+import Text.Pandoc.Highlighting (highlightingStyles)
71+import Text.Pandoc.MediaBag (MediaBag, extractMediaBag, mediaDirectory)
72+import Text.Pandoc.PDF (makePDF)
73+import Text.Pandoc.Process (pipeProcess)
74+import Text.Pandoc.SelfContained (makeSelfContained)
75+import Text.Pandoc.Shared (err, headerShift, openURL, readDataFile,
76+ readDataFileUTF8, safeRead, tabFilter)
77+import qualified Text.Pandoc.UTF8 as UTF8
78+import Text.Pandoc.Walk (walk)
79+import Text.Pandoc.XML (toEntities)
80+import Text.Printf
8081#ifndef _WINDOWS
81−import System.Posix.Terminal (queryTerminal)
8282import System.Posix.IO (stdOutput)
83+import System.Posix.Terminal (queryTerminal)
8384#endif
8485
8586parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
@@ -119,7 +120,7 @@ convertWithOpts opts = do
119120 let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css"
120121 let mathMethod =
121122 case (optKaTeXJS opts, optKaTeXStylesheet opts) of
122− (Nothing, _) -> optHTMLMathMethod opts
123+ (Nothing, _) -> optHTMLMathMethod opts
123124 (Just js, ss) -> KaTeX js (fromMaybe csscdn ss)
124125
125126
@@ -151,8 +152,8 @@ convertWithOpts opts = do
151152 Just x -> map toLower x
152153
153154 let writerName = case optWriter opts of
154− Nothing -> defaultWriterName outputFile
155− Just x -> map toLower x
155+ Nothing -> defaultWriterName outputFile
156+ Just x -> map toLower x
156157 let format = takeWhile (`notElem` ['+','-'])
157158 $ takeFileName writerName -- in case path to lua script
158159
@@ -196,13 +197,13 @@ convertWithOpts opts = do
196197 Nothing -> do
197198 deftemp <- getDefaultTemplate datadir format
198199 case deftemp of
199− Left e -> throwIO e
200− Right t -> return (Just t)
200+ Left e -> throwIO e
201+ Right t -> return (Just t)
201202 Just tp -> do
202203 -- strip off extensions
203204 let tp' = case takeExtension tp of
204− "" -> tp <.> format
205− _ -> tp
205+ "" -> tp <.> format
206+ _ -> tp
206207 Just <$> E.catch (UTF8.readFile tp')
207208 (\e -> if isDoesNotExistError e
208209 then E.catch
@@ -221,7 +222,7 @@ convertWithOpts opts = do
221222 -- note: this reverses the list constructed in option parsing,
222223 -- which in turn was reversed from the command-line order,
223224 -- so we end up with the correct order in the variable list:
224− let withList _ [] vars = return vars
225+ let withList _ [] vars = return vars
225226 withList f (x:xs) vars = f x vars >>= withList f xs
226227
227228 variables <-
@@ -352,7 +353,7 @@ convertWithOpts opts = do
352353 rs <- getLog
353354 return (x, rs)
354355 case optLogFile opts of
355− Nothing -> return ()
356+ Nothing -> return ()
356357 Just logfile -> B.writeFile logfile (encodeLogMessages reports)
357358 let isWarning msg = messageVerbosity msg == WARNING
358359 when (optFailIfWarnings opts && any isWarning reports) $
@@ -394,7 +395,7 @@ convertWithOpts opts = do
394395 let pdfprog = case () of
395396 _ | conTeXtOutput -> "context"
396397 _ | html5Output -> "wkhtmltopdf"
397− _ -> optLaTeXEngine opts
398+ _ -> optLaTeXEngine opts
398399 -- check for pdf creating program
399400 mbPdfProg <- liftIO $ findExecutable pdfprog
400401 when (isNothing mbPdfProg) $
@@ -437,7 +438,7 @@ externalFilter f args' d = liftIO $ do
437438 else return True
438439 let (f', args'') = if exists
439440 then case map toLower (takeExtension f) of
440− _ | isExecutable -> ("." </> f, args')
441+ _ | isExecutable -> ("." </> f, args')
441442 ".py" -> ("python", f:args')
442443 ".hs" -> ("runhaskell", f:args')
443444 ".pl" -> ("perl", f:args')
@@ -465,66 +466,66 @@ externalFilter f args' d = liftIO $ do
465466
466467-- | Data structure for command line options.
467468data Opt = Opt
468− { optTabStop :: Int -- ^ Number of spaces per tab
469− , optPreserveTabs :: Bool -- ^ Preserve tabs instead of converting to spaces
470− , optStandalone :: Bool -- ^ Include header, footer
471− , optReader :: Maybe String -- ^ Reader format
472− , optWriter :: Maybe String -- ^ Writer format
473− , optTableOfContents :: Bool -- ^ Include table of contents
474− , optBaseHeaderLevel :: Int -- ^ Base header level
475− , optTemplate :: Maybe FilePath -- ^ Custom template
476− , optVariables :: [(String,String)] -- ^ Template variables to set
477− , optMetadata :: [(String, String)] -- ^ Metadata fields to set
478− , optOutputFile :: FilePath -- ^ Name of output file
479− , optInputFiles :: [FilePath] -- ^ Names of input files
480− , optNumberSections :: Bool -- ^ Number sections in LaTeX
481− , optNumberOffset :: [Int] -- ^ Starting number for sections
482− , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
483− , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
484− , optSelfContained :: Bool -- ^ Make HTML accessible offline
485− , optHtmlQTags :: Bool -- ^ Use <q> tags in HTML
486− , optHighlightStyle :: Maybe String -- ^ Style to use for highlighted code
487− , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
488− , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
489− , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
490− , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata
491− , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed
492− , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters
493− , optEpubCoverImage :: Maybe FilePath -- ^ Cover image for epub
494− , optTOCDepth :: Int -- ^ Number of levels to include in TOC
495− , optDumpArgs :: Bool -- ^ Output command-line arguments
496− , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
497− , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output
498− , optLogFile :: Maybe FilePath -- ^ File to write JSON log output
499− , optFailIfWarnings :: Bool -- ^ Fail on warnings
500− , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
501− , optReferenceLocation :: ReferenceLocation -- ^ location for footnotes and link references in markdown output
502− , optDpi :: Int -- ^ Dpi
503− , optWrapText :: WrapOption -- ^ Options for wrapping text
504− , optColumns :: Int -- ^ Line length in characters
505− , optFilters :: [FilePath] -- ^ Filters to apply
506− , optEmailObfuscation :: ObfuscationMethod
507− , optIdentifierPrefix :: String
508− , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
509− , optDataDir :: Maybe FilePath
510− , optCiteMethod :: CiteMethod -- ^ Method to output cites
511− , optListings :: Bool -- ^ Use listings package for code blocks
512− , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
513− , optLaTeXEngineArgs :: [String] -- ^ Flags to pass to the latex-engine
514− , optSlideLevel :: Maybe Int -- ^ Header level that creates slides
515− , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2
516− , optAscii :: Bool -- ^ Use ascii characters only in html
469+ { optTabStop :: Int -- ^ Number of spaces per tab
470+ , optPreserveTabs :: Bool -- ^ Preserve tabs instead of converting to spaces
471+ , optStandalone :: Bool -- ^ Include header, footer
472+ , optReader :: Maybe String -- ^ Reader format
473+ , optWriter :: Maybe String -- ^ Writer format
474+ , optTableOfContents :: Bool -- ^ Include table of contents
475+ , optBaseHeaderLevel :: Int -- ^ Base header level
476+ , optTemplate :: Maybe FilePath -- ^ Custom template
477+ , optVariables :: [(String,String)] -- ^ Template variables to set
478+ , optMetadata :: [(String, String)] -- ^ Metadata fields to set
479+ , optOutputFile :: FilePath -- ^ Name of output file
480+ , optInputFiles :: [FilePath] -- ^ Names of input files
481+ , optNumberSections :: Bool -- ^ Number sections in LaTeX
482+ , optNumberOffset :: [Int] -- ^ Starting number for sections
483+ , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
484+ , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
485+ , optSelfContained :: Bool -- ^ Make HTML accessible offline
486+ , optHtmlQTags :: Bool -- ^ Use <q> tags in HTML
487+ , optHighlightStyle :: Maybe String -- ^ Style to use for highlighted code
488+ , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
489+ , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
490+ , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
491+ , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata
492+ , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed
493+ , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters
494+ , optEpubCoverImage :: Maybe FilePath -- ^ Cover image for epub
495+ , optTOCDepth :: Int -- ^ Number of levels to include in TOC
496+ , optDumpArgs :: Bool -- ^ Output command-line arguments
497+ , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
498+ , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output
499+ , optLogFile :: Maybe FilePath -- ^ File to write JSON log output
500+ , optFailIfWarnings :: Bool -- ^ Fail on warnings
501+ , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
502+ , optReferenceLocation :: ReferenceLocation -- ^ location for footnotes and link references in markdown output
503+ , optDpi :: Int -- ^ Dpi
504+ , optWrapText :: WrapOption -- ^ Options for wrapping text
505+ , optColumns :: Int -- ^ Line length in characters
506+ , optFilters :: [FilePath] -- ^ Filters to apply
507+ , optEmailObfuscation :: ObfuscationMethod
508+ , optIdentifierPrefix :: String
509+ , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
510+ , optDataDir :: Maybe FilePath
511+ , optCiteMethod :: CiteMethod -- ^ Method to output cites
512+ , optListings :: Bool -- ^ Use listings package for code blocks
513+ , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
514+ , optLaTeXEngineArgs :: [String] -- ^ Flags to pass to the latex-engine
515+ , optSlideLevel :: Maybe Int -- ^ Header level that creates slides
516+ , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2
517+ , optAscii :: Bool -- ^ Use ascii characters only in html
517518 , optDefaultImageExtension :: String -- ^ Default image extension
518− , optExtractMedia :: Maybe FilePath -- ^ Path to extract embedded media
519− , optTrackChanges :: TrackChanges -- ^ Accept or reject MS Word track-changes.
520− , optFileScope :: Bool -- ^ Parse input files before combining
521− , optKaTeXStylesheet :: Maybe String -- ^ Path to stylesheet for KaTeX
522− , optKaTeXJS :: Maybe String -- ^ Path to js file for KaTeX
523− , optTitlePrefix :: Maybe String -- ^ Prefix for title
524− , optCss :: [FilePath] -- ^ CSS files to link to
525− , optIncludeBeforeBody :: [FilePath] -- ^ Files to include before
526− , optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
527− , optIncludeInHeader :: [FilePath] -- ^ Files to include in header
519+ , optExtractMedia :: Maybe FilePath -- ^ Path to extract embedded media
520+ , optTrackChanges :: TrackChanges -- ^ Accept or reject MS Word track-changes.
521+ , optFileScope :: Bool -- ^ Parse input files before combining
522+ , optKaTeXStylesheet :: Maybe String -- ^ Path to stylesheet for KaTeX
523+ , optKaTeXJS :: Maybe String -- ^ Path to js file for KaTeX
524+ , optTitlePrefix :: Maybe String -- ^ Prefix for title
525+ , optCss :: [FilePath] -- ^ CSS files to link to
526+ , optIncludeBeforeBody :: [FilePath] -- ^ Files to include before
527+ , optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
528+ , optIncludeInHeader :: [FilePath] -- ^ Files to include in header
528529 }
529530
530531-- | Defaults for command-line options.
@@ -675,7 +676,7 @@ defaultWriterName x =
675676 ".icml" -> "icml"
676677 ".tei.xml" -> "tei"
677678 ".tei" -> "tei"
678− ['.',y] | y `elem` ['1'..'9'] -> "man"
679+ ['.',y] | y `elem` ['1'..'9'] -> "man"
679680 _ -> "html"
680681
681682-- Transformations of a Pandoc document post-parsing:
@@ -1210,8 +1211,8 @@ options =
12101211 (OptArg
12111212 (\arg opt -> do
12121213 let url' = case arg of
1213− Just u -> u ++ "?"
1214− Nothing -> "/cgi-bin/mimetex.cgi?"
1214+ Just u -> u ++ "?"
1215+ Nothing -> "/cgi-bin/mimetex.cgi?"
12151216 return opt { optHTMLMathMethod = WebTeX url' })
12161217 "URL")
12171218 "" -- "Use mimetex for HTML math"
@@ -1423,7 +1424,7 @@ handleUnrecognizedOption x =
14231424
14241425uppercaseFirstLetter :: String -> String
14251426uppercaseFirstLetter (c:cs) = toUpper c : cs
1426−uppercaseFirstLetter [] = []
1427+uppercaseFirstLetter [] = []
14271428
14281429readers'names :: [String]
14291430readers'names = sort (map fst (readers :: [(String, Reader PandocIO)]))
src/Text/Pandoc/Asciify.hs+1−1
@@ -30,8 +30,8 @@ ascii equivalents (used in constructing HTML identifiers).
3030-}
3131module Text.Pandoc.Asciify (toAsciiChar)
3232where
33−import qualified Data.Map as M
3433import Data.Char (isAscii)
34+import qualified Data.Map as M
3535
3636toAsciiChar :: Char -> Maybe Char
3737toAsciiChar c | isAscii c = Just c
src/Text/Pandoc/CSS.hs+2−2
@@ -25,14 +25,14 @@ foldOrElse v xs = foldr (orElse v) v xs
2525
2626eitherToMaybe :: Either a b -> Maybe b
2727eitherToMaybe (Right x) = Just x
28−eitherToMaybe _ = Nothing
28+eitherToMaybe _ = Nothing
2929
3030-- | takes a list of keys/properties and a CSS string and
3131-- returns the corresponding key-value-pairs.
3232pickStylesToKVs :: [String] -> String -> [(String, String)]
3333pickStylesToKVs props styleAttr =
3434 case parse styleAttrParser "" styleAttr of
35− Left _ -> []
35+ Left _ -> []
3636 Right styles -> filter (\s -> fst s `elem` props) styles
3737
3838-- | takes a list of key/property synonyms and a CSS string and maybe
src/Text/Pandoc/Error.hs+5−4
@@ -1,4 +1,5 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
23{-
34Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu>
45
@@ -33,12 +34,12 @@ module Text.Pandoc.Error (
3334 PandocError(..),
3435 handleError) where
3536
36−import Text.Parsec.Error
37−import Text.Parsec.Pos hiding (Line)
37+import Control.Exception (Exception)
3838import Data.Generics (Typeable)
3939import GHC.Generics (Generic)
40−import Control.Exception (Exception)
4140import Text.Pandoc.Shared (err)
41+import Text.Parsec.Error
42+import Text.Parsec.Pos hiding (Line)
4243
4344type Input = String
4445
src/Text/Pandoc/Extensions.hs+3−2
@@ -1,4 +1,5 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
23{-
34Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
45
@@ -42,7 +43,7 @@ module Text.Pandoc.Extensions ( Extension(..)
4243 , githubMarkdownExtensions
4344 , multimarkdownExtensions )
4445where
45−import Data.Bits (testBit, setBit, clearBit)
46+import Data.Bits (clearBit, setBit, testBit)
4647import Data.Data (Data)
4748import Data.Typeable (Typeable)
4849import GHC.Generics (Generic)
src/Text/Pandoc/Highlighting.hs+5−5
@@ -49,14 +49,14 @@ module Text.Pandoc.Highlighting ( highlightingStyles
4949 , fromListingsLanguage
5050 , toListingsLanguage
5151 ) where
52−import Text.Pandoc.Definition
53−import Text.Pandoc.Shared (safeRead)
54−import Skylighting
55−import Data.Maybe (fromMaybe)
52+import Control.Monad
5653import Data.Char (toLower)
5754import qualified Data.Map as M
58−import Control.Monad
55+import Data.Maybe (fromMaybe)
5956import qualified Data.Text as T
57+import Skylighting
58+import Text.Pandoc.Definition
59+import Text.Pandoc.Shared (safeRead)
6060
6161highlightingStyles :: [(String, Style)]
6262highlightingStyles =
src/Text/Pandoc/Logging.hs+28−26
@@ -1,4 +1,6 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, OverloadedStrings #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
3+{-# LANGUAGE OverloadedStrings #-}
24{-
35Copyright (C) 2016-17 John MacFarlane <jgm@berkeley.edu>
46
@@ -37,16 +39,16 @@ module Text.Pandoc.Logging (
3739 , messageVerbosity
3840 ) where
3941
40−import Text.Parsec.Pos
42+import Data.Aeson
43+import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
44+ keyOrder)
45+import qualified Data.ByteString.Lazy as BL
4146import Data.Data (Data)
4247import Data.Generics (Typeable)
43−import GHC.Generics (Generic)
4448import qualified Data.Text as Text
45−import Data.Aeson
49+import GHC.Generics (Generic)
4650import Text.Pandoc.Definition
47−import Data.Aeson.Encode.Pretty (encodePretty', keyOrder,
48− defConfig, Config(..))
49−import qualified Data.ByteString.Lazy as BL
51+import Text.Parsec.Pos
5052
5153-- | Verbosity level.
5254data Verbosity = ERROR | WARNING | INFO | DEBUG
@@ -240,23 +242,23 @@ showLogMessage msg =
240242messageVerbosity:: LogMessage -> Verbosity
241243messageVerbosity msg =
242244 case msg of
243− SkippedContent{} -> INFO
244− CouldNotParseYamlMetadata{} -> WARNING
245− DuplicateLinkReference{} -> WARNING
246− DuplicateNoteReference{} -> WARNING
247− ReferenceNotFound{} -> WARNING
248− CircularReference{} -> WARNING
249− CouldNotLoadIncludeFile{} -> WARNING
250− ParsingUnescaped{} -> INFO
251− ParsingTrace{} -> DEBUG
252− InlineNotRendered{} -> INFO
253− BlockNotRendered{} -> INFO
254− DocxParserWarning{} -> WARNING
255− CouldNotFetchResource{} -> WARNING
245+ SkippedContent{} -> INFO
246+ CouldNotParseYamlMetadata{} -> WARNING
247+ DuplicateLinkReference{} -> WARNING
248+ DuplicateNoteReference{} -> WARNING
249+ ReferenceNotFound{} -> WARNING
250+ CircularReference{} -> WARNING
251+ CouldNotLoadIncludeFile{} -> WARNING
252+ ParsingUnescaped{} -> INFO
253+ ParsingTrace{} -> DEBUG
254+ InlineNotRendered{} -> INFO
255+ BlockNotRendered{} -> INFO
256+ DocxParserWarning{} -> WARNING
257+ CouldNotFetchResource{} -> WARNING
256258 CouldNotDetermineImageSize{} -> WARNING
257− CouldNotConvertImage{} -> WARNING
258− CouldNotDetermineMimeType{} -> WARNING
259− CouldNotConvertTeXMath{} -> WARNING
260− CouldNotParseCSS{} -> WARNING
261− Fetching{} -> INFO
262− NoTitleElement{} -> WARNING
259+ CouldNotConvertImage{} -> WARNING
260+ CouldNotDetermineMimeType{} -> WARNING
261+ CouldNotConvertTeXMath{} -> WARNING
262+ CouldNotParseCSS{} -> WARNING
263+ Fetching{} -> INFO
264+ NoTitleElement{} -> WARNING
src/Text/Pandoc/MIME.hs+3−3
@@ -29,11 +29,11 @@ Mime type lookup for ODT writer.
2929-}
3030module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef,
3131 extensionFromMimeType )where
32−import System.FilePath
33−import Data.Char ( toLower )
32+import Data.Char (toLower)
3433import Data.List (isPrefixOf, isSuffixOf)
35−import Data.Maybe (fromMaybe)
3634import qualified Data.Map as M
35+import Data.Maybe (fromMaybe)
36+import System.FilePath
3737
3838type MimeType = String
3939
src/Text/Pandoc/MediaBag.hs+13−12
@@ -1,4 +1,5 @@
1−{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23{-
34Copyright (C) 2014 John MacFarlane <jgm@berkeley.edu>
45
@@ -36,19 +37,19 @@ module Text.Pandoc.MediaBag (
3637 mediaDirectory,
3738 extractMediaBag
3839 ) where
40+import Control.Monad (when)
41+import Control.Monad.Trans (MonadIO (..))
42+import qualified Data.ByteString.Lazy as BL
43+import Data.Data (Data)
44+import qualified Data.Map as M
45+import Data.Maybe (fromMaybe)
46+import Data.Typeable (Typeable)
47+import System.Directory (createDirectoryIfMissing)
3948import System.FilePath
4049import qualified System.FilePath.Posix as Posix
41−import System.Directory (createDirectoryIfMissing)
42−import qualified Data.Map as M
43−import qualified Data.ByteString.Lazy as BL
44−import Control.Monad (when)
45−import Control.Monad.Trans (MonadIO(..))
50+import System.IO (stderr)
4651import Text.Pandoc.MIME (MimeType, getMimeTypeDef)
4752import qualified Text.Pandoc.UTF8 as UTF8
48−import Data.Maybe (fromMaybe)
49−import System.IO (stderr)
50−import Data.Data (Data)
51−import Data.Typeable (Typeable)
5253
5354-- | A container for a collection of binary resources, with names and
5455-- mime types. Note that a 'MediaBag' is a Monoid, so 'mempty'
@@ -71,8 +72,8 @@ insertMedia fp mbMime contents (MediaBag mediamap) =
7172 MediaBag (M.insert (splitDirectories fp) (mime, contents) mediamap)
7273 where mime = fromMaybe fallback mbMime
7374 fallback = case takeExtension fp of
74− ".gz" -> getMimeTypeDef $ dropExtension fp
75− _ -> getMimeTypeDef fp
75+ ".gz" -> getMimeTypeDef $ dropExtension fp
76+ _ -> getMimeTypeDef fp
7677
7778-- | Lookup a media item in a 'MediaBag', returning mime type and contents.
7879lookupMedia :: FilePath
src/Text/Pandoc/Options.hs+43−42
@@ -1,4 +1,5 @@
1−{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
23{-
34Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
45
@@ -44,23 +45,23 @@ module Text.Pandoc.Options ( module Text.Pandoc.Extensions
4445 , def
4546 , isEnabled
4647 ) where
47−import Text.Pandoc.Extensions
48−import Data.Default
49−import Text.Pandoc.Highlighting (Style, pygments)
5048import Data.Data (Data)
49+import Data.Default
5150import Data.Typeable (Typeable)
5251import GHC.Generics (Generic)
52+import Text.Pandoc.Extensions
53+import Text.Pandoc.Highlighting (Style, pygments)
5354
5455data ReaderOptions = ReaderOptions{
55− readerExtensions :: Extensions -- ^ Syntax extensions
56− , readerStandalone :: Bool -- ^ Standalone document with header
57− , readerColumns :: Int -- ^ Number of columns in terminal
58− , readerTabStop :: Int -- ^ Tab stop
59− , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
60− , readerIndentedCodeClasses :: [String] -- ^ Default classes for
56+ readerExtensions :: Extensions -- ^ Syntax extensions
57+ , readerStandalone :: Bool -- ^ Standalone document with header
58+ , readerColumns :: Int -- ^ Number of columns in terminal
59+ , readerTabStop :: Int -- ^ Tab stop
60+ , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
61+ , readerIndentedCodeClasses :: [String] -- ^ Default classes for
6162 -- indented code blocks
6263 , readerDefaultImageExtension :: String -- ^ Default extension for images
63− , readerTrackChanges :: TrackChanges
64+ , readerTrackChanges :: TrackChanges
6465} deriving (Show, Read, Data, Typeable, Generic)
6566
6667instance Default ReaderOptions
@@ -139,39 +140,39 @@ data ReferenceLocation = EndOfBlock -- ^ End of block
139140
140141-- | Options for writers
141142data WriterOptions = WriterOptions
142− { writerTemplate :: Maybe String -- ^ Template to use
143− , writerVariables :: [(String, String)] -- ^ Variables to set in template
144− , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
145− , writerTableOfContents :: Bool -- ^ Include table of contents
146− , writerIncremental :: Bool -- ^ True if lists should be incremental
147− , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
148− , writerNumberSections :: Bool -- ^ Number sections in LaTeX
149− , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
150− , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
151− , writerExtensions :: Extensions -- ^ Markdown extensions that can be used
152− , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
153− , writerDpi :: Int -- ^ Dpi for pixel to/from inch/cm conversions
154− , writerWrapText :: WrapOption -- ^ Option for wrapping text
155− , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
156− , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
157− , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
143+ { writerTemplate :: Maybe String -- ^ Template to use
144+ , writerVariables :: [(String, String)] -- ^ Variables to set in template
145+ , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
146+ , writerTableOfContents :: Bool -- ^ Include table of contents
147+ , writerIncremental :: Bool -- ^ True if lists should be incremental
148+ , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
149+ , writerNumberSections :: Bool -- ^ Number sections in LaTeX
150+ , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
151+ , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
152+ , writerExtensions :: Extensions -- ^ Markdown extensions that can be used
153+ , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
154+ , writerDpi :: Int -- ^ Dpi for pixel to/from inch/cm conversions
155+ , writerWrapText :: WrapOption -- ^ Option for wrapping text
156+ , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
157+ , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
158+ , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
158159 -- and for footnote marks in markdown
159− , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
160− , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
161− , writerCiteMethod :: CiteMethod -- ^ How to print cites
162− , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
163− , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
164− , writerTopLevelDivision :: TopLevelDivision -- ^ Type of top-level divisions
165− , writerListings :: Bool -- ^ Use listings package for code
166− , writerHighlightStyle :: Maybe Style -- ^ Style to use for highlighting
160+ , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
161+ , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
162+ , writerCiteMethod :: CiteMethod -- ^ How to print cites
163+ , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
164+ , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
165+ , writerTopLevelDivision :: TopLevelDivision -- ^ Type of top-level divisions
166+ , writerListings :: Bool -- ^ Use listings package for code
167+ , writerHighlightStyle :: Maybe Style -- ^ Style to use for highlighting
167168 -- (Nothing = no highlighting)
168− , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown
169− , writerEpubMetadata :: Maybe String -- ^ Metadata to include in EPUB
170− , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed
171− , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)
172− , writerTOCDepth :: Int -- ^ Number of levels to include in TOC
173− , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified
174− , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine
169+ , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown
170+ , writerEpubMetadata :: Maybe String -- ^ Metadata to include in EPUB
171+ , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed
172+ , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)
173+ , writerTOCDepth :: Int -- ^ Number of levels to include in TOC
174+ , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified
175+ , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine
175176 , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown
176177 } deriving (Show, Data, Typeable, Generic)
177178
src/Text/Pandoc/PDF.hs+22−20
@@ -1,4 +1,6 @@
1−{-# LANGUAGE OverloadedStrings, CPP, ScopedTypeVariables #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
24{-
35Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
46
@@ -30,39 +32,39 @@ Conversion of LaTeX documents to PDF.
3032-}
3133module Text.Pandoc.PDF ( makePDF ) where
3234
35+import qualified Codec.Picture as JP
36+import qualified Control.Exception as E
37+import Control.Monad (unless, when, (<=<))
38+import Control.Monad.Trans (MonadIO (..))
39+import qualified Data.ByteString as BS
3340import Data.ByteString.Lazy (ByteString)
3441import qualified Data.ByteString.Lazy as B
42+import qualified Data.ByteString.Lazy as BL
3543import qualified Data.ByteString.Lazy.Char8 as BC
36−import qualified Data.ByteString as BS
44+import Data.Digest.Pure.SHA (sha1, showDigest)
45+import Data.List (isInfixOf)
46+import Data.Maybe (fromMaybe)
3747import Data.Monoid ((<>))
48+import System.Directory
49+import System.Environment
3850import System.Exit (ExitCode (..))
3951import System.FilePath
4052import System.IO (stdout)
41−import System.IO.Temp (withTempFile, withTempDirectory)
42−import System.Directory
43−import Data.Digest.Pure.SHA (showDigest, sha1)
44−import System.Environment
45−import Control.Monad (unless, when, (<=<))
46−import qualified Control.Exception as E
47−import Data.List (isInfixOf)
48−import Data.Maybe (fromMaybe)
49−import qualified Text.Pandoc.UTF8 as UTF8
53+import System.IO.Temp (withTempDirectory, withTempFile)
5054import Text.Pandoc.Definition
5155import Text.Pandoc.MediaBag
52−import Text.Pandoc.Walk (walkM)
53−import Text.Pandoc.Shared (withTempDir, inDirectory, stringify)
54−import Text.Pandoc.Writers.Shared (getField, metaToJSON)
55−import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..))
5656import Text.Pandoc.MIME (extensionFromMimeType, getMimeType)
57+import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..))
5758import Text.Pandoc.Process (pipeProcess)
58−import Control.Monad.Trans (MonadIO(..))
59−import qualified Data.ByteString.Lazy as BL
60−import qualified Codec.Picture as JP
59+import Text.Pandoc.Shared (inDirectory, stringify, withTempDir)
60+import qualified Text.Pandoc.UTF8 as UTF8
61+import Text.Pandoc.Walk (walkM)
62+import Text.Pandoc.Writers.Shared (getField, metaToJSON)
6163#ifdef _WINDOWS
6264import Data.List (intercalate)
6365#endif
64−import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem, report,
65− setVerbosity, setMediaBag, runIO)
66+import Text.Pandoc.Class (PandocIO, fetchItem, report, runIO, runIOorExplode,
67+ setMediaBag, setVerbosity)
6668import Text.Pandoc.Logging
6769
6870#ifdef _WINDOWS
src/Text/Pandoc/Pretty.hs+34−32
@@ -1,4 +1,5 @@
1−{-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23{-
34Copyright (C) 2010-2016 John MacFarlane <jgm@berkeley.edu>
45
@@ -76,22 +77,23 @@ module Text.Pandoc.Pretty (
7677 )
7778
7879where
79−import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..))
80−import qualified Data.Sequence as Seq
81−import Data.Foldable (toList)
82−import Data.List (intersperse)
83−import Data.String
8480import Control.Monad.State
8581import Data.Char (isSpace)
82+import Data.Foldable (toList)
83+import Data.List (intersperse)
8684import Data.Monoid ((<>))
85+import Data.Sequence (Seq, ViewL (..), fromList, mapWithIndex, singleton, viewl,
86+ (<|))
87+import qualified Data.Sequence as Seq
88+import Data.String
8789
8890data RenderState a = RenderState{
89− output :: [a] -- ^ In reverse order
90− , prefix :: String
91− , usePrefix :: Bool
92− , lineLength :: Maybe Int -- ^ 'Nothing' means no wrapping
93− , column :: Int
94− , newlines :: Int -- ^ Number of preceding newlines
91+ output :: [a] -- ^ In reverse order
92+ , prefix :: String
93+ , usePrefix :: Bool
94+ , lineLength :: Maybe Int -- ^ 'Nothing' means no wrapping
95+ , column :: Int
96+ , newlines :: Int -- ^ Number of preceding newlines
9597 }
9698
9799type DocState a = State (RenderState a) ()
@@ -184,21 +186,21 @@ nestle :: Doc -> Doc
184186nestle (Doc d) = Doc $ go d
185187 where go x = case viewl x of
186188 (BlankLines _ :< rest) -> go rest
187− (NewLine :< rest) -> go rest
188− _ -> x
189+ (NewLine :< rest) -> go rest
190+ _ -> x
189191
190192-- | Chomps trailing blank space off of a 'Doc'.
191193chomp :: Doc -> Doc
192194chomp d = Doc (fromList dl')
193195 where dl = toList (unDoc d)
194196 dl' = reverse $ go $ reverse dl
195− go [] = []
196− go (BreakingSpace : xs) = go xs
197+ go [] = []
198+ go (BreakingSpace : xs) = go xs
197199 go (CarriageReturn : xs) = go xs
198− go (NewLine : xs) = go xs
199− go (BlankLines _ : xs) = go xs
200− go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
201− go xs = xs
200+ go (NewLine : xs) = go xs
201+ go (BlankLines _ : xs) = go xs
202+ go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
203+ go xs = xs
202204
203205outp :: (IsString a) => Int -> String -> DocState a
204206outp off s | off < 0 = do -- offset < 0 means newline characters
@@ -306,10 +308,10 @@ renderList (BreakingSpace : NewLine : xs) = renderList (NewLine:xs)
306308renderList (BreakingSpace : BlankLines n : xs) = renderList (BlankLines n:xs)
307309renderList (BreakingSpace : BreakingSpace : xs) = renderList (BreakingSpace:xs)
308310renderList (BreakingSpace : xs) = do
309− let isText (Text _ _) = True
310− isText (Block _ _) = True
311− isText (AfterBreak _) = True
312− isText _ = False
311+ let isText (Text _ _) = True
312+ isText (Block _ _) = True
313+ isText (AfterBreak _) = True
314+ isText _ = False
313315 let isBreakingSpace BreakingSpace = True
314316 isBreakingSpace _ = False
315317 let xs' = dropWhile isBreakingSpace xs
@@ -342,7 +344,7 @@ renderList (Block _width lns : xs) = do
342344 let oldPref = prefix st
343345 case column st - realLength oldPref of
344346 n | n > 0 -> modify $ \s -> s{ prefix = oldPref ++ replicate n ' ' }
345− _ -> return ()
347+ _ -> return ()
346348 renderList $ intersperse CarriageReturn (map (Text 0) lns)
347349 modify $ \s -> s{ prefix = oldPref }
348350 renderList xs
@@ -362,10 +364,10 @@ mergeBlocks addSpace (IsBlock w1 lns1) (IsBlock w2 lns2) =
362364 sp xs = if addSpace then (' ' : xs) else xs
363365
364366offsetOf :: D -> Int
365−offsetOf (Text o _) = o
366−offsetOf (Block w _) = w
367−offsetOf BreakingSpace = 1
368−offsetOf _ = 0
367+offsetOf (Text o _) = o
368+offsetOf (Block w _) = w
369+offsetOf BreakingSpace = 1
370+offsetOf _ = 0
369371
370372-- | A literal string.
371373text :: String -> Doc
@@ -430,7 +432,7 @@ beforeNonBlank d = Doc $ singleton (BeforeNonBlank d)
430432nowrap :: Doc -> Doc
431433nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc
432434 where replaceSpace _ BreakingSpace = Text 1 " "
433− replaceSpace _ x = x
435+ replaceSpace _ x = x
434436
435437-- | Content to print only if it comes at the beginning of a line,
436438-- to be used e.g. for escaping line-initial `.` in groff man.
@@ -440,8 +442,8 @@ afterBreak s = Doc $ singleton (AfterBreak s)
440442-- | Returns the width of a 'Doc'.
441443offset :: Doc -> Int
442444offset d = case map realLength . lines . render Nothing $ d of
443− [] -> 0
444− os -> maximum os
445+ [] -> 0
446+ os -> maximum os
445447
446448-- | Returns the minimal width of a 'Doc' when reflowed at breakable spaces.
447449minOffset :: Doc -> Int
src/Text/Pandoc/Process.hs+4−4
@@ -29,13 +29,13 @@ ByteString variant of 'readProcessWithExitCode'.
2929-}
3030module Text.Pandoc.Process (pipeProcess)
3131where
32−import System.Process
33−import System.Exit (ExitCode (..))
32+import Control.Concurrent (forkIO, newEmptyMVar, putMVar, takeMVar)
3433import Control.Exception
35−import System.IO (hClose, hFlush)
36−import Control.Concurrent (putMVar, takeMVar, newEmptyMVar, forkIO)
3734import Control.Monad (unless)
3835import qualified Data.ByteString.Lazy as BL
36+import System.Exit (ExitCode (..))
37+import System.IO (hClose, hFlush)
38+import System.Process
3939
4040{- |
4141Version of 'System.Process.readProcessWithExitCode' that uses lazy bytestrings
src/Text/Pandoc/Readers/CommonMark.hs+6−6
@@ -33,11 +33,11 @@ module Text.Pandoc.Readers.CommonMark (readCommonMark)
3333where
3434
3535import CMark
36−import Data.Text (unpack, pack)
3736import Data.List (groupBy)
37+import Data.Text (pack, unpack)
38+import Text.Pandoc.Class (PandocMonad)
3839import Text.Pandoc.Definition
3940import Text.Pandoc.Options
40−import Text.Pandoc.Class (PandocMonad)
4141
4242-- | Parse a CommonMark formatted string into a 'Pandoc' structure.
4343readCommonMark :: PandocMonad m => ReaderOptions -> String -> m Pandoc
@@ -86,8 +86,8 @@ addBlock (Node _ (LIST listAttrs) nodes) =
8686 paraToPlain (Para xs) = Plain (xs)
8787 paraToPlain x = x
8888 delim = case listDelim listAttrs of
89− PERIOD_DELIM -> Period
90− PAREN_DELIM -> OneParen
89+ PERIOD_DELIM -> Period
90+ PAREN_DELIM -> OneParen
9191addBlock (Node _ ITEM _) = id -- handled in LIST
9292addBlock _ = id
9393
@@ -105,8 +105,8 @@ addInline (Node _ (TEXT t) _) = (map toinl clumps ++)
105105 samekind ' ' _ = False
106106 samekind _ ' ' = False
107107 samekind _ _ = True
108− toinl (' ':_) = Space
109− toinl xs = Str xs
108+ toinl (' ':_) = Space
109+ toinl xs = Str xs
110110addInline (Node _ LINEBREAK _) = (LineBreak :)
111111addInline (Node _ SOFTBREAK _) = (SoftBreak :)
112112addInline (Node _ (HTML_INLINE t) _) =
src/Text/Pandoc/Readers/Docx.hs+43−41
@@ -1,4 +1,6 @@
1−{-# LANGUAGE PatternGuards, OverloadedStrings, CPP #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE PatternGuards #-}
24
35{-
46Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.edu>
@@ -74,32 +76,32 @@ module Text.Pandoc.Readers.Docx
7476 ) where
7577
7678import Codec.Archive.Zip
77−import Text.Pandoc.Definition
78−import Text.Pandoc.Options
79+import Control.Monad.Reader
80+import Control.Monad.State
81+import qualified Data.ByteString.Lazy as B
82+import Data.Default (Default)
83+import Data.List (delete, intersect)
84+import qualified Data.Map as M
85+import Data.Sequence (ViewL (..), viewl)
86+import qualified Data.Sequence as Seq (null)
87+import qualified Data.Set as Set
7988import Text.Pandoc.Builder
80−import Text.Pandoc.Walk
81−import Text.Pandoc.Readers.Docx.Parse
82−import Text.Pandoc.Readers.Docx.Lists
89+-- import Text.Pandoc.Definition
90+import Text.Pandoc.MediaBag (MediaBag)
91+import Text.Pandoc.Options
8392import Text.Pandoc.Readers.Docx.Combine
93+import Text.Pandoc.Readers.Docx.Lists
94+import Text.Pandoc.Readers.Docx.Parse
8495import Text.Pandoc.Shared
85−import Text.Pandoc.MediaBag (MediaBag)
86−import Data.List (delete, intersect)
96+import Text.Pandoc.Walk
8797import Text.TeXMath (writeTeX)
88−import Data.Default (Default)
89−import qualified Data.ByteString.Lazy as B
90−import qualified Data.Map as M
91−import qualified Data.Set as Set
92−import Control.Monad.Reader
93−import Control.Monad.State
94−import Data.Sequence (ViewL(..), viewl)
95−import qualified Data.Sequence as Seq (null)
9698#if !(MIN_VERSION_base(4,8,0))
9799import Data.Traversable (traverse)
98100#endif
99−import Text.Pandoc.Error
100101import Control.Monad.Except (throwError)
101102import Text.Pandoc.Class (PandocMonad)
102103import qualified Text.Pandoc.Class as P
104+import Text.Pandoc.Error
103105import Text.Pandoc.Logging
104106
105107readDocx :: PandocMonad m
@@ -123,9 +125,9 @@ readDocxWithWarnings :: PandocMonad m
123125readDocxWithWarnings = readDocx
124126
125127data DState = DState { docxAnchorMap :: M.Map String String
126− , docxMediaBag :: MediaBag
127− , docxDropCap :: Inlines
128− , docxWarnings :: [String]
128+ , docxMediaBag :: MediaBag
129+ , docxDropCap :: Inlines
130+ , docxWarnings :: [String]
129131 }
130132
131133instance Default DState where
@@ -135,7 +137,7 @@ instance Default DState where
135137 , docxWarnings = []
136138 }
137139
138−data DEnv = DEnv { docxOptions :: ReaderOptions
140+data DEnv = DEnv { docxOptions :: ReaderOptions
139141 , docxInHeaderBlock :: Bool }
140142
141143instance Default DEnv where
@@ -173,7 +175,7 @@ isEmptyPar (Paragraph _ parParts) =
173175 all isEmptyParPart parParts
174176 where
175177 isEmptyParPart (PlainRun (Run _ runElems)) = all isEmptyElem runElems
176− isEmptyParPart _ = False
178+ isEmptyParPart _ = False
177179 isEmptyElem (TextRun s) = trim s == ""
178180 isEmptyElem _ = True
179181isEmptyPar _ = False
@@ -207,7 +209,7 @@ fixAuthors :: MetaValue -> MetaValue
207209fixAuthors (MetaBlocks blks) =
208210 MetaList $ map g $ filter f blks
209211 where f (Para _) = True
210− f _ = False
212+ f _ = False
211213 g (Para ils) = MetaInlines ils
212214 g _ = MetaInlines []
213215fixAuthors mv = mv
@@ -219,28 +221,28 @@ codeDivs :: [String]
219221codeDivs = ["SourceCode"]
220222
221223runElemToInlines :: RunElem -> Inlines
222−runElemToInlines (TextRun s) = text s
223−runElemToInlines (LnBrk) = linebreak
224−runElemToInlines (Tab) = space
225−runElemToInlines (SoftHyphen) = text "\xad"
224+runElemToInlines (TextRun s) = text s
225+runElemToInlines (LnBrk) = linebreak
226+runElemToInlines (Tab) = space
227+runElemToInlines (SoftHyphen) = text "\xad"
226228runElemToInlines (NoBreakHyphen) = text "\x2011"
227229
228230runElemToString :: RunElem -> String
229−runElemToString (TextRun s) = s
230−runElemToString (LnBrk) = ['\n']
231−runElemToString (Tab) = ['\t']
232−runElemToString (SoftHyphen) = ['\xad']
231+runElemToString (TextRun s) = s
232+runElemToString (LnBrk) = ['\n']
233+runElemToString (Tab) = ['\t']
234+runElemToString (SoftHyphen) = ['\xad']
233235runElemToString (NoBreakHyphen) = ['\x2011']
234236
235237runToString :: Run -> String
236238runToString (Run _ runElems) = concatMap runElemToString runElems
237−runToString _ = ""
239+runToString _ = ""
238240
239241parPartToString :: ParPart -> String
240−parPartToString (PlainRun run) = runToString run
242+parPartToString (PlainRun run) = runToString run
241243parPartToString (InternalHyperLink _ runs) = concatMap runToString runs
242244parPartToString (ExternalHyperLink _ runs) = concatMap runToString runs
243−parPartToString _ = ""
245+parPartToString _ = ""
244246
245247blacklistedCharStyles :: [String]
246248blacklistedCharStyles = ["Hyperlink"]
@@ -332,9 +334,9 @@ blocksToInlinesWarn :: PandocMonad m => String -> Blocks -> DocxContext m Inline
332334blocksToInlinesWarn cmtId blks = do
333335 let blkList = toList blks
334336 notParaOrPlain :: Block -> Bool
335− notParaOrPlain (Para _) = False
337+ notParaOrPlain (Para _) = False
336338 notParaOrPlain (Plain _) = False
337− notParaOrPlain _ = True
339+ notParaOrPlain _ = True
338340 when (not $ null $ filter notParaOrPlain blkList) $
339341 lift $ P.report $ DocxParserWarning $
340342 "Docx comment " ++ cmtId ++ " will not retain formatting"
@@ -508,14 +510,14 @@ parStyleToTransform pPr
508510 let pPr' = pPr { indentation = Nothing }
509511 in
510512 case (left - hang) > 0 of
511− True -> blockQuote . (parStyleToTransform pPr')
513+ True -> blockQuote . (parStyleToTransform pPr')
512514 False -> parStyleToTransform pPr'
513515 | null (pStyle pPr),
514516 Just left <- indentation pPr >>= leftParIndent =
515517 let pPr' = pPr { indentation = Nothing }
516518 in
517519 case left > 0 of
518− True -> blockQuote . (parStyleToTransform pPr')
520+ True -> blockQuote . (parStyleToTransform pPr')
519521 False -> parStyleToTransform pPr'
520522parStyleToTransform _ = id
521523
@@ -542,7 +544,7 @@ bodyPartToBlocks (Paragraph pPr parparts)
542544 else do modify $ \s -> s { docxDropCap = mempty }
543545 return $ case isNull ils' of
544546 True -> mempty
545− _ -> parStyleToTransform pPr $ para ils'
547+ _ -> parStyleToTransform pPr $ para ils'
546548bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do
547549 let
548550 kvs = case levelInfo of
@@ -573,12 +575,12 @@ bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
573575 | otherwise -> (Just r, rs)
574576 False -> (Nothing, r:rs)
575577
576− cells <- mapM rowToBlocksList rows
578+ cells <- mapM rowToBlocksList rows
577579
578580 let width = case cells of
579581 r':_ -> length r'
580582 -- shouldn't happen
581− [] -> 0
583+ [] -> 0
582584
583585 hdrCells <- case hdr of
584586 Just r' -> rowToBlocksList r'
src/Text/Pandoc/Readers/Docx/Combine.hs+16−15
@@ -1,15 +1,16 @@
1−{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
2− PatternGuards #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE PatternGuards #-}
3+{-# LANGUAGE TypeSynonymInstances #-}
34
45module Text.Pandoc.Readers.Docx.Combine ( smushInlines
56 , smushBlocks
67 )
78 where
89
9−import Text.Pandoc.Builder
1010import Data.List
11−import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr, (><), (|>))
11+import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr, (><), (|>))
1212import qualified Data.Sequence as Seq (null)
13+import Text.Pandoc.Builder
1314
1415data Modifier a = Modifier (a -> a)
1516 | AttrModifier (Attr -> a -> a) Attr
@@ -56,15 +57,15 @@ unstackInlines ms = case ilModifier ms of
5657ilModifier :: Inlines -> Modifier Inlines
5758ilModifier ils = case viewl (unMany ils) of
5859 (x :< xs) | Seq.null xs -> case x of
59− (Emph _) -> Modifier emph
60− (Strong _) -> Modifier strong
61− (SmallCaps _) -> Modifier smallcaps
62− (Strikeout _) -> Modifier strikeout
63− (Superscript _) -> Modifier superscript
64− (Subscript _) -> Modifier subscript
60+ (Emph _) -> Modifier emph
61+ (Strong _) -> Modifier strong
62+ (SmallCaps _) -> Modifier smallcaps
63+ (Strikeout _) -> Modifier strikeout
64+ (Superscript _) -> Modifier superscript
65+ (Subscript _) -> Modifier subscript
6566 (Link attr _ tgt) -> Modifier $ linkWith attr (fst tgt) (snd tgt)
66− (Span attr _) -> AttrModifier spanWith attr
67− _ -> NullModifier
67+ (Span attr _) -> AttrModifier spanWith attr
68+ _ -> NullModifier
6869 _ -> NullModifier
6970
7071ilInnards :: Inlines -> Inlines
@@ -78,18 +79,18 @@ ilInnards ils = case viewl (unMany ils) of
7879 (Subscript lst) -> fromList lst
7980 (Link _ lst _) -> fromList lst
8081 (Span _ lst) -> fromList lst
81− _ -> ils
82+ _ -> ils
8283 _ -> ils
8384
8485inlinesL :: Inlines -> (Inlines, Inlines)
8586inlinesL ils = case viewl $ unMany ils of
8687 (s :< sq) -> (singleton s, Many sq)
87− _ -> (mempty, ils)
88+ _ -> (mempty, ils)
8889
8990inlinesR :: Inlines -> (Inlines, Inlines)
9091inlinesR ils = case viewr $ unMany ils of
9192 (sq :> s) -> (Many sq, singleton s)
92− _ -> (ils, mempty)
93+ _ -> (ils, mempty)
9394
9495combineInlines :: Inlines -> Inlines -> Inlines
9596combineInlines x y =
src/Text/Pandoc/Readers/Docx/Lists.hs+15−15
@@ -33,38 +33,38 @@ module Text.Pandoc.Readers.Docx.Lists ( blocksToBullets
3333 , listParagraphDivs
3434 ) where
3535
36−import Text.Pandoc.JSON
37−import Text.Pandoc.Generic (bottomUp)
38−import Text.Pandoc.Shared (trim)
3936import Control.Monad
4037import Data.List
4138import Data.Maybe
39+import Text.Pandoc.Generic (bottomUp)
40+import Text.Pandoc.JSON
41+import Text.Pandoc.Shared (trim)
4242
4343isListItem :: Block -> Bool
4444isListItem (Div (_, classes, _) _) | "list-item" `elem` classes = True
45−isListItem _ = False
45+isListItem _ = False
4646
4747getLevel :: Block -> Maybe Integer
4848getLevel (Div (_, _, kvs) _) = liftM read $ lookup "level" kvs
49−getLevel _ = Nothing
49+getLevel _ = Nothing
5050
5151getLevelN :: Block -> Integer
5252getLevelN b = case getLevel b of
53− Just n -> n
53+ Just n -> n
5454 Nothing -> -1
5555
5656getNumId :: Block -> Maybe Integer
5757getNumId (Div (_, _, kvs) _) = liftM read $ lookup "num-id" kvs
58−getNumId _ = Nothing
58+getNumId _ = Nothing
5959
6060getNumIdN :: Block -> Integer
6161getNumIdN b = case getNumId b of
62− Just n -> n
62+ Just n -> n
6363 Nothing -> -1
6464
6565getText :: Block -> Maybe String
6666getText (Div (_, _, kvs) _) = lookup "text" kvs
67−getText _ = Nothing
67+getText _ = Nothing
6868
6969data ListType = Itemized | Enumerated ListAttributes
7070
@@ -162,7 +162,7 @@ flatToBullets elems = flatToBullets' (-1) elems
162162
163163singleItemHeaderToHeader :: Block -> Block
164164singleItemHeaderToHeader (OrderedList _ [[h@(Header _ _ _)]]) = h
165−singleItemHeaderToHeader blk = blk
165+singleItemHeaderToHeader blk = blk
166166
167167
168168blocksToBullets :: [Block] -> [Block]
@@ -173,8 +173,8 @@ blocksToBullets blks =
173173
174174plainParaInlines :: Block -> [Inline]
175175plainParaInlines (Plain ils) = ils
176−plainParaInlines (Para ils) = ils
177−plainParaInlines _ = []
176+plainParaInlines (Para ils) = ils
177+plainParaInlines _ = []
178178
179179blocksToDefinitions' :: [([Inline], [[Block]])] -> [Block] -> [Block] -> [Block]
180180blocksToDefinitions' [] acc [] = reverse acc
@@ -194,7 +194,7 @@ blocksToDefinitions' defAcc acc
194194 | (not . null) defAcc && "Definition" `elem` classes2 =
195195 let remainingAttr2 = (ident2, delete "Definition" classes2, kvs2)
196196 defItems2 = case remainingAttr2 == ("", [], []) of
197− True -> blks2
197+ True -> blks2
198198 False -> [Div remainingAttr2 blks2]
199199 ((defTerm, defItems):defs) = defAcc
200200 defAcc' = case null defItems of
@@ -211,12 +211,12 @@ removeListDivs' :: Block -> [Block]
211211removeListDivs' (Div (ident, classes, kvs) blks)
212212 | "list-item" `elem` classes =
213213 case delete "list-item" classes of
214− [] -> blks
214+ [] -> blks
215215 classes' -> [Div (ident, classes', kvs) $ blks]
216216removeListDivs' (Div (ident, classes, kvs) blks)
217217 | not $ null $ listParagraphDivs `intersect` classes =
218218 case classes \\ listParagraphDivs of
219− [] -> blks
219+ [] -> blks
220220 classes' -> [Div (ident, classes', kvs) blks]
221221removeListDivs' blk = [blk]
222222
src/Text/Pandoc/Readers/Docx/Parse.hs+42−40
@@ -1,4 +1,6 @@
1−{-# LANGUAGE PatternGuards, ViewPatterns, FlexibleInstances #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE PatternGuards #-}
3+{-# LANGUAGE ViewPatterns #-}
24
35{-
46Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.edu>
@@ -53,24 +55,24 @@ module Text.Pandoc.Readers.Docx.Parse ( Docx(..)
5355 , archiveToDocxWithWarnings
5456 ) where
5557import Codec.Archive.Zip
56−import Text.XML.Light
57−import Data.Maybe
58−import Data.List
59−import System.FilePath
60−import Data.Bits ((.|.))
61−import qualified Data.ByteString.Lazy as B
62−import qualified Text.Pandoc.UTF8 as UTF8
58+import Control.Applicative ((<|>))
59+import Control.Monad.Except
6360import Control.Monad.Reader
6461import Control.Monad.State
65−import Control.Applicative ((<|>))
62+import Data.Bits ((.|.))
63+import qualified Data.ByteString.Lazy as B
64+import Data.Char (chr, isDigit, ord, readLitChar)
65+import Data.List
6666import qualified Data.Map as M
67−import Control.Monad.Except
68−import Text.Pandoc.Shared (safeRead, filteredFilesFromArchive)
69−import Text.TeXMath.Readers.OMML (readOMML)
70−import Text.TeXMath.Unicode.Fonts (getUnicode, stringToFont, Font(..))
71−import Text.TeXMath (Exp)
67+import Data.Maybe
68+import System.FilePath
7269import Text.Pandoc.Readers.Docx.Util
73−import Data.Char (readLitChar, ord, chr, isDigit)
70+import Text.Pandoc.Shared (filteredFilesFromArchive, safeRead)
71+import qualified Text.Pandoc.UTF8 as UTF8
72+import Text.TeXMath (Exp)
73+import Text.TeXMath.Readers.OMML (readOMML)
74+import Text.TeXMath.Unicode.Fonts (Font (..), getUnicode, stringToFont)
75+import Text.XML.Light
7476
7577data ReaderEnv = ReaderEnv { envNotes :: Notes
7678 , envComments :: Comments
@@ -97,7 +99,7 @@ runD dx re rs = runState (runReaderT (runExceptT dx) re) rs
9799
98100maybeToD :: Maybe a -> D a
99101maybeToD (Just a) = return a
100−maybeToD Nothing = throwError DocxError
102+maybeToD Nothing = throwError DocxError
101103
102104eitherToD :: Either a b -> D b
103105eitherToD (Right b) = return b
@@ -160,12 +162,12 @@ data Notes = Notes NameSpaces
160162data Comments = Comments NameSpaces (M.Map String Element)
161163 deriving Show
162164
163−data ParIndentation = ParIndentation { leftParIndent :: Maybe Integer
164− , rightParIndent :: Maybe Integer
165+data ParIndentation = ParIndentation { leftParIndent :: Maybe Integer
166+ , rightParIndent :: Maybe Integer
165167 , hangingParIndent :: Maybe Integer}
166168 deriving Show
167169
168−data ParagraphStyle = ParagraphStyle { pStyle :: [String]
170+data ParagraphStyle = ParagraphStyle { pStyle :: [String]
169171 , indentation :: Maybe ParIndentation
170172 , dropCap :: Bool
171173 , pHeading :: Maybe (String, Int)
@@ -234,19 +236,19 @@ data RunElem = TextRun String | LnBrk | Tab | SoftHyphen | NoBreakHyphen
234236data VertAlign = BaseLn | SupScrpt | SubScrpt
235237 deriving Show
236238
237−data RunStyle = RunStyle { isBold :: Maybe Bool
238− , isItalic :: Maybe Bool
239+data RunStyle = RunStyle { isBold :: Maybe Bool
240+ , isItalic :: Maybe Bool
239241 , isSmallCaps :: Maybe Bool
240− , isStrike :: Maybe Bool
241− , rVertAlign :: Maybe VertAlign
242− , rUnderline :: Maybe String
243− , rStyle :: Maybe CharStyle}
242+ , isStrike :: Maybe Bool
243+ , rVertAlign :: Maybe VertAlign
244+ , rUnderline :: Maybe String
245+ , rStyle :: Maybe CharStyle}
244246 deriving Show
245247
246−data ParStyleData = ParStyleData { headingLev :: Maybe (String, Int)
248+data ParStyleData = ParStyleData { headingLev :: Maybe (String, Int)
247249 , isBlockQuote :: Maybe Bool
248− , numInfo :: Maybe (String, String)
249− , psStyle :: Maybe ParStyle}
250+ , numInfo :: Maybe (String, String)
251+ , psStyle :: Maybe ParStyle}
250252 deriving Show
251253
252254defaultRunStyle :: RunStyle
@@ -381,10 +383,10 @@ archiveToNotes zf =
381383 enElem = findEntryByPath "word/endnotes.xml" zf
382384 >>= (parseXMLDoc . UTF8.toStringLazy . fromEntry)
383385 fn_namespaces = case fnElem of
384− Just e -> elemToNameSpaces e
386+ Just e -> elemToNameSpaces e
385387 Nothing -> []
386388 en_namespaces = case enElem of
387− Just e -> elemToNameSpaces e
389+ Just e -> elemToNameSpaces e
388390 Nothing -> []
389391 ns = unionBy (\x y -> fst x == fst y) fn_namespaces en_namespaces
390392 fn = fnElem >>= (elemToNotes ns "footnote")
@@ -397,19 +399,19 @@ archiveToComments zf =
397399 let cmtsElem = findEntryByPath "word/comments.xml" zf
398400 >>= (parseXMLDoc . UTF8.toStringLazy . fromEntry)
399401 cmts_namespaces = case cmtsElem of
400− Just e -> elemToNameSpaces e
402+ Just e -> elemToNameSpaces e
401403 Nothing -> []
402404 cmts = (elemToComments cmts_namespaces) <$> cmtsElem
403405 in
404406 case cmts of
405− Just c -> Comments cmts_namespaces c
407+ Just c -> Comments cmts_namespaces c
406408 Nothing -> Comments cmts_namespaces M.empty
407409
408410filePathToRelType :: FilePath -> Maybe DocumentLocation
409−filePathToRelType "word/_rels/document.xml.rels" = Just InDocument
411+filePathToRelType "word/_rels/document.xml.rels" = Just InDocument
410412filePathToRelType "word/_rels/footnotes.xml.rels" = Just InFootnote
411−filePathToRelType "word/_rels/endnotes.xml.rels" = Just InEndnote
412−filePathToRelType _ = Nothing
413+filePathToRelType "word/_rels/endnotes.xml.rels" = Just InEndnote
414+filePathToRelType _ = Nothing
413415
414416relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship
415417relElemToRelationship relType element | qName (elName element) == "Relationship" =
@@ -616,12 +618,12 @@ elemToBodyPart ns element
616618 >>= findAttrByName ns "w" "val"
617619 caption = (fromMaybe "" caption')
618620 grid' = case findChildByName ns "w" "tblGrid" element of
619− Just g -> elemToTblGrid ns g
621+ Just g -> elemToTblGrid ns g
620622 Nothing -> return []
621623 tblLook' = case findChildByName ns "w" "tblPr" element >>=
622624 findChildByName ns "w" "tblLook"
623625 of
624− Just l -> elemToTblLook ns l
626+ Just l -> elemToTblLook ns l
625627 Nothing -> return defaultTblLook
626628
627629 grid <- grid'
@@ -741,7 +743,7 @@ elemToParPart ns element
741743 (Comments _ commentMap) <- asks envComments
742744 case M.lookup cmtId commentMap of
743745 Just cmtElem -> elemToCommentStart ns cmtElem
744− Nothing -> throwError WrongElem
746+ Nothing -> throwError WrongElem
745747elemToParPart ns element
746748 | isElem ns "w" "commentRangeEnd" element
747749 , Just cmtId <- findAttrByName ns "w" "id" element =
@@ -771,7 +773,7 @@ elemToExtent :: Element -> Extent
771773elemToExtent drawingElem =
772774 case (getDim "cx", getDim "cy") of
773775 (Just w, Just h) -> Just (w, h)
774− _ -> Nothing
776+ _ -> Nothing
775777 where
776778 wp_ns = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
777779 getDim at = findElement (QName "extent" (Just wp_ns) (Just "wp")) drawingElem
@@ -1023,7 +1025,7 @@ getSymChar ns element
10231025 getCodepoint = findAttrByName ns "w" "char" element
10241026 getFont = stringToFont =<< findAttrByName ns "w" "font" element
10251027 lowerFromPrivate ('F':xs) = '0':xs
1026− lowerFromPrivate xs = xs
1028+ lowerFromPrivate xs = xs
10271029getSymChar _ _ = TextRun ""
10281030
10291031elemToRunElems :: NameSpaces -> Element -> D [RunElem]
src/Text/Pandoc/Readers/Docx/StyleMap.hs+6−6
@@ -7,11 +7,11 @@ module Text.Pandoc.Readers.Docx.StyleMap ( StyleMaps(..)
77 , hasStyleName
88 ) where
99
10−import Text.XML.Light
11−import Text.Pandoc.Readers.Docx.Util
12−import Control.Monad.State
13−import Data.Char (toLower)
14−import qualified Data.Map as M
10+import Control.Monad.State
11+import Data.Char (toLower)
12+import qualified Data.Map as M
13+import Text.Pandoc.Readers.Docx.Util
14+import Text.XML.Light
1515
1616newtype ParaStyleMap = ParaStyleMap ( M.Map String String )
1717newtype CharStyleMap = CharStyleMap ( M.Map String String )
@@ -30,7 +30,7 @@ instance StyleMap CharStyleMap where
3030
3131insert :: (StyleMap a) => Maybe String -> Maybe String -> a -> a
3232insert (Just k) (Just v) m = alterMap (M.insert k v) m
33−insert _ _ m = m
33+insert _ _ m = m
3434
3535getStyleId :: (StyleMap a) => String -> a -> String
3636getStyleId s = M.findWithDefault (filter (/=' ') s) (map toLower s) . getMap
src/Text/Pandoc/Readers/Docx/Util.hs+2−2
@@ -8,8 +8,8 @@ module Text.Pandoc.Readers.Docx.Util (
88 , findAttrByName
99 ) where
1010
11−import Text.XML.Light
1211import Data.Maybe (mapMaybe)
12+import Text.XML.Light
1313
1414type NameSpaces = [(String, String)]
1515
@@ -18,7 +18,7 @@ elemToNameSpaces = mapMaybe attrToNSPair . elAttribs
1818
1919attrToNSPair :: Attr -> Maybe (String, String)
2020attrToNSPair (Attr (QName s _ (Just "xmlns")) val) = Just (s, val)
21−attrToNSPair _ = Nothing
21+attrToNSPair _ = Nothing
2222
2323elemName :: NameSpaces -> String -> String -> QName
2424elemName ns prefix name =
src/Text/Pandoc/Readers/EPUB.hs+29−31
@@ -1,39 +1,37 @@
1−{-# LANGUAGE
2− ViewPatterns
3− , StandaloneDeriving
4− , TupleSections
5− , FlexibleContexts #-}
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE StandaloneDeriving #-}
3+{-# LANGUAGE TupleSections #-}
4+{-# LANGUAGE ViewPatterns #-}
65
76module Text.Pandoc.Readers.EPUB
87 (readEPUB)
98 where
109
11−import Text.XML.Light
12−import Text.Pandoc.Definition hiding (Attr)
13−import Text.Pandoc.Readers.HTML (readHtml)
14−import Text.Pandoc.Walk (walk, query)
15−import Text.Pandoc.Options ( ReaderOptions(..))
16−import Text.Pandoc.Extensions (enableExtension, Extension(Ext_raw_html))
17−import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField)
18−import Network.URI (unEscapeString)
10+import Codec.Archive.Zip (Archive (..), Entry, findEntryByPath, fromEntry,
11+ toArchiveOrFail)
12+import Control.DeepSeq (NFData, deepseq)
13+import Control.Monad (guard, liftM)
1914import Control.Monad.Except (throwError)
20−import Text.Pandoc.MIME (MimeType)
21−import qualified Text.Pandoc.Builder as B
22−import Codec.Archive.Zip ( Archive (..), toArchiveOrFail, fromEntry
23− , findEntryByPath, Entry)
2415import qualified Data.ByteString.Lazy as BL (ByteString)
25−import System.FilePath ( takeFileName, (</>), dropFileName, normalise
26− , dropFileName
27− , splitFileName )
28−import qualified Text.Pandoc.UTF8 as UTF8 (toStringLazy)
29−import Control.Monad (guard, liftM)
30−import Data.List (isPrefixOf, isInfixOf)
31−import Data.Maybe (mapMaybe, fromMaybe)
32−import qualified Data.Map as M (Map, lookup, fromList, elems)
16+import Data.List (isInfixOf, isPrefixOf)
17+import qualified Data.Map as M (Map, elems, fromList, lookup)
18+import Data.Maybe (fromMaybe, mapMaybe)
3319import Data.Monoid ((<>))
34−import Control.DeepSeq (deepseq, NFData)
35−import Text.Pandoc.Error
20+import Network.URI (unEscapeString)
21+import System.FilePath (dropFileName, dropFileName, normalise, splitFileName,
22+ takeFileName, (</>))
23+import qualified Text.Pandoc.Builder as B
3624import Text.Pandoc.Class (PandocMonad, insertMedia)
25+import Text.Pandoc.Definition hiding (Attr)
26+import Text.Pandoc.Error
27+import Text.Pandoc.Extensions (Extension (Ext_raw_html), enableExtension)
28+import Text.Pandoc.MIME (MimeType)
29+import Text.Pandoc.Options (ReaderOptions (..))
30+import Text.Pandoc.Readers.HTML (readHtml)
31+import Text.Pandoc.Shared (addMetaField, collapseFilePath, escapeURI)
32+import qualified Text.Pandoc.UTF8 as UTF8 (toStringLazy)
33+import Text.Pandoc.Walk (query, walk)
34+import Text.XML.Light
3735
3836type Items = M.Map String (FilePath, MimeType)
3937
@@ -99,7 +97,7 @@ fetchImages mimes root arc (query iq -> links) =
9997
10098iq :: Inline -> [FilePath]
10199iq (Image _ _ (url, _)) = [url]
102−iq _ = []
100+iq _ = []
103101
104102-- Remove relative paths
105103renameImages :: FilePath -> Inline -> Inline
@@ -159,7 +157,7 @@ parseMetaItem e@(stripNamespace . elName -> field) meta =
159157
160158renameMeta :: String -> String
161159renameMeta "creator" = "author"
162−renameMeta s = s
160+renameMeta s = s
163161
164162getManifest :: PandocMonad m => Archive -> m (String, Element)
165163getManifest archive = do
@@ -216,7 +214,7 @@ fixAttrs :: FilePath -> B.Attr -> B.Attr
216214fixAttrs s (ident, cs, kvs) = (addHash s ident, filter (not . null) cs, removeEPUBAttrs kvs)
217215
218216addHash :: String -> String -> String
219−addHash _ "" = ""
217+addHash _ "" = ""
220218addHash s ident = takeFileName s ++ "#" ++ ident
221219
222220removeEPUBAttrs :: [(String, String)] -> [(String, String)]
@@ -244,7 +242,7 @@ stripNamespace (QName v _ _) = v
244242
245243attrToNSPair :: Attr -> Maybe (String, String)
246244attrToNSPair (Attr (QName "xmlns" _ _) val) = Just ("xmlns", val)
247−attrToNSPair _ = Nothing
245+attrToNSPair _ = Nothing
248246
249247attrToPair :: Attr -> (String, String)
250248attrToPair (Attr (QName name _ _) val) = (name, val)
src/Text/Pandoc/Readers/Haddock.hs+9−9
@@ -14,19 +14,19 @@ module Text.Pandoc.Readers.Haddock
1414 ( readHaddock
1515 ) where
1616
17−import Text.Pandoc.Builder (Blocks, Inlines)
18−import qualified Text.Pandoc.Builder as B
19−import Data.Monoid ((<>))
20−import Text.Pandoc.Shared (trim, splitBy)
17+import Control.Monad.Except (throwError)
2118import Data.List (intersperse, stripPrefix)
2219import Data.Maybe (fromMaybe)
23−import Text.Pandoc.Definition
24−import Text.Pandoc.Options
20+import Data.Monoid ((<>))
2521import Documentation.Haddock.Parser
2622import Documentation.Haddock.Types
27−import Text.Pandoc.Error
28−import Control.Monad.Except (throwError)
23+import Text.Pandoc.Builder (Blocks, Inlines)
24+import qualified Text.Pandoc.Builder as B
2925import Text.Pandoc.Class (PandocMonad)
26+import Text.Pandoc.Definition
27+import Text.Pandoc.Error
28+import Text.Pandoc.Options
29+import Text.Pandoc.Shared (splitBy, trim)
3030
3131
3232-- | Parse Haddock markup and return a 'Pandoc' document.
@@ -96,7 +96,7 @@ docHToBlocks d' =
9696 isPlain (Plain _) = True
9797 isPlain _ = False
9898 extractContents (Plain xs) = xs
99− extractContents _ = []
99+ extractContents _ = []
100100
101101docHToInlines :: Bool -> DocH String Identifier -> Inlines
102102docHToInlines isCode d' =
src/Text/Pandoc/Readers/LaTeX.hs+29−29
@@ -1,4 +1,5 @@
1−{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
23{-
34Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
45
@@ -34,26 +35,25 @@ module Text.Pandoc.Readers.LaTeX ( readLaTeX,
3435 inlineCommand,
3536 ) where
3637
37−import Text.Pandoc.Definition
38−import Text.Pandoc.Walk
39−import Text.Pandoc.Shared
40−import Text.Pandoc.Options
41−import Text.Pandoc.Logging
42−import Text.Pandoc.Parsing hiding ((<|>), many, optional, space,
43− mathDisplay, mathInline)
44−import Data.Char ( chr, ord, isLetter, isAlphaNum )
38+import Control.Applicative (many, optional, (<|>))
4539import Control.Monad
46−import Text.Pandoc.Builder
47−import Control.Applicative ((<|>), many, optional)
48−import Data.Maybe (fromMaybe, maybeToList)
49−import System.FilePath (replaceExtension, takeExtension, addExtension)
40+import Control.Monad.Except (throwError)
41+import Data.Char (chr, isAlphaNum, isLetter, ord)
5042import Data.List (intercalate)
5143import qualified Data.Map as M
44+import Data.Maybe (fromMaybe, maybeToList)
45+import System.FilePath (addExtension, replaceExtension, takeExtension)
46+import Text.Pandoc.Builder
47+import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, readFileFromDirs,
48+ report, setResourcePath)
5249import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
5350import Text.Pandoc.ImageSize (numUnit, showFl)
54−import Control.Monad.Except (throwError)
55−import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, report,
56− readFileFromDirs, setResourcePath)
51+import Text.Pandoc.Logging
52+import Text.Pandoc.Options
53+import Text.Pandoc.Parsing hiding (many, mathDisplay, mathInline, optional,
54+ space, (<|>))
55+import Text.Pandoc.Shared
56+import Text.Pandoc.Walk
5757
5858-- | Parse LaTeX from string and return 'Pandoc' document.
5959readLaTeX :: PandocMonad m
@@ -64,7 +64,7 @@ readLaTeX opts ltx = do
6464 parsed <- readWithM parseLaTeX def{ stateOptions = opts } ltx
6565 case parsed of
6666 Right result -> return result
67− Left e -> throwError e
67+ Left e -> throwError e
6868
6969parseLaTeX :: PandocMonad m => LP m Pandoc
7070parseLaTeX = do
@@ -90,9 +90,9 @@ controlSeq :: PandocMonad m => String -> LP m String
9090controlSeq name = try $ do
9191 char '\\'
9292 case name of
93− "" -> mzero
93+ "" -> mzero
9494 [c] | not (isLetter c) -> string [c]
95− cs -> string cs <* notFollowedBy letter <* optional sp
95+ cs -> string cs <* notFollowedBy letter <* optional sp
9696 return name
9797
9898dimenarg :: PandocMonad m => LP m String
@@ -176,11 +176,11 @@ mathChars =
176176 where escapedChar = try $ do char '\\'
177177 c <- anyChar
178178 return ['\\',c]
179− isOrdChar '$' = False
180− isOrdChar '{' = False
181− isOrdChar '}' = False
179+ isOrdChar '$' = False
180+ isOrdChar '{' = False
181+ isOrdChar '}' = False
182182 isOrdChar '\\' = False
183− isOrdChar _ = True
183+ isOrdChar _ = True
184184
185185quoted' :: PandocMonad m => (Inlines -> Inlines) -> LP m String -> LP m () -> LP m Inlines
186186quoted' f starter ender = do
@@ -192,9 +192,9 @@ quoted' f starter ender = do
192192 (ender >> return (f (mconcat ils))) <|>
193193 (<> mconcat ils) <$>
194194 lit (case startchs of
195− "``" -> "“"
196− "`" -> "‘"
197− _ -> startchs)
195+ "``" -> "“"
196+ "`" -> "‘"
197+ _ -> startchs)
198198 else lit startchs
199199
200200doubleQuote :: PandocMonad m => LP m Inlines
@@ -1155,7 +1155,7 @@ closing = do
11551155 st <- getState
11561156 let extractInlines (MetaBlocks [Plain ys]) = ys
11571157 extractInlines (MetaBlocks [Para ys ]) = ys
1158− extractInlines _ = []
1158+ extractInlines _ = []
11591159 let sigs = case lookupMeta "author" (stateMeta st) of
11601160 Just (MetaList xs) ->
11611161 para $ trimInlines $ fromList $
@@ -1263,8 +1263,8 @@ preamble = mempty <$> manyTill preambleBlock beginDoc
12631263-- citations
12641264
12651265addPrefix :: [Inline] -> [Citation] -> [Citation]
1266−addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
1267−addPrefix _ _ = []
1266+addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
1267+addPrefix _ _ = []
12681268
12691269addSuffix :: [Inline] -> [Citation] -> [Citation]
12701270addSuffix s ks@(_:_) =
src/Text/Pandoc/Readers/Markdown.hs+49−49
@@ -1,4 +1,4 @@
1−{-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7
1+{-# LANGUAGE RelaxedPolyRec #-}
22{-# LANGUAGE ScopedTypeVariables #-}
33
44{-
@@ -32,40 +32,40 @@ Conversion of markdown-formatted plain text to 'Pandoc' document.
3232-}
3333module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
3434
35−import Data.List ( transpose, sortBy, findIndex, intercalate )
35+import Control.Monad
36+import Control.Monad.Except (catchError, throwError)
37+import Control.Monad.Trans (lift)
38+import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)
39+import qualified Data.HashMap.Strict as H
40+import Data.List (findIndex, intercalate, sortBy, transpose)
3641import qualified Data.Map as M
37−import Data.Scientific (coefficient, base10Exponent)
38−import Data.Ord ( comparing )
39−import Data.Char ( isSpace, isAlphaNum, toLower, isPunctuation )
4042import Data.Maybe
41−import Text.Pandoc.Definition
42−import Text.Pandoc.Emoji (emojis)
43−import Text.Pandoc.Generic (bottomUp)
44−import qualified Data.Text as T
43+import Data.Monoid ((<>))
44+import Data.Ord (comparing)
45+import Data.Scientific (base10Exponent, coefficient)
4546import Data.Text (Text)
47+import qualified Data.Text as T
48+import qualified Data.Vector as V
49+import Data.Yaml (ParseException (..), YamlException (..), YamlMark (..))
4650import qualified Data.Yaml as Yaml
47−import Data.Yaml (ParseException(..), YamlException(..), YamlMark(..))
48−import qualified Data.HashMap.Strict as H
51+import System.FilePath (addExtension, takeExtension)
52+import Text.HTML.TagSoup
53+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
4954import qualified Text.Pandoc.Builder as B
50−import qualified Text.Pandoc.UTF8 as UTF8
51−import qualified Data.Vector as V
52−import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
53−import Text.Pandoc.Options
55+import Text.Pandoc.Class (PandocMonad, report)
56+import Text.Pandoc.Definition
57+import Text.Pandoc.Emoji (emojis)
58+import Text.Pandoc.Generic (bottomUp)
5459import Text.Pandoc.Logging
55−import Text.Pandoc.Shared
60+import Text.Pandoc.Options
61+import Text.Pandoc.Parsing hiding (tableWith)
5662import Text.Pandoc.Pretty (charWidth)
63+import Text.Pandoc.Readers.HTML (htmlInBalanced, htmlTag, isBlockTag,
64+ isCommentTag, isInlineTag, isTextTag)
65+import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)
66+import Text.Pandoc.Shared
67+import qualified Text.Pandoc.UTF8 as UTF8
5768import Text.Pandoc.XML (fromEntities)
58−import Text.Pandoc.Parsing hiding (tableWith)
59−import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
60−import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,
61− isTextTag, isCommentTag )
62−import Control.Monad
63−import System.FilePath (takeExtension, addExtension)
64−import Text.HTML.TagSoup
65−import Data.Monoid ((<>))
66−import Control.Monad.Trans (lift)
67−import Control.Monad.Except (throwError, catchError)
68−import Text.Pandoc.Class (PandocMonad, report)
6969
7070type MarkdownParser m = ParserT [Char] ParserState m
7171
@@ -78,7 +78,7 @@ readMarkdown opts s = do
7878 parsed <- (readWithM parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
7979 case parsed of
8080 Right result -> return result
81− Left e -> throwError e
81+ Left e -> throwError e
8282
8383trimInlinesF :: F Inlines -> F Inlines
8484trimInlinesF = liftM trimInlines
@@ -235,11 +235,11 @@ pandocTitleBlock = try $ do
235235 $ nullMeta
236236 updateState $ \st -> st{ stateMeta' = stateMeta' st <> meta' }
237237
238−
238+
239239-- Adapted from solution at
240240-- http://stackoverflow.com/a/29448764/1901888
241241foldrWithKeyM :: Monad m => (k -> b -> a -> m a) -> a -> H.HashMap k b -> m a
242−foldrWithKeyM f acc = H.foldrWithKey f' (return acc)
242+foldrWithKeyM f acc = H.foldrWithKey f' (return acc)
243243 where
244244 f' k b ma = ma >>= \a -> f k b a
245245
@@ -688,9 +688,9 @@ codeBlockFenced = try $ do
688688-- correctly handle github language identifiers
689689toLanguageId :: String -> String
690690toLanguageId = map toLower . go
691− where go "c++" = "cpp"
691+ where go "c++" = "cpp"
692692 go "objective-c" = "objectivec"
693− go x = x
693+ go x = x
694694
695695codeBlockIndented :: PandocMonad m => MarkdownParser m (F Blocks)
696696codeBlockIndented = do
@@ -1167,13 +1167,13 @@ alignType strLst len =
11671167 let nonempties = filter (not . null) $ map trimr strLst
11681168 (leftSpace, rightSpace) =
11691169 case sortBy (comparing length) nonempties of
1170− (x:_) -> (head x `elem` " \t", length x < len)
1171− [] -> (False, False)
1170+ (x:_) -> (head x `elem` " \t", length x < len)
1171+ [] -> (False, False)
11721172 in case (leftSpace, rightSpace) of
1173− (True, False) -> AlignRight
1174− (False, True) -> AlignLeft
1175− (True, True) -> AlignCenter
1176− (False, False) -> AlignDefault
1173+ (True, False) -> AlignRight
1174+ (False, True) -> AlignLeft
1175+ (True, True) -> AlignCenter
1176+ (False, False) -> AlignDefault
11771177
11781178-- Parse a table footer - dashed lines followed by blank line.
11791179tableFooter :: PandocMonad m => MarkdownParser m String
@@ -1352,7 +1352,7 @@ removeOneLeadingSpace xs =
13521352 if all startsWithSpace xs
13531353 then map (drop 1) xs
13541354 else xs
1355− where startsWithSpace "" = True
1355+ where startsWithSpace "" = True
13561356 startsWithSpace (y:_) = y == ' '
13571357
13581358-- | Parse footer for a grid table.
@@ -1475,8 +1475,8 @@ table = try $ do
14751475 (gridTable False <|> gridTable True)) <?> "table"
14761476 optional blanklines
14771477 caption <- case frontCaption of
1478− Nothing -> option (return mempty) tableCaption
1479− Just c -> return c
1478+ Nothing -> option (return mempty) tableCaption
1479+ Just c -> return c
14801480 -- renormalize widths if greater than 100%:
14811481 let totalWidth = sum widths
14821482 let widths' = if totalWidth < 1
@@ -1555,8 +1555,8 @@ exampleRef = try $ do
15551555 return $ do
15561556 st <- askF
15571557 return $ case M.lookup lab (stateExamples st) of
1558− Just n -> B.str (show n)
1559− Nothing -> B.str ('@':lab)
1558+ Just n -> B.str (show n)
1559+ Nothing -> B.str ('@':lab)
15601560
15611561symbol :: PandocMonad m => MarkdownParser m (F Inlines)
15621562symbol = do
@@ -1600,10 +1600,10 @@ enclosure c = do
16001600 (return (B.str cs) <>) <$> whitespace
16011601 <|> do
16021602 case length cs of
1603− 3 -> three c
1604− 2 -> two c mempty
1605− 1 -> one c mempty
1606− _ -> return (return $ B.str cs)
1603+ 3 -> three c
1604+ 2 -> two c mempty
1605+ 1 -> one c mempty
1606+ _ -> return (return $ B.str cs)
16071607
16081608ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
16091609ender c n = try $ do
@@ -1839,9 +1839,9 @@ referenceLink constructor (lab, raw) = do
18391839dropBrackets :: String -> String
18401840dropBrackets = reverse . dropRB . reverse . dropLB
18411841 where dropRB (']':xs) = xs
1842− dropRB xs = xs
1842+ dropRB xs = xs
18431843 dropLB ('[':xs) = xs
1844− dropLB xs = xs
1844+ dropLB xs = xs
18451845
18461846bareURL :: PandocMonad m => MarkdownParser m (F Inlines)
18471847bareURL = try $ do
src/Text/Pandoc/Readers/MediaWiki.hs+29−27
@@ -1,4 +1,6 @@
1−{-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE RelaxedPolyRec #-}
3+{-# LANGUAGE TypeSynonymInstances #-}
24-- RelaxedPolyRec needed for inlinesBetween on GHC < 7
35{-
46 Copyright (C) 2012-2015 John MacFarlane <jgm@berkeley.edu>
@@ -36,28 +38,28 @@ _ parse templates?
3638-}
3739module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
3840
39−import Text.Pandoc.Definition
40−import qualified Text.Pandoc.Builder as B
41−import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
42−import Data.Monoid ((<>))
43−import Text.Pandoc.Options
44−import Text.Pandoc.Logging
45−import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )
46−import Text.Pandoc.XML ( fromEntities )
47−import Text.Pandoc.Parsing hiding ( nested )
48−import Text.Pandoc.Walk ( walk )
49−import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify, trim )
5041import Control.Monad
51−import Data.List (intersperse, intercalate, isPrefixOf )
52−import Text.HTML.TagSoup
53−import Data.Sequence (viewl, ViewL(..), (<|))
42+import Control.Monad.Except (throwError)
43+import Data.Char (isDigit, isSpace)
5444import qualified Data.Foldable as F
45+import Data.List (intercalate, intersperse, isPrefixOf)
5546import qualified Data.Map as M
56−import qualified Data.Set as Set
57−import Data.Char (isDigit, isSpace)
5847import Data.Maybe (fromMaybe)
59−import Control.Monad.Except (throwError)
48+import Data.Monoid ((<>))
49+import Data.Sequence (ViewL (..), viewl, (<|))
50+import qualified Data.Set as Set
51+import Text.HTML.TagSoup
52+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
53+import qualified Text.Pandoc.Builder as B
6054import Text.Pandoc.Class (PandocMonad, report)
55+import Text.Pandoc.Definition
56+import Text.Pandoc.Logging
57+import Text.Pandoc.Options
58+import Text.Pandoc.Parsing hiding (nested)
59+import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isCommentTag)
60+import Text.Pandoc.Shared (safeRead, stringify, stripTrailingNewlines, trim)
61+import Text.Pandoc.Walk (walk)
62+import Text.Pandoc.XML (fromEntities)
6163
6264-- | Read mediawiki from an input string and return a Pandoc document.
6365readMediaWiki :: PandocMonad m
@@ -75,7 +77,7 @@ readMediaWiki opts s = do
7577 (s ++ "\n")
7678 case parsed of
7779 Right result -> return result
78− Left e -> throwError e
80+ Left e -> throwError e
7981
8082data MWState = MWState { mwOptions :: ReaderOptions
8183 , mwMaxNestingLevel :: Int
@@ -134,7 +136,7 @@ isBlockTag' tag = isBlockTag tag
134136
135137isInlineTag' :: Tag String -> Bool
136138isInlineTag' (TagComment _) = True
137−isInlineTag' t = not (isBlockTag' t)
139+isInlineTag' t = not (isBlockTag' t)
138140
139141eitherBlockOrInline :: [String]
140142eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",
@@ -311,7 +313,7 @@ parseWidth :: String -> Maybe Double
311313parseWidth s =
312314 case reverse s of
313315 ('%':ds) | all isDigit ds -> safeRead ('0':'.':reverse ds)
314− _ -> Nothing
316+ _ -> Nothing
315317
316318template :: PandocMonad m => MWParser m String
317319template = try $ do
@@ -468,10 +470,10 @@ listItem c = try $ do
468470 many1 $ listItem' c)
469471 (unlines (first : rest))
470472 case c of
471− '*' -> return $ B.bulletList contents
472− '#' -> return $ B.orderedList contents
473− ':' -> return $ B.definitionList [(mempty, contents)]
474− _ -> mzero
473+ '*' -> return $ B.bulletList contents
474+ '#' -> return $ B.orderedList contents
475+ ':' -> return $ B.definitionList [(mempty, contents)]
476+ _ -> mzero
475477
476478-- The point of this is to handle stuff like
477479-- * {{cite book
@@ -619,9 +621,9 @@ imageOption = try $ char '|' *> opt
619621 <|> try (oneOfStrings ["link=","alt=","page=","class="] <* many (noneOf "|]"))
620622
621623collapseUnderscores :: String -> String
622−collapseUnderscores [] = []
624+collapseUnderscores [] = []
623625collapseUnderscores ('_':'_':xs) = collapseUnderscores ('_':xs)
624−collapseUnderscores (x:xs) = x : collapseUnderscores xs
626+collapseUnderscores (x:xs) = x : collapseUnderscores xs
625627
626628addUnderscores :: String -> String
627629addUnderscores = collapseUnderscores . intercalate "_" . words
src/Text/Pandoc/Readers/Native.hs+2−2
@@ -31,12 +31,12 @@ Conversion of a string representation of a pandoc type (@Pandoc@,
3131module Text.Pandoc.Readers.Native ( readNative ) where
3232
3333import Text.Pandoc.Definition
34−import Text.Pandoc.Shared (safeRead)
3534import Text.Pandoc.Options (ReaderOptions)
35+import Text.Pandoc.Shared (safeRead)
3636
3737import Control.Monad.Except (throwError)
38−import Text.Pandoc.Error
3938import Text.Pandoc.Class
39+import Text.Pandoc.Error
4040
4141-- | Read native formatted text and return a Pandoc document.
4242-- The input may be a full pandoc document, a block list, a block,
src/Text/Pandoc/Readers/OPML.hs+7−8
@@ -1,17 +1,16 @@
11{-# LANGUAGE FlexibleContexts #-}
22module Text.Pandoc.Readers.OPML ( readOPML ) where
3+import Control.Monad.State
34import Data.Char (toUpper)
4−import Text.Pandoc.Options
5−import Text.Pandoc.Definition
5+import Data.Default
6+import Data.Generics
7+import Text.HTML.TagSoup.Entity (lookupEntity)
68import Text.Pandoc.Builder
9+import Text.Pandoc.Class (PandocMonad)
10+import Text.Pandoc.Options
711import Text.Pandoc.Readers.HTML (readHtml)
812import Text.Pandoc.Readers.Markdown (readMarkdown)
913import Text.XML.Light
10−import Text.HTML.TagSoup.Entity (lookupEntity)
11−import Data.Generics
12−import Control.Monad.State
13−import Data.Default
14−import Text.Pandoc.Class (PandocMonad)
1514
1615type OPML m = StateT OPMLState m
1716
@@ -70,7 +69,7 @@ asHtml :: PandocMonad m => String -> OPML m Inlines
7069asHtml s =
7170 (\(Pandoc _ bs) -> case bs of
7271 [Plain ils] -> fromList ils
73− _ -> mempty) <$> (lift $ readHtml def s)
72+ _ -> mempty) <$> (lift $ readHtml def s)
7473
7574asMarkdown :: PandocMonad m => String -> OPML m Blocks
7675asMarkdown s = (\(Pandoc _ bs) -> fromList bs) <$> (lift $ readMarkdown def s)
src/Text/Pandoc/Readers/Org.hs+9−9
@@ -27,17 +27,17 @@ Conversion of org-mode formatted plain text to 'Pandoc' document.
2727-}
2828module Text.Pandoc.Readers.Org ( readOrg ) where
2929
30−import Text.Pandoc.Readers.Org.Blocks ( blockList, meta )
31−import Text.Pandoc.Readers.Org.Parsing ( OrgParser, readWithM )
32−import Text.Pandoc.Readers.Org.ParserState ( optionsToParserState )
30+import Text.Pandoc.Readers.Org.Blocks (blockList, meta)
31+import Text.Pandoc.Readers.Org.ParserState (optionsToParserState)
32+import Text.Pandoc.Readers.Org.Parsing (OrgParser, readWithM)
3333
34−import Text.Pandoc.Class (PandocMonad)
35−import Text.Pandoc.Definition
36−import Text.Pandoc.Error
37−import Text.Pandoc.Options
34+import Text.Pandoc.Class (PandocMonad)
35+import Text.Pandoc.Definition
36+import Text.Pandoc.Error
37+import Text.Pandoc.Options
3838
39−import Control.Monad.Except ( throwError )
40−import Control.Monad.Reader ( runReaderT )
39+import Control.Monad.Except (throwError)
40+import Control.Monad.Reader (runReaderT)
4141
4242
4343-- | Parse org-mode string and return a Pandoc document.
src/Text/Pandoc/Readers/Org/BlockStarts.hs+1−1
@@ -40,7 +40,7 @@ module Text.Pandoc.Readers.Org.BlockStarts
4040 , endOfBlock
4141 ) where
4242
43−import Control.Monad ( void )
43+import Control.Monad (void)
4444import Text.Pandoc.Readers.Org.Parsing
4545
4646-- | Horizontal Line (five -- dashes or more)
src/Text/Pandoc/Readers/Org/Blocks.hs+25−25
@@ -1,6 +1,6 @@
11{-# LANGUAGE FlexibleContexts #-}
2−{-# LANGUAGE RecordWildCards #-}
3−{-# LANGUAGE ViewPatterns #-}
2+{-# LANGUAGE RecordWildCards #-}
3+{-# LANGUAGE ViewPatterns #-}
44{-
55Copyright (C) 2014-2017 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
66
@@ -33,28 +33,28 @@ module Text.Pandoc.Readers.Org.Blocks
3333 , meta
3434 ) where
3535
36−import Text.Pandoc.Readers.Org.BlockStarts
37−import Text.Pandoc.Readers.Org.Inlines
38−import Text.Pandoc.Readers.Org.Meta ( metaExport, metaKey, metaLine )
39−import Text.Pandoc.Readers.Org.ParserState
40−import Text.Pandoc.Readers.Org.Parsing
41−import Text.Pandoc.Readers.Org.Shared
42− ( cleanLinkString, isImageFilename, rundocBlockClass
43− , toRundocAttrib, translateLang )
36+import Text.Pandoc.Readers.Org.BlockStarts
37+import Text.Pandoc.Readers.Org.Inlines
38+import Text.Pandoc.Readers.Org.Meta (metaExport, metaKey, metaLine)
39+import Text.Pandoc.Readers.Org.ParserState
40+import Text.Pandoc.Readers.Org.Parsing
41+import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
42+ rundocBlockClass, toRundocAttrib,
43+ translateLang)
4444
45+import Text.Pandoc.Builder (Blocks, Inlines)
4546import qualified Text.Pandoc.Builder as B
46−import Text.Pandoc.Builder ( Inlines, Blocks )
47−import Text.Pandoc.Class (PandocMonad)
48−import Text.Pandoc.Definition
49−import Text.Pandoc.Options
50−import Text.Pandoc.Shared ( compactify, compactifyDL, safeRead )
51−
52−import Control.Monad ( foldM, guard, mzero, void )
53−import Data.Char ( isSpace, toLower, toUpper)
54−import Data.Default ( Default )
55−import Data.List ( foldl', isPrefixOf )
56−import Data.Maybe ( fromMaybe, isNothing )
57−import Data.Monoid ((<>))
47+import Text.Pandoc.Class (PandocMonad)
48+import Text.Pandoc.Definition
49+import Text.Pandoc.Options
50+import Text.Pandoc.Shared (compactify, compactifyDL, safeRead)
51+
52+import Control.Monad (foldM, guard, mzero, void)
53+import Data.Char (isSpace, toLower, toUpper)
54+import Data.Default (Default)
55+import Data.List (foldl', isPrefixOf)
56+import Data.Maybe (fromMaybe, isNothing)
57+import Data.Monoid ((<>))
5858
5959--
6060-- Org headers
@@ -581,7 +581,7 @@ genericDrawer = try $ do
581581 _ | name == "PROPERTIES" -> return mempty
582582 Left names | name `elem` names -> return mempty
583583 Right names | name `notElem` names -> return mempty
584− _ -> drawerDiv name <$> parseLines content
584+ _ -> drawerDiv name <$> parseLines content
585585 where
586586 parseLines :: PandocMonad m => [String] -> OrgParser m (F Blocks)
587587 parseLines = parseFromString blocks . (++ "\n") . unlines
@@ -715,8 +715,8 @@ data OrgTableRow = OrgContentRow (F [Blocks])
715715-- should be generated using a builder function.
716716data OrgTable = OrgTable
717717 { orgTableColumnProperties :: [ColumnProperty]
718− , orgTableHeader :: [Blocks]
719− , orgTableRows :: [[Blocks]]
718+ , orgTableHeader :: [Blocks]
719+ , orgTableRows :: [[Blocks]]
720720 }
721721
722722table :: PandocMonad m => OrgParser m (F Blocks)
src/Text/Pandoc/Readers/Org/ExportSettings.hs+5−5
@@ -29,12 +29,12 @@ module Text.Pandoc.Readers.Org.ExportSettings
2929 ( exportSettings
3030 ) where
3131
32−import Text.Pandoc.Readers.Org.ParserState
33−import Text.Pandoc.Readers.Org.Parsing
32+import Text.Pandoc.Readers.Org.ParserState
33+import Text.Pandoc.Readers.Org.Parsing
3434
35−import Control.Monad ( mzero, void )
36−import Data.Char ( toLower )
37−import Data.Maybe ( listToMaybe )
35+import Control.Monad (mzero, void)
36+import Data.Char (toLower)
37+import Data.Maybe (listToMaybe)
3838
3939-- | Read and handle space separated org-mode export settings.
4040exportSettings :: Monad m => OrgParser m ()
src/Text/Pandoc/Readers/Org/Inlines.hs+24−24
@@ -33,31 +33,31 @@ module Text.Pandoc.Readers.Org.Inlines
3333 , linkTarget
3434 ) where
3535
36−import Text.Pandoc.Readers.Org.BlockStarts ( endOfBlock, noteMarker )
37−import Text.Pandoc.Readers.Org.ParserState
38−import Text.Pandoc.Readers.Org.Parsing
39−import Text.Pandoc.Readers.Org.Shared
40− ( cleanLinkString, isImageFilename, rundocBlockClass
41− , toRundocAttrib, translateLang )
42−
36+import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
37+import Text.Pandoc.Readers.Org.ParserState
38+import Text.Pandoc.Readers.Org.Parsing
39+import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
40+ rundocBlockClass, toRundocAttrib,
41+ translateLang)
42+
43+import Text.Pandoc.Builder (Inlines)
4344import qualified Text.Pandoc.Builder as B
44−import Text.Pandoc.Builder ( Inlines )
45−import Text.Pandoc.Definition
46−import Text.Pandoc.Options
47−import Text.Pandoc.Readers.LaTeX ( inlineCommand, rawLaTeXInline )
48−import Text.TeXMath ( readTeX, writePandoc, DisplayType(..) )
45+import Text.Pandoc.Class (PandocMonad)
46+import Text.Pandoc.Definition
47+import Text.Pandoc.Options
48+import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
49+import Text.TeXMath (DisplayType (..), readTeX, writePandoc)
4950import qualified Text.TeXMath.Readers.MathML.EntityMap as MathMLEntityMap
50−import Text.Pandoc.Class (PandocMonad)
51−
52−import Prelude hiding (sequence)
53−import Control.Monad ( guard, mplus, mzero, when, void )
54−import Control.Monad.Trans ( lift )
55−import Data.Char ( isAlphaNum, isSpace )
56−import Data.List ( intersperse )
57−import Data.Maybe ( fromMaybe )
51+
52+import Control.Monad (guard, mplus, mzero, void, when)
53+import Control.Monad.Trans (lift)
54+import Data.Char (isAlphaNum, isSpace)
55+import Data.List (intersperse)
5856import qualified Data.Map as M
59−import Data.Monoid ( (<>) )
60−import Data.Traversable (sequence)
57+import Data.Maybe (fromMaybe)
58+import Data.Monoid ((<>))
59+import Data.Traversable (sequence)
60+import Prelude hiding (sequence)
6161
6262--
6363-- Functions acting on the parser state
@@ -258,10 +258,10 @@ berkeleyCite = try $ do
258258 appendSuffix suf c = c { citationSuffix = citationSuffix c <> B.toList suf }
259259
260260data BerkeleyCitationList = BerkeleyCitationList
261− { berkeleyCiteParens :: Bool
261+ { berkeleyCiteParens :: Bool
262262 , berkeleyCiteCommonPrefix :: Maybe Inlines
263263 , berkeleyCiteCommonSuffix :: Maybe Inlines
264− , berkeleyCiteCitations :: [Citation]
264+ , berkeleyCiteCitations :: [Citation]
265265 }
266266berkeleyCitationList :: PandocMonad m => OrgParser m (F BerkeleyCitationList)
267267berkeleyCitationList = try $ do
src/Text/Pandoc/Readers/Org/Meta.hs+15−15
@@ -1,5 +1,5 @@
11{-# LANGUAGE FlexibleContexts #-}
2−{-# LANGUAGE TupleSections #-}
2+{-# LANGUAGE TupleSections #-}
33{-
44Copyright (C) 2014-2017 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
55
@@ -33,23 +33,23 @@ module Text.Pandoc.Readers.Org.Meta
3333 , metaLine
3434 ) where
3535
36−import Text.Pandoc.Readers.Org.BlockStarts
37−import Text.Pandoc.Readers.Org.ExportSettings ( exportSettings )
38−import Text.Pandoc.Readers.Org.Inlines
39−import Text.Pandoc.Readers.Org.ParserState
40−import Text.Pandoc.Readers.Org.Parsing
36+import Text.Pandoc.Readers.Org.BlockStarts
37+import Text.Pandoc.Readers.Org.ExportSettings (exportSettings)
38+import Text.Pandoc.Readers.Org.Inlines
39+import Text.Pandoc.Readers.Org.ParserState
40+import Text.Pandoc.Readers.Org.Parsing
4141
42+import Text.Pandoc.Builder (Blocks, Inlines)
4243import qualified Text.Pandoc.Builder as B
43−import Text.Pandoc.Builder ( Blocks, Inlines )
44−import Text.Pandoc.Class ( PandocMonad )
45−import Text.Pandoc.Definition
44+import Text.Pandoc.Class (PandocMonad)
45+import Text.Pandoc.Definition
4646
47−import Control.Monad ( mzero, void )
48−import Data.Char ( toLower )
49−import Data.List ( intersperse )
47+import Control.Monad (mzero, void)
48+import Data.Char (toLower)
49+import Data.List (intersperse)
5050import qualified Data.Map as M
51−import Data.Monoid ( (<>) )
52−import Network.HTTP ( urlEncode )
51+import Data.Monoid ((<>))
52+import Network.HTTP (urlEncode)
5353
5454-- | Returns the current meta, respecting export options.
5555metaExport :: Monad m => OrgParser m (F Meta)
@@ -151,7 +151,7 @@ optionLine = try $ do
151151 "todo" -> todoSequence >>= updateState . registerTodoSequence
152152 "seq_todo" -> todoSequence >>= updateState . registerTodoSequence
153153 "typ_todo" -> todoSequence >>= updateState . registerTodoSequence
154− _ -> mzero
154+ _ -> mzero
155155
156156addLinkFormat :: Monad m => String
157157 -> (String -> String)
src/Text/Pandoc/Readers/Org/ParserState.hs+22−26
@@ -1,6 +1,6 @@
1−{-# LANGUAGE FlexibleInstances #-}
1+{-# LANGUAGE FlexibleInstances #-}
22{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3−{-# LANGUAGE MultiParamTypeClasses #-}
3+{-# LANGUAGE MultiParamTypeClasses #-}
44{-
55Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
66
@@ -50,24 +50,20 @@ module Text.Pandoc.Readers.Org.ParserState
5050 , optionsToParserState
5151 ) where
5252
53−import Control.Monad (liftM, liftM2)
54−import Control.Monad.Reader (Reader, runReader, ReaderT, ask, asks, local)
53+import Control.Monad (liftM, liftM2)
54+import Control.Monad.Reader (Reader, ReaderT, ask, asks, local, runReader)
5555
56−import Data.Default (Default(..))
56+import Data.Default (Default (..))
5757import qualified Data.Map as M
5858import qualified Data.Set as Set
5959
60−import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )
61−import Text.Pandoc.Definition ( Meta(..), nullMeta )
62−import Text.Pandoc.Options ( ReaderOptions(..) )
63−import Text.Pandoc.Parsing ( HasHeaderMap(..)
64− , HasIdentifierList(..)
65− , HasLastStrPosition(..)
66− , HasQuoteContext(..)
67− , HasReaderOptions(..)
68− , ParserContext(..)
69− , QuoteContext(..)
70− , SourcePos )
60+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
61+import Text.Pandoc.Definition (Meta (..), nullMeta)
62+import Text.Pandoc.Options (ReaderOptions (..))
63+import Text.Pandoc.Parsing (HasHeaderMap (..), HasIdentifierList (..),
64+ HasLastStrPosition (..), HasQuoteContext (..),
65+ HasReaderOptions (..), ParserContext (..),
66+ QuoteContext (..), SourcePos)
7167
7268-- | An inline note / footnote containing the note key and its (inline) value.
7369type OrgNoteRecord = (String, F Blocks)
@@ -191,20 +187,20 @@ data ArchivedTreesOption =
191187-- | Export settings <http://orgmode.org/manual/Export-settings.html>
192188-- These settings can be changed via OPTIONS statements.
193189data ExportSettings = ExportSettings
194− { exportArchivedTrees :: ArchivedTreesOption -- ^ How to treat archived trees
195− , exportDrawers :: Either [String] [String]
190+ { exportArchivedTrees :: ArchivedTreesOption -- ^ How to treat archived trees
191+ , exportDrawers :: Either [String] [String]
196192 -- ^ Specify drawer names which should be exported. @Left@ names are
197193 -- explicitly excluded from the resulting output while @Right@ means that
198194 -- only the listed drawer names should be included.
199− , exportEmphasizedText :: Bool -- ^ Parse emphasized text
200− , exportHeadlineLevels :: Int
195+ , exportEmphasizedText :: Bool -- ^ Parse emphasized text
196+ , exportHeadlineLevels :: Int
201197 -- ^ Maximum depth of headlines, deeper headlines are convert to list
202− , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
203− , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
204− , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
205− , exportWithAuthor :: Bool -- ^ Include author in final meta-data
206− , exportWithCreator :: Bool -- ^ Include creator in final meta-data
207− , exportWithEmail :: Bool -- ^ Include email in final meta-data
198+ , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
199+ , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
200+ , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
201+ , exportWithAuthor :: Bool -- ^ Include author in final meta-data
202+ , exportWithCreator :: Bool -- ^ Include creator in final meta-data
203+ , exportWithEmail :: Bool -- ^ Include email in final meta-data
208204 , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
209205 }
210206
src/Text/Pandoc/Readers/Org/Parsing.hs+5−5
@@ -108,14 +108,14 @@ module Text.Pandoc.Readers.Org.Parsing
108108 , getPosition
109109 ) where
110110
111−import Text.Pandoc.Readers.Org.ParserState
111+import Text.Pandoc.Readers.Org.ParserState
112112
113+import Text.Pandoc.Parsing hiding (anyLine, blanklines, newline,
114+ parseFromString)
113115import qualified Text.Pandoc.Parsing as P
114−import Text.Pandoc.Parsing hiding ( anyLine, blanklines, newline
115− , parseFromString )
116116
117−import Control.Monad ( guard )
118−import Control.Monad.Reader ( ReaderT )
117+import Control.Monad (guard)
118+import Control.Monad.Reader (ReaderT)
119119
120120-- | The parser used to read org files.
121121type OrgParser m = ParserT [Char] OrgParserState (ReaderT OrgParserLocal m)
src/Text/Pandoc/Readers/Org/Shared.hs+4−4
@@ -34,9 +34,9 @@ module Text.Pandoc.Readers.Org.Shared
3434 , translateLang
3535 ) where
3636
37−import Control.Arrow ( first )
38−import Data.Char ( isAlphaNum )
39−import Data.List ( isPrefixOf, isSuffixOf )
37+import Control.Arrow (first)
38+import Data.Char (isAlphaNum)
39+import Data.List (isPrefixOf, isSuffixOf)
4040
4141
4242-- | Check whether the given string looks like the path to of URL of an image.
@@ -59,7 +59,7 @@ cleanLinkString s =
5959 '.':'.':'/':_ -> Just s -- relative path
6060 -- Relative path or URL (file schema)
6161 'f':'i':'l':'e':':':s' -> Just $ if ("//" `isPrefixOf` s') then s else s'
62− _ | isUrl s -> Just s -- URL
62+ _ | isUrl s -> Just s -- URL
6363 _ -> Nothing
6464 where
6565 isUrl :: String -> Bool
src/Text/Pandoc/Readers/RST.hs+26−26
@@ -1,6 +1,6 @@
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE OverloadedStrings #-}
13{-# LANGUAGE ScopedTypeVariables #-}
2−{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE FlexibleContexts #-}
44{-
55Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
66
@@ -31,27 +31,27 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3131Conversion from reStructuredText to 'Pandoc' document.
3232-}
3333module Text.Pandoc.Readers.RST ( readRST ) where
34−import Text.Pandoc.Definition
35−import Text.Pandoc.Builder (setMeta, fromList)
36−import Text.Pandoc.Shared
37−import Text.Pandoc.Parsing
38−import Text.Pandoc.Options
39−import Text.Pandoc.Logging
40−import Text.Pandoc.Error
41−import Text.Pandoc.ImageSize (lengthToDim, scaleDimension)
42−import Control.Monad ( when, liftM, guard, mzero )
43−import Data.List ( findIndex, intercalate, isInfixOf,
44− transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
45−import Data.Maybe (fromMaybe, isJust)
34+import Control.Monad (guard, liftM, mzero, when)
35+import Control.Monad.Except (throwError)
36+import Data.Char (isHexDigit, isSpace, toLower, toUpper)
37+import Data.List (deleteFirstsBy, findIndex, intercalate, isInfixOf, isSuffixOf,
38+ nub, sort, transpose, union)
4639import qualified Data.Map as M
47−import Text.Printf ( printf )
48−import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
49−import qualified Text.Pandoc.Builder as B
50−import Data.Sequence (viewr, ViewR(..))
51−import Data.Char (toLower, isHexDigit, isSpace, toUpper)
40+import Data.Maybe (fromMaybe, isJust)
5241import Data.Monoid ((<>))
53−import Control.Monad.Except (throwError)
42+import Data.Sequence (ViewR (..), viewr)
43+import Text.Pandoc.Builder (fromList, setMeta)
44+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
45+import qualified Text.Pandoc.Builder as B
5446import Text.Pandoc.Class (PandocMonad, readFileFromDirs)
47+import Text.Pandoc.Definition
48+import Text.Pandoc.Error
49+import Text.Pandoc.ImageSize (lengthToDim, scaleDimension)
50+import Text.Pandoc.Logging
51+import Text.Pandoc.Options
52+import Text.Pandoc.Parsing
53+import Text.Pandoc.Shared
54+import Text.Printf (printf)
5555
5656-- TODO:
5757-- [ ] .. parsed-literal
@@ -667,7 +667,7 @@ directive' = do
667667 _ ->
668668 case safeRead v of
669669 Just (s :: Double) -> s
670− Nothing -> 1.0
670+ Nothing -> 1.0
671671 Nothing -> 1.0
672672 widthAttr = maybe [] (\x -> [("width",
673673 show $ scaleDimension scale x)])
@@ -744,7 +744,7 @@ directive' = do
744744 -- directive content or the first immediately following element
745745 children <- case body of
746746 "" -> block
747− _ -> parseFromString parseBlocks body'
747+ _ -> parseFromString parseBlocks body'
748748 return $ B.divWith attrs children
749749 other -> do
750750 pos <- getPosition
@@ -775,7 +775,7 @@ addNewRole roleString fields = do
775775 let getBaseRole (r, f, a) roles =
776776 case M.lookup r roles of
777777 Just (r', f', a') -> getBaseRole (r', f', a') roles
778− Nothing -> (r, f, a)
778+ Nothing -> (r, f, a)
779779 (baseRole, baseFmt, baseAttr) =
780780 getBaseRole (parentRole, Nothing, nullAttr) customRoles
781781 fmt = if parentRole == "raw" then lookup "format" fields else baseFmt
@@ -1003,7 +1003,7 @@ anonymousKey = try $ do
10031003stripTicks :: String -> String
10041004stripTicks = reverse . stripTick . reverse . stripTick
10051005 where stripTick ('`':xs) = xs
1006− stripTick xs = xs
1006+ stripTick xs = xs
10071007
10081008regularKey :: PandocMonad m => RSTParser m ()
10091009regularKey = try $ do
@@ -1320,7 +1320,7 @@ explicitLink = try $ do
13201320 -- `link <google_>` is a reference link to _google!
13211321 ((src',tit),attr) <- case reverse src of
13221322 '_':xs -> lookupKey [] (toKey (reverse xs))
1323− _ -> return ((src, ""), nullAttr)
1323+ _ -> return ((src, ""), nullAttr)
13241324 return $ B.linkWith attr (escapeURI src') tit label''
13251325
13261326citationName :: PandocMonad m => RSTParser m Inlines
@@ -1342,7 +1342,7 @@ referenceLink = try $ do
13421342 do char '_'
13431343 let anonKeys = sort $ filter isAnonKey $ M.keys keyTable
13441344 case anonKeys of
1345− [] -> mzero
1345+ [] -> mzero
13461346 (k:_) -> return k
13471347 ((src,tit), attr) <- lookupKey [] key
13481348 -- if anonymous link, remove key so it won't be used again
src/Text/Pandoc/Readers/TWiki.hs+15−12
@@ -1,4 +1,7 @@
1−{-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances, FlexibleContexts #-}
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE RelaxedPolyRec #-}
4+{-# LANGUAGE TypeSynonymInstances #-}
25-- RelaxedPolyRec needed for inlinesBetween on GHC < 7
36{-
47 Copyright (C) 2014 Alexander Sulfrian <alexander.sulfrian@fu-berlin.de>
@@ -32,20 +35,20 @@ Conversion of twiki text to 'Pandoc' document.
3235module Text.Pandoc.Readers.TWiki ( readTWiki
3336 ) where
3437
35−import Text.Pandoc.Definition
38+import Control.Monad
39+import Control.Monad.Except (throwError)
40+import Data.Char (isAlphaNum)
41+import qualified Data.Foldable as F
42+import Data.Maybe (fromMaybe)
43+import Text.HTML.TagSoup
3644import qualified Text.Pandoc.Builder as B
37−import Text.Pandoc.Options
45+import Text.Pandoc.Class (PandocMonad, report)
46+import Text.Pandoc.Definition
3847import Text.Pandoc.Logging
48+import Text.Pandoc.Options
3949import Text.Pandoc.Parsing hiding (enclosed, macro, nested)
4050import Text.Pandoc.Readers.HTML (htmlTag, isCommentTag)
41−import Control.Monad
4251import Text.Pandoc.XML (fromEntities)
43−import Data.Maybe (fromMaybe)
44−import Text.HTML.TagSoup
45−import Data.Char (isAlphaNum)
46−import qualified Data.Foldable as F
47−import Control.Monad.Except (throwError)
48−import Text.Pandoc.Class (PandocMonad, report)
4952
5053-- | Read twiki from an input string and return a Pandoc document.
5154readTWiki :: PandocMonad m
@@ -391,8 +394,8 @@ attributes = char '{' *> spnl *> many (attribute <* spnl) <* char '}' >>=
391394 return . foldr (either mkContent mkKvs) ([], [])
392395 where
393396 spnl = skipMany (spaceChar <|> newline)
394− mkContent c ([], kvs) = (c, kvs)
395− mkContent c (rest, kvs) = (c ++ " " ++ rest, kvs)
397+ mkContent c ([], kvs) = (c, kvs)
398+ mkContent c (rest, kvs) = (c ++ " " ++ rest, kvs)
396399 mkKvs kv (cont, rest) = (cont, (kv : rest))
397400
398401attribute :: PandocMonad m => TWParser m (Either String (String, String))
src/Text/Pandoc/Readers/Textile.hs+16−16
@@ -51,24 +51,24 @@ TODO : refactor common patterns across readers :
5151
5252
5353module Text.Pandoc.Readers.Textile ( readTextile) where
54+import Control.Monad (guard, liftM)
55+import Control.Monad.Except (throwError)
56+import Data.Char (digitToInt, isUpper)
57+import Data.List (intercalate, intersperse, transpose)
58+import Data.Monoid ((<>))
59+import Text.HTML.TagSoup (Tag (..), fromAttrib)
60+import Text.HTML.TagSoup.Match
61+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
62+import qualified Text.Pandoc.Builder as B
63+import Text.Pandoc.Class (PandocMonad, report)
5464import Text.Pandoc.CSS
5565import Text.Pandoc.Definition
56−import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
57−import qualified Text.Pandoc.Builder as B
66+import Text.Pandoc.Logging
5867import Text.Pandoc.Options
5968import Text.Pandoc.Parsing
60−import Text.Pandoc.Logging
61−import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isInlineTag )
69+import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isInlineTag)
70+import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)
6271import Text.Pandoc.Shared (trim)
63−import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
64−import Text.HTML.TagSoup (fromAttrib, Tag(..))
65−import Text.HTML.TagSoup.Match
66−import Data.List ( intercalate, transpose, intersperse )
67−import Data.Char ( digitToInt, isUpper )
68−import Control.Monad ( guard, liftM )
69−import Data.Monoid ((<>))
70−import Text.Pandoc.Class (PandocMonad, report)
71−import Control.Monad.Except (throwError)
7272
7373-- | Parse a Textile text and return a Pandoc document.
7474readTextile :: PandocMonad m
@@ -79,7 +79,7 @@ readTextile opts s = do
7979 parsed <- readWithM parseTextile def{ stateOptions = opts } (s ++ "\n\n")
8080 case parsed of
8181 Right result -> return result
82− Left e -> throwError e
82+ Left e -> throwError e
8383
8484
8585-- | Generate a Pandoc ADT from a textile document
@@ -505,8 +505,8 @@ note = try $ do
505505 ref <- (char '[' *> many1 digit <* char ']')
506506 notes <- stateNotes <$> getState
507507 case lookup ref notes of
508− Nothing -> fail "note not found"
509− Just raw -> B.note <$> parseFromString parseBlocks raw
508+ Nothing -> fail "note not found"
509+ Just raw -> B.note <$> parseFromString parseBlocks raw
510510
511511-- | Special chars
512512markupChars :: [Char]
src/Text/Pandoc/Readers/Txt2Tags.hs+16−16
@@ -32,35 +32,35 @@ module Text.Pandoc.Readers.Txt2Tags ( readTxt2Tags
3232 )
3333 where
3434
35−import qualified Text.Pandoc.Builder as B
36−import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )
35+import Data.Char (toLower)
36+import Data.List (intercalate, intersperse, transpose)
37+import Data.Maybe (fromMaybe)
3738import Data.Monoid ((<>))
39+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
40+import qualified Text.Pandoc.Builder as B
3841import Text.Pandoc.Definition
3942import Text.Pandoc.Options
40−import Text.Pandoc.Shared (escapeURI,compactify, compactifyDL)
41−import Text.Pandoc.Parsing hiding (space, spaces, uri, macro)
42−import Data.Char (toLower)
43−import Data.List (transpose, intersperse, intercalate)
44−import Data.Maybe (fromMaybe)
43+import Text.Pandoc.Parsing hiding (macro, space, spaces, uri)
44+import Text.Pandoc.Shared (compactify, compactifyDL, escapeURI)
4545--import Network.URI (isURI) -- Not sure whether to use this function
46−import Control.Monad (void, guard, when)
46+import Control.Monad (guard, void, when)
47+import Control.Monad.Reader (Reader, asks, runReader)
4748import Data.Default
48−import Control.Monad.Reader (Reader, runReader, asks)
4949
50+import Control.Monad.Except (catchError, throwError)
5051import Data.Time.Format (formatTime)
51−import Text.Pandoc.Compat.Time (defaultTimeLocale)
52−import Control.Monad.Except (throwError, catchError)
5352import Text.Pandoc.Class (PandocMonad)
5453import qualified Text.Pandoc.Class as P
54+import Text.Pandoc.Compat.Time (defaultTimeLocale)
5555
5656type T2T = ParserT String ParserState (Reader T2TMeta)
5757
5858-- | An object for the T2T macros meta information
5959-- the contents of each field is simply substituted verbatim into the file
6060data T2TMeta = T2TMeta {
61− date :: String -- ^ Current date
62− , mtime :: String -- ^ Last modification time of infile
63− , infile :: FilePath -- ^ Input file
61+ date :: String -- ^ Current date
62+ , mtime :: String -- ^ Last modification time of infile
63+ , infile :: FilePath -- ^ Input file
6464 , outfile :: FilePath -- ^ Output file
6565 } deriving Show
6666
@@ -76,7 +76,7 @@ getT2TMeta = do
7676 Nothing -> []
7777 mbOutp <- P.getOutputFile
7878 let outp = case mbOutp of
79− Just x -> x
79+ Just x -> x
8080 Nothing -> ""
8181 curDate <- formatTime defaultTimeLocale "%F" <$> P.getZonedTime
8282 let getModTime = fmap (formatTime defaultTimeLocale "%T") .
@@ -98,7 +98,7 @@ readTxt2Tags opts s = do
9898 let parsed = flip runReader meta $ readWithM parseT2T (def {stateOptions = opts}) (s ++ "\n\n")
9999 case parsed of
100100 Right result -> return $ result
101− Left e -> throwError e
101+ Left e -> throwError e
102102
103103-- | Read Txt2Tags (ignoring all macros) from an input string returning
104104-- a Pandoc document
src/Text/Pandoc/SelfContained.hs+16−16
@@ -31,28 +31,28 @@ offline, by incorporating linked images, CSS, and scripts into
3131the HTML using data URIs.
3232-}
3333module Text.Pandoc.SelfContained ( makeSelfContained ) where
34−import Text.HTML.TagSoup
35−import Network.URI (isURI, escapeURIString, URI(..), parseURI)
36−import Data.ByteString.Base64
37−import qualified Data.ByteString.Char8 as B
38−import Data.ByteString (ByteString)
39−import System.FilePath (takeExtension, takeDirectory, (</>))
40−import Data.Char (toLower, isAscii, isAlphaNum)
4134import Codec.Compression.GZip as Gzip
42−import qualified Data.ByteString.Lazy as L
43−import Text.Pandoc.Shared (renderTags', trim)
44−import Text.Pandoc.MIME (MimeType)
45−import Text.Pandoc.UTF8 (toString)
46−import Text.Pandoc.Options (WriterOptions(..))
47−import Data.List (isPrefixOf)
4835import Control.Applicative ((<|>))
49−import Text.Parsec (runParserT, ParsecT)
50−import qualified Text.Parsec as P
5136import Control.Monad.Except (throwError)
5237import Control.Monad.Trans (lift)
53−import Text.Pandoc.Class (fetchItem, PandocMonad(..), report)
38+import Data.ByteString (ByteString)
39+import Data.ByteString.Base64
40+import qualified Data.ByteString.Char8 as B
41+import qualified Data.ByteString.Lazy as L
42+import Data.Char (isAlphaNum, isAscii, toLower)
43+import Data.List (isPrefixOf)
44+import Network.URI (URI (..), escapeURIString, isURI, parseURI)
45+import System.FilePath (takeDirectory, takeExtension, (</>))
46+import Text.HTML.TagSoup
47+import Text.Pandoc.Class (PandocMonad (..), fetchItem, report)
5448import Text.Pandoc.Error
5549import Text.Pandoc.Logging
50+import Text.Pandoc.MIME (MimeType)
51+import Text.Pandoc.Options (WriterOptions (..))
52+import Text.Pandoc.Shared (renderTags', trim)
53+import Text.Pandoc.UTF8 (toString)
54+import Text.Parsec (ParsecT, runParserT)
55+import qualified Text.Parsec as P
5656
5757isOk :: Char -> Bool
5858isOk c = isAscii c && isAlphaNum c
src/Text/Pandoc/Slides.hs+2−2
@@ -40,9 +40,9 @@ getSlideLevel = go 6
4040 | otherwise = go least (x:xs)
4141 go least (_ : xs) = go least xs
4242 go least [] = least
43− nonHOrHR (Header{}) = False
43+ 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+9−8
@@ -1,5 +1,7 @@
1−{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
2− OverloadedStrings, GeneralizedNewtypeDeriving #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3+{-# LANGUAGE OverloadedStrings #-}
4+{-# LANGUAGE TypeSynonymInstances #-}
35{-
46Copyright (C) 2009-2016 John MacFarlane <jgm@berkeley.edu>
57
@@ -39,13 +41,12 @@ module Text.Pandoc.Templates ( renderTemplate
3941 , Template
4042 , getDefaultTemplate ) where
4143
42−import Text.DocTemplates (Template, TemplateTarget, compileTemplate,
43− renderTemplate, applyTemplate,
44− varListToJSON)
45−import Data.Aeson (ToJSON(..))
44+import qualified Control.Exception.Extensible as E (IOException, try)
45+import Data.Aeson (ToJSON (..))
4646import qualified Data.Text as T
47−import System.FilePath ((</>), (<.>))
48−import qualified Control.Exception.Extensible as E (try, IOException)
47+import System.FilePath ((<.>), (</>))
48+import Text.DocTemplates (Template, TemplateTarget, applyTemplate,
49+ compileTemplate, renderTemplate, varListToJSON)
4950import Text.Pandoc.Shared (readDataFileUTF8)
5051
5152-- | Get default template for the specified writer.
src/Text/Pandoc/UTF8.hs+9−9
@@ -45,16 +45,16 @@ module Text.Pandoc.UTF8 ( readFile
4545
4646where
4747
48−import System.IO hiding (readFile, writeFile, getContents,
49− putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)
50−import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
51−import qualified System.IO as IO
5248import qualified Data.ByteString.Char8 as B
5349import qualified Data.ByteString.Lazy as BL
54−import qualified Data.Text.Encoding as T
5550import qualified Data.Text as T
51+import qualified Data.Text.Encoding as T
5652import qualified Data.Text.Lazy as TL
5753import qualified Data.Text.Lazy.Encoding as TL
54+import Prelude hiding (getContents, putStr, putStrLn, readFile, writeFile)
55+import System.IO hiding (getContents, hGetContents, hPutStr, hPutStrLn, putStr,
56+ putStrLn, readFile, writeFile)
57+import qualified System.IO as IO
5858
5959readFile :: FilePath -> IO String
6060readFile f = do
@@ -90,13 +90,13 @@ hGetContents = fmap toString . B.hGetContents
9090-- no-break space, so if the string begins with this we strip it off.
9191dropBOM :: String -> String
9292dropBOM ('\xFEFF':xs) = xs
93−dropBOM xs = xs
93+dropBOM xs = xs
9494
9595filterCRs :: String -> String
9696filterCRs ('\r':'\n':xs) = '\n': filterCRs xs
97−filterCRs ('\r':xs) = '\n' : filterCRs xs
98−filterCRs (x:xs) = x : filterCRs xs
99−filterCRs [] = []
97+filterCRs ('\r':xs) = '\n' : filterCRs xs
98+filterCRs (x:xs) = x : filterCRs xs
99+filterCRs [] = []
100100
101101-- | Convert UTF8-encoded ByteString to String, also
102102-- removing '\r' characters.
src/Text/Pandoc/UUID.hs+3−3
@@ -31,10 +31,10 @@ in RFC4122. See http://tools.ietf.org/html/rfc4122
3131
3232module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where
3333
34−import Text.Printf ( printf )
35−import System.Random ( RandomGen, randoms, getStdGen )
34+import Data.Bits (clearBit, setBit)
3635import Data.Word
37−import Data.Bits ( setBit, clearBit )
36+import System.Random (RandomGen, getStdGen, randoms)
37+import Text.Printf (printf)
3838
3939data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
4040 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
src/Text/Pandoc/Writers/AsciiDoc.hs+23−23
@@ -37,25 +37,25 @@ that it has omitted the construct.
3737AsciiDoc: <http://www.methods.co.nz/asciidoc/>
3838-}
3939module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc) where
40−import Text.Pandoc.Definition
41−import Text.Pandoc.Templates (renderTemplate')
42−import Text.Pandoc.Shared
43−import Text.Pandoc.Writers.Shared
44−import Text.Pandoc.Options
45−import Text.Pandoc.Parsing hiding (blankline, space)
46−import Data.Maybe (fromMaybe)
47−import Data.List ( stripPrefix, intersperse, intercalate )
48−import Text.Pandoc.Pretty
49−import Text.Pandoc.ImageSize
5040import Control.Monad.State
41+import Data.Aeson (Result (..), Value (String), fromJSON, toJSON)
42+import Data.Char (isPunctuation, isSpace)
43+import Data.List (intercalate, intersperse, stripPrefix)
5144import qualified Data.Map as M
52−import Data.Aeson (Value(String), fromJSON, toJSON, Result(..))
45+import Data.Maybe (fromMaybe)
5346import qualified Data.Text as T
54−import Data.Char (isSpace, isPunctuation)
5547import Text.Pandoc.Class (PandocMonad, report)
48+import Text.Pandoc.Definition
49+import Text.Pandoc.ImageSize
5650import Text.Pandoc.Logging
51+import Text.Pandoc.Options
52+import Text.Pandoc.Parsing hiding (blankline, space)
53+import Text.Pandoc.Pretty
54+import Text.Pandoc.Shared
55+import Text.Pandoc.Templates (renderTemplate')
56+import Text.Pandoc.Writers.Shared
5757
58−data WriterState = WriterState { defListMarker :: String
58+data WriterState = WriterState { defListMarker :: String
5959 , orderedListLevel :: Int
6060 , bulletListLevel :: Int
6161 , intraword :: Bool
@@ -122,8 +122,8 @@ olMarker = do (start, style', delim) <- anyOrderedListMarker
122122beginsWithOrderedListMarker :: String -> Bool
123123beginsWithOrderedListMarker str =
124124 case runParser olMarker defaultParserState "para start" (take 10 str) of
125− Left _ -> False
126− Right _ -> True
125+ Left _ -> False
126+ Right _ -> True
127127
128128-- | Convert Pandoc block element to asciidoc.
129129blockToAsciiDoc :: PandocMonad m
@@ -169,11 +169,11 @@ blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
169169 then
170170 identifier $$ contents $$
171171 (case level of
172− 1 -> text $ replicate len '-'
173− 2 -> text $ replicate len '~'
174− 3 -> text $ replicate len '^'
175− 4 -> text $ replicate len '+'
176− _ -> empty) <> blankline
172+ 1 -> text $ replicate len '-'
173+ 2 -> text $ replicate len '~'
174+ 3 -> text $ replicate len '^'
175+ 4 -> text $ replicate len '+'
176+ _ -> empty) <> blankline
177177 else
178178 identifier $$ text (replicate level '=') <> space <> contents <> blankline)
179179blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ (flush $
@@ -428,9 +428,9 @@ inlineToAsciiDoc _ LineBreak = return $ " +" <> cr
428428inlineToAsciiDoc _ Space = return space
429429inlineToAsciiDoc opts SoftBreak =
430430 case writerWrapText opts of
431− WrapAuto -> return space
431+ WrapAuto -> return space
432432 WrapPreserve -> return cr
433− WrapNone -> return space
433+ WrapNone -> return space
434434inlineToAsciiDoc opts (Cite _ lst) = inlineListToAsciiDoc opts lst
435435inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
436436-- relative: link:downloads/foo.zip[download foo.zip]
@@ -444,7 +444,7 @@ inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
444444 let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)
445445 let useAuto = case txt of
446446 [Str s] | escapeURI s == srcSuffix -> True
447− _ -> False
447+ _ -> False
448448 return $ if useAuto
449449 then text srcSuffix
450450 else prefix <> text src <> "[" <> linktext <> "]"
src/Text/Pandoc/Writers/CommonMark.hs+8−8
@@ -31,18 +31,18 @@ CommonMark: <http://commonmark.org>
3131-}
3232module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
3333
34−import Text.Pandoc.Writers.HTML (writeHtml5String)
34+import CMark
35+import Control.Monad.State (State, get, modify, runState)
36+import Data.Foldable (foldrM)
37+import qualified Data.Text as T
38+import Text.Pandoc.Class (PandocMonad)
3539import Text.Pandoc.Definition
40+import Text.Pandoc.Options
3641import Text.Pandoc.Shared (isTightList, linesToPara)
3742import Text.Pandoc.Templates (renderTemplate')
38−import Text.Pandoc.Writers.Shared
39−import Text.Pandoc.Options
40−import CMark
41−import qualified Data.Text as T
42−import Control.Monad.State (runState, State, modify, get)
4343import Text.Pandoc.Walk (walkM)
44−import Text.Pandoc.Class (PandocMonad)
45−import Data.Foldable (foldrM)
44+import Text.Pandoc.Writers.HTML (writeHtml5String)
45+import Text.Pandoc.Writers.Shared
4646
4747-- | Convert Pandoc to CommonMark.
4848writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m String
src/Text/Pandoc/Writers/ConTeXt.hs+27−27
@@ -29,21 +29,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2929Conversion of 'Pandoc' format into ConTeXt.
3030-}
3131module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
32+import Control.Monad.State
33+import Data.Char (ord)
34+import Data.List (intercalate, intersperse)
35+import Data.Maybe (catMaybes)
36+import Network.URI (isURI, unEscapeString)
37+import Text.Pandoc.Class (PandocMonad)
3238import Text.Pandoc.Definition
33−import Text.Pandoc.Shared
34−import Text.Pandoc.Writers.Shared
39+import Text.Pandoc.ImageSize
3540import Text.Pandoc.Options
36−import Text.Pandoc.Walk (query)
37−import Text.Printf ( printf )
38−import Data.List ( intercalate, intersperse )
39−import Data.Char ( ord )
40−import Data.Maybe ( catMaybes )
41−import Control.Monad.State
4241import Text.Pandoc.Pretty
43−import Text.Pandoc.ImageSize
44−import Text.Pandoc.Templates ( renderTemplate' )
45−import Network.URI ( isURI, unEscapeString )
46−import Text.Pandoc.Class (PandocMonad)
42+import Text.Pandoc.Shared
43+import Text.Pandoc.Templates (renderTemplate')
44+import Text.Pandoc.Walk (query)
45+import Text.Pandoc.Writers.Shared
46+import Text.Printf (printf)
4747
4848data WriterState =
4949 WriterState { stNextRef :: Int -- number of next URL reference
@@ -113,22 +113,22 @@ escapeCharForConTeXt :: WriterOptions -> Char -> String
113113escapeCharForConTeXt opts ch =
114114 let ligatures = isEnabled Ext_smart opts in
115115 case ch of
116− '{' -> "\\{"
117− '}' -> "\\}"
118− '\\' -> "\\letterbackslash{}"
119− '$' -> "\\$"
120− '|' -> "\\letterbar{}"
121− '%' -> "\\letterpercent{}"
122− '~' -> "\\lettertilde{}"
123− '#' -> "\\#"
124− '[' -> "{[}"
125− ']' -> "{]}"
126− '\160' -> "~"
116+ '{' -> "\\{"
117+ '}' -> "\\}"
118+ '\\' -> "\\letterbackslash{}"
119+ '$' -> "\\$"
120+ '|' -> "\\letterbar{}"
121+ '%' -> "\\letterpercent{}"
122+ '~' -> "\\lettertilde{}"
123+ '#' -> "\\#"
124+ '[' -> "{[}"
125+ ']' -> "{]}"
126+ '\160' -> "~"
127127 '\x2014' | ligatures -> "---"
128128 '\x2013' | ligatures -> "--"
129129 '\x2019' | ligatures -> "'"
130130 '\x2026' -> "\\ldots{}"
131− x -> [x]
131+ x -> [x]
132132
133133-- | Escape string for ConTeXt
134134stringToConTeXt :: WriterOptions -> String -> String
@@ -293,9 +293,9 @@ inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt $ addStruts lst
293293 addStruts xs
294294 addStruts (x:xs) = x : addStruts xs
295295 addStruts [] = []
296− isSpacey Space = True
296+ isSpacey Space = True
297297 isSpacey (Str ('\160':_)) = True
298− isSpacey _ = False
298+ isSpacey _ = False
299299
300300-- | Convert inline element to ConTeXt
301301inlineToConTeXt :: Inline -- ^ Inline to convert
@@ -398,7 +398,7 @@ inlineToConTeXt (Image attr@(_,cls,_) _ (src, _)) = do
398398inlineToConTeXt (Note contents) = do
399399 contents' <- blockListToConTeXt contents
400400 let codeBlock x@(CodeBlock _ _) = [x]
401− codeBlock _ = []
401+ codeBlock _ = []
402402 let codeBlocks = query codeBlock contents
403403 return $ if null codeBlocks
404404 then text "\\footnote{" <> nest 2 contents' <> char '}'
src/Text/Pandoc/Writers/Custom.hs+25−22
@@ -1,6 +1,9 @@
11{-# OPTIONS_GHC -fno-warn-orphans #-}
2−{-# LANGUAGE FlexibleInstances, OverloadedStrings,
3− ScopedTypeVariables, DeriveDataTypeable, CPP #-}
2+{-# LANGUAGE CPP #-}
3+{-# LANGUAGE DeriveDataTypeable #-}
4+{-# LANGUAGE FlexibleInstances #-}
5+{-# LANGUAGE OverloadedStrings #-}
6+{-# LANGUAGE ScopedTypeVariables #-}
47#if MIN_VERSION_base(4,8,0)
58#else
69{-# LANGUAGE OverlappingInstances #-}
@@ -35,20 +38,20 @@ Conversion of 'Pandoc' documents to custom markup using
3538a lua writer.
3639-}
3740module Text.Pandoc.Writers.Custom ( writeCustom ) where
38−import Text.Pandoc.Definition
39−import Text.Pandoc.Options
40−import Data.List ( intersperse )
41−import Data.Char ( toLower )
41+import Control.Exception
42+import Control.Monad (when)
43+import Data.Char (toLower)
44+import Data.List (intersperse)
45+import qualified Data.Map as M
4246import Data.Typeable
47+import GHC.IO.Encoding (getForeignEncoding, setForeignEncoding, utf8)
4348import Scripting.Lua (LuaState, StackValue, callfunc)
44−import Text.Pandoc.Writers.Shared
4549import qualified Scripting.Lua as Lua
46−import qualified Text.Pandoc.UTF8 as UTF8
47−import Control.Monad (when)
48−import Control.Exception
49−import qualified Data.Map as M
50+import Text.Pandoc.Definition
51+import Text.Pandoc.Options
5052import Text.Pandoc.Templates
51−import GHC.IO.Encoding (getForeignEncoding,setForeignEncoding, utf8)
53+import qualified Text.Pandoc.UTF8 as UTF8
54+import Text.Pandoc.Writers.Shared
5255
5356attrToMap :: Attr -> M.Map String String
5457attrToMap (id',classes,keyvals) = M.fromList
@@ -142,19 +145,19 @@ instance StackValue [Block] where
142145 valuetype _ = Lua.TSTRING
143146
144147instance StackValue MetaValue where
145− push l (MetaMap m) = Lua.push l m
146− push l (MetaList xs) = Lua.push l xs
147− push l (MetaBool x) = Lua.push l x
148− push l (MetaString s) = Lua.push l s
148+ push l (MetaMap m) = Lua.push l m
149+ push l (MetaList xs) = Lua.push l xs
150+ push l (MetaBool x) = Lua.push l x
151+ push l (MetaString s) = Lua.push l s
149152 push l (MetaInlines ils) = Lua.push l ils
150− push l (MetaBlocks bs) = Lua.push l bs
153+ push l (MetaBlocks bs) = Lua.push l bs
151154 peek _ _ = undefined
152− valuetype (MetaMap _) = Lua.TTABLE
153− valuetype (MetaList _) = Lua.TTABLE
154− valuetype (MetaBool _) = Lua.TBOOLEAN
155− valuetype (MetaString _) = Lua.TSTRING
155+ valuetype (MetaMap _) = Lua.TTABLE
156+ valuetype (MetaList _) = Lua.TTABLE
157+ valuetype (MetaBool _) = Lua.TBOOLEAN
158+ valuetype (MetaString _) = Lua.TSTRING
156159 valuetype (MetaInlines _) = Lua.TSTRING
157− valuetype (MetaBlocks _) = Lua.TSTRING
160+ valuetype (MetaBlocks _) = Lua.TSTRING
158161
159162instance StackValue Citation where
160163 push lua cit = do
src/Text/Pandoc/Writers/Docbook.hs+24−23
@@ -1,4 +1,5 @@
1−{-# LANGUAGE OverloadedStrings, PatternGuards #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE PatternGuards #-}
23{-
34Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
45
@@ -29,27 +30,27 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2930Conversion of 'Pandoc' documents to Docbook XML.
3031-}
3132module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where
33+import Control.Monad.Reader
34+import Data.Char (toLower)
35+import Data.Generics (everywhere, mkT)
36+import Data.List (intercalate, isPrefixOf, isSuffixOf, stripPrefix)
37+import Data.Monoid (Any (..))
38+import qualified Text.Pandoc.Builder as B
39+import Text.Pandoc.Class (PandocMonad, report)
3240import Text.Pandoc.Definition
33−import Text.Pandoc.XML
34−import Text.Pandoc.Shared
35−import Text.Pandoc.Walk
36−import Text.Pandoc.Writers.Shared
41+import Text.Pandoc.Highlighting (languages, languagesByExtension)
42+import Text.Pandoc.ImageSize
43+import Text.Pandoc.Logging
3744import Text.Pandoc.Options
45+import Text.Pandoc.Pretty
46+import Text.Pandoc.Shared
3847import Text.Pandoc.Templates (renderTemplate')
48+import Text.Pandoc.Walk
3949import Text.Pandoc.Writers.Math
40−import Data.List ( stripPrefix, isPrefixOf, intercalate, isSuffixOf )
41−import Data.Char ( toLower )
42−import Data.Monoid ( Any(..) )
43−import Text.Pandoc.Highlighting ( languages, languagesByExtension )
44−import Text.Pandoc.Pretty
45−import Text.Pandoc.ImageSize
46−import qualified Text.Pandoc.Builder as B
50+import Text.Pandoc.Writers.Shared
51+import Text.Pandoc.XML
4752import Text.TeXMath
4853import qualified Text.XML.Light as Xml
49−import Data.Generics (everywhere, mkT)
50−import Text.Pandoc.Class (PandocMonad, report)
51−import Text.Pandoc.Logging
52−import Control.Monad.Reader
5354
5455data DocBookVersion = DocBook4 | DocBook5
5556 deriving (Eq, Show)
@@ -122,8 +123,8 @@ writeDocbook opts (Pandoc meta blocks) = do
122123 _ -> False)
123124 $ metadata
124125 return $ case writerTemplate opts of
125− Nothing -> main
126− Just tpl -> renderTemplate' tpl context
126+ Nothing -> main
127+ Just tpl -> renderTemplate' tpl context
127128
128129-- | Convert an Element to Docbook.
129130elementToDocbook :: PandocMonad m => WriterOptions -> Int -> Element -> DB m Doc
@@ -311,16 +312,16 @@ hasLineBreaks = getAny . query isLineBreak . walk removeNote
311312 where
312313 removeNote :: Inline -> Inline
313314 removeNote (Note _) = Str ""
314− removeNote x = x
315+ removeNote x = x
315316 isLineBreak :: Inline -> Any
316317 isLineBreak LineBreak = Any True
317− isLineBreak _ = Any False
318+ isLineBreak _ = Any False
318319
319320alignmentToString :: Alignment -> [Char]
320321alignmentToString alignment = case alignment of
321− AlignLeft -> "left"
322− AlignRight -> "right"
323− AlignCenter -> "center"
322+ AlignLeft -> "left"
323+ AlignRight -> "right"
324+ AlignCenter -> "center"
324325 AlignDefault -> "left"
325326
326327tableRowToDocbook :: PandocMonad m
src/Text/Pandoc/Writers/Docx.hs+74−71
@@ -1,5 +1,8 @@
1−{-# LANGUAGE ScopedTypeVariables, PatternGuards, ViewPatterns, DeriveFunctor,
2− ScopedTypeVariables, RankNTypes #-}
1+{-# LANGUAGE DeriveFunctor #-}
2+{-# LANGUAGE PatternGuards #-}
3+{-# LANGUAGE RankNTypes #-}
4+{-# LANGUAGE ScopedTypeVariables #-}
5+{-# LANGUAGE ViewPatterns #-}
36{-
47Copyright (C) 2012-2015 John MacFarlane <jgm@berkeley.edu>
58
@@ -30,45 +33,45 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3033Conversion of 'Pandoc' documents to docx.
3134-}
3235module Text.Pandoc.Writers.Docx ( writeDocx ) where
33−import Data.List ( intercalate, isPrefixOf, isSuffixOf )
36+import Codec.Archive.Zip
37+import Control.Applicative ((<|>))
38+import Control.Monad.Except (catchError)
39+import Control.Monad.Reader
40+import Control.Monad.State
3441import qualified Data.ByteString as B
3542import qualified Data.ByteString.Lazy as BL
3643import qualified Data.ByteString.Lazy.Char8 as BL8
44+import Data.Char (isSpace, ord, toLower)
45+import Data.List (intercalate, isPrefixOf, isSuffixOf)
3746import qualified Data.Map as M
47+import Data.Maybe (fromMaybe, isNothing, mapMaybe, maybeToList)
48+import Data.Monoid ((<>))
3849import qualified Data.Set as Set
39−import qualified Text.Pandoc.UTF8 as UTF8
40−import Codec.Archive.Zip
50+import qualified Data.Text as T
4151import Data.Time.Clock.POSIX
52+import Skylighting
53+import System.Random (randomR)
54+import Text.Pandoc.Class (PandocMonad, report)
55+import qualified Text.Pandoc.Class as P
4256import Text.Pandoc.Compat.Time
4357import Text.Pandoc.Definition
58+import Text.Pandoc.Error
4459import Text.Pandoc.Generic
60+import Text.Pandoc.Highlighting (highlight)
4561import Text.Pandoc.ImageSize
46−import Text.Pandoc.Shared hiding (Element)
47−import Text.Pandoc.Writers.Shared (fixDisplayMath)
62+import Text.Pandoc.Logging
63+import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType,
64+ getMimeTypeDef)
4865import Text.Pandoc.Options
49−import Text.Pandoc.Writers.Math
50−import Text.Pandoc.Highlighting ( highlight )
51−import Text.Pandoc.Walk
52−import Text.XML.Light as XML
53−import Text.TeXMath
5466import Text.Pandoc.Readers.Docx.StyleMap
55−import Control.Monad.Reader
56−import Control.Monad.State
57−import Skylighting
58−import Control.Monad.Except (catchError)
59−import System.Random (randomR)
67+import Text.Pandoc.Shared hiding (Element)
68+import qualified Text.Pandoc.UTF8 as UTF8
69+import Text.Pandoc.Walk
70+import Text.Pandoc.Writers.Math
71+import Text.Pandoc.Writers.Shared (fixDisplayMath)
6072import Text.Printf (printf)
61−import Data.Monoid ((<>))
62−import qualified Data.Text as T
63−import Text.Pandoc.MIME (MimeType, getMimeType, getMimeTypeDef,
64− extensionFromMimeType)
65−import Control.Applicative ((<|>))
66−import Data.Maybe (fromMaybe, mapMaybe, maybeToList, isNothing)
67−import Data.Char (ord, isSpace, toLower)
68−import Text.Pandoc.Class (PandocMonad, report)
69−import qualified Text.Pandoc.Class as P
70−import Text.Pandoc.Logging
71−import Text.Pandoc.Error
73+import Text.TeXMath
74+import Text.XML.Light as XML
7275
7376data ListMarker = NoMarker
7477 | BulletMarker
@@ -81,28 +84,28 @@ listMarkerToId BulletMarker = "991"
8184listMarkerToId (NumberMarker sty delim n) =
8285 '9' : '9' : styNum : delimNum : show n
8386 where styNum = case sty of
84− DefaultStyle -> '2'
85− Example -> '3'
86− Decimal -> '4'
87− LowerRoman -> '5'
88− UpperRoman -> '6'
89− LowerAlpha -> '7'
90− UpperAlpha -> '8'
87+ DefaultStyle -> '2'
88+ Example -> '3'
89+ Decimal -> '4'
90+ LowerRoman -> '5'
91+ UpperRoman -> '6'
92+ LowerAlpha -> '7'
93+ UpperAlpha -> '8'
9194 delimNum = case delim of
92− DefaultDelim -> '0'
93− Period -> '1'
94− OneParen -> '2'
95− TwoParens -> '3'
95+ DefaultDelim -> '0'
96+ Period -> '1'
97+ OneParen -> '2'
98+ TwoParens -> '3'
9699
97100data WriterEnv = WriterEnv{ envTextProperties :: [Element]
98101 , envParaProperties :: [Element]
99− , envRTL :: Bool
100− , envListLevel :: Int
101− , envListNumId :: Int
102− , envInDel :: Bool
103− , envChangesAuthor :: String
104− , envChangesDate :: String
105− , envPrintWidth :: Integer
102+ , envRTL :: Bool
103+ , envListLevel :: Int
104+ , envListNumId :: Int
105+ , envInDel :: Bool
106+ , envChangesAuthor :: String
107+ , envChangesDate :: String
108+ , envPrintWidth :: Integer
106109 }
107110
108111defaultWriterEnv :: WriterEnv
@@ -209,11 +212,11 @@ isValidChar (ord -> c)
209212 | otherwise = False
210213
211214metaValueToInlines :: MetaValue -> [Inline]
212−metaValueToInlines (MetaString s) = [Str s]
215+metaValueToInlines (MetaString s) = [Str s]
213216metaValueToInlines (MetaInlines ils) = ils
214−metaValueToInlines (MetaBlocks bs) = query return bs
215−metaValueToInlines (MetaBool b) = [Str $ show b]
216−metaValueToInlines _ = []
217+metaValueToInlines (MetaBlocks bs) = query return bs
218+metaValueToInlines (MetaBool b) = [Str $ show b]
219+metaValueToInlines _ = []
217220
218221
219222
@@ -452,8 +455,8 @@ writeDocx opts doc@(Pandoc meta _) = do
452455 let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
453456 map newTextPropToOpenXml newDynamicTextProps ++
454457 (case writerHighlightStyle opts of
455− Nothing -> []
456− Just sty -> (styleToOpenXml styleMaps sty))
458+ Nothing -> []
459+ Just sty -> (styleToOpenXml styleMaps sty))
457460 let styledoc' = styledoc{ elContent = elContent styledoc ++
458461 map Elem newstyles }
459462 let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
@@ -675,21 +678,21 @@ mkLvl marker lvl =
675678 bulletFor 4 = "\x2022"
676679 bulletFor 5 = "\x2013"
677680 bulletFor _ = "\x2022"
678− styleFor UpperAlpha _ = "upperLetter"
679− styleFor LowerAlpha _ = "lowerLetter"
680− styleFor UpperRoman _ = "upperRoman"
681− styleFor LowerRoman _ = "lowerRoman"
682− styleFor Decimal _ = "decimal"
681+ styleFor UpperAlpha _ = "upperLetter"
682+ styleFor LowerAlpha _ = "lowerLetter"
683+ styleFor UpperRoman _ = "upperRoman"
684+ styleFor LowerRoman _ = "lowerRoman"
685+ styleFor Decimal _ = "decimal"
683686 styleFor DefaultStyle 1 = "decimal"
684687 styleFor DefaultStyle 2 = "lowerLetter"
685688 styleFor DefaultStyle 3 = "lowerRoman"
686689 styleFor DefaultStyle 4 = "decimal"
687690 styleFor DefaultStyle 5 = "lowerLetter"
688691 styleFor DefaultStyle 6 = "lowerRoman"
689− styleFor _ _ = "decimal"
690− patternFor OneParen s = s ++ ")"
692+ styleFor _ _ = "decimal"
693+ patternFor OneParen s = s ++ ")"
691694 patternFor TwoParens s = "(" ++ s ++ ")"
692− patternFor _ s = s ++ "."
695+ patternFor _ s = s ++ "."
693696
694697getNumId :: (PandocMonad m) => WS m Int
695698getNumId = (((baseListId - 1) +) . length) `fmap` gets stLists
@@ -733,14 +736,14 @@ writeOpenXML opts (Pandoc meta blocks) = do
733736 let auths = docAuthors meta
734737 let dat = docDate meta
735738 let abstract' = case lookupMeta "abstract" meta of
736− Just (MetaBlocks bs) -> bs
739+ Just (MetaBlocks bs) -> bs
737740 Just (MetaInlines ils) -> [Plain ils]
738− _ -> []
741+ _ -> []
739742 let subtitle' = case lookupMeta "subtitle" meta of
740743 Just (MetaBlocks [Plain xs]) -> xs
741744 Just (MetaBlocks [Para xs]) -> xs
742745 Just (MetaInlines xs) -> xs
743− _ -> []
746+ _ -> []
744747 title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]
745748 subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]
746749 authors <- withParaProp (pCustomStyle "Author") $ blocksToOpenXML opts $
@@ -750,8 +753,8 @@ writeOpenXML opts (Pandoc meta blocks) = do
750753 then return []
751754 else withParaProp (pCustomStyle "Abstract") $ blocksToOpenXML opts abstract'
752755 let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs
753− convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
754− convertSpace xs = xs
756+ convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
757+ convertSpace xs = xs
755758 let blocks' = bottomUp convertSpace blocks
756759 doc' <- (setFirstPara >> blocksToOpenXML opts blocks')
757760 notes' <- reverse `fmap` gets stFootnotes
@@ -981,9 +984,9 @@ listItemToOpenXML opts numid (first:rest) = do
981984
982985alignmentToString :: Alignment -> [Char]
983986alignmentToString alignment = case alignment of
984− AlignLeft -> "left"
985− AlignRight -> "right"
986− AlignCenter -> "center"
987+ AlignLeft -> "left"
988+ AlignRight -> "right"
989+ AlignCenter -> "center"
987990 AlignDefault -> "left"
988991
989992-- | Convert a list of inline elements to OpenXML.
@@ -1063,7 +1066,7 @@ inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
10631066 let dirmod = case lookup "dir" kvs of
10641067 Just "rtl" -> local (\env -> env { envRTL = True })
10651068 Just "ltr" -> local (\env -> env { envRTL = False })
1066− _ -> id
1069+ _ -> id
10671070 let off x = withTextProp (mknode x [("w:val","0")] ())
10681071 let pmod = (if "csl-no-emph" `elem` classes then off "w:i" else id) .
10691072 (if "csl-no-strong" `elem` classes then off "w:b" else id) .
@@ -1154,8 +1157,8 @@ inlineToOpenXML' opts (Code attrs str) = do
11541157 , mknode "w:t" [("xml:space","preserve")] (T.unpack tok) ]
11551158 withTextProp (rCustomStyle "VerbatimChar")
11561159 $ case writerHighlightStyle opts >> highlight formatOpenXML attrs str of
1157− Just h -> return h
1158− Nothing -> unhighlighted
1160+ Just h -> return h
1161+ Nothing -> unhighlighted
11591162inlineToOpenXML' opts (Note bs) = do
11601163 notes <- gets stFootnotes
11611164 notenum <- (lift . lift) getUniqueId
src/Text/Pandoc/Writers/DokuWiki.hs+27−30
@@ -39,31 +39,28 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
3939-}
4040
4141module Text.Pandoc.Writers.DokuWiki ( writeDokuWiki ) where
42+import Control.Monad (zipWithM)
43+import Control.Monad.Reader (ReaderT, ask, local, runReaderT)
44+import Control.Monad.State (State, evalState, gets, modify)
45+import Data.Default (Default (..))
46+import Data.List (intercalate, intersect, isPrefixOf, transpose)
47+import Network.URI (isURI)
48+import Text.Pandoc.Class (PandocMonad)
4249import Text.Pandoc.Definition
43−import Text.Pandoc.Options ( WriterOptions(
44− writerTableOfContents
45− , writerTemplate
46− , writerWrapText), WrapOption(..) )
47−import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting
48− , camelCaseToHyphenated, trimr, substitute )
49−import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
5050import Text.Pandoc.ImageSize
51−import Text.Pandoc.Templates ( renderTemplate' )
52−import Data.List ( intersect, intercalate, isPrefixOf, transpose )
53−import Data.Default (Default(..))
54−import Network.URI ( isURI )
55−import Control.Monad ( zipWithM )
56−import Control.Monad.State ( modify, State, gets, evalState )
57−import Control.Monad.Reader ( ReaderT, runReaderT, ask, local )
58−import Text.Pandoc.Class (PandocMonad)
51+import Text.Pandoc.Options (WrapOption (..), WriterOptions (writerTableOfContents, writerTemplate, writerWrapText))
52+import Text.Pandoc.Shared (camelCaseToHyphenated, escapeURI, linesToPara,
53+ removeFormatting, substitute, trimr)
54+import Text.Pandoc.Templates (renderTemplate')
55+import Text.Pandoc.Writers.Shared (defField, metaToJSON)
5956
6057data WriterState = WriterState {
6158 stNotes :: Bool -- True if there are notes
6259 }
6360
6461data WriterEnvironment = WriterEnvironment {
65− stIndent :: String -- Indent after the marker at the beginning of list items
66− , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
62+ stIndent :: String -- Indent after the marker at the beginning of list items
63+ , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
6764 , stBackSlashLB :: Bool -- True if we should produce formatted strings with newlines (as in a table cell)
6865 }
6966
@@ -178,7 +175,7 @@ blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do
178175 "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
179176 return $ "<code" ++
180177 (case at of
181− [] -> ">\n"
178+ [] -> ">\n"
182179 (x:_) -> " " ++ x ++ ">\n") ++ str ++ "\n</code>"
183180
184181blockToDokuWiki opts (BlockQuote blocks) = do
@@ -338,18 +335,18 @@ isSimpleListItem :: [Block] -> Bool
338335isSimpleListItem [] = True
339336isSimpleListItem [x] =
340337 case x of
341− Plain _ -> True
342− Para _ -> True
343− BulletList _ -> isSimpleList x
344− OrderedList _ _ -> isSimpleList x
345− DefinitionList _ -> isSimpleList x
346− _ -> False
338+ Plain _ -> True
339+ Para _ -> True
340+ BulletList _ -> isSimpleList x
341+ OrderedList _ _ -> isSimpleList x
342+ DefinitionList _ -> isSimpleList x
343+ _ -> False
347344isSimpleListItem [x, y] | isPlainOrPara x =
348345 case y of
349− BulletList _ -> isSimpleList y
350− OrderedList _ _ -> isSimpleList y
351− DefinitionList _ -> isSimpleList y
352− _ -> False
346+ BulletList _ -> isSimpleList y
347+ OrderedList _ _ -> isSimpleList y
348+ DefinitionList _ -> isSimpleList y
349+ _ -> False
353350isSimpleListItem _ = False
354351
355352isPlainOrPara :: Block -> Bool
@@ -369,7 +366,7 @@ backSlashLineBreaks cs = reverse $ g $ reverse $ concatMap f cs
369366 where f '\n' = "\\\\ "
370367 f c = [c]
371368 g (' ' : '\\':'\\': xs) = xs
372− g s = s
369+ g s = s
373370
374371-- Auxiliary functions for tables:
375372
@@ -515,7 +512,7 @@ imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height
515512 where
516513 toPx = fmap (showInPixel opts) . checkPct
517514 checkPct (Just (Percent _)) = Nothing
518− checkPct maybeDim = maybeDim
515+ checkPct maybeDim = maybeDim
519516 go (Just w) Nothing = "?" ++ w
520517 go (Just w) (Just h) = "?" ++ w ++ "x" ++ h
521518 go Nothing (Just h) = "?0x" ++ h
src/Text/Pandoc/Writers/EPUB.hs+95−93
@@ -1,4 +1,7 @@
1−{-# LANGUAGE PatternGuards, CPP, ScopedTypeVariables, ViewPatterns, FlexibleContexts #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE PatternGuards #-}
4+{-# LANGUAGE ScopedTypeVariables #-}
25{-
36Copyright (C) 2010-2015 John MacFarlane <jgm@berkeley.edu>
47
@@ -29,45 +32,44 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2932Conversion of 'Pandoc' documents to EPUB.
3033-}
3134module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where
32−import Text.Pandoc.Logging
33−import qualified Data.Map as M
34−import qualified Data.Set as Set
35−import Data.Maybe ( fromMaybe, catMaybes )
36−import Data.List ( isPrefixOf, isInfixOf, intercalate )
37−import Text.Printf (printf)
38−import System.FilePath ( takeExtension, takeFileName )
39−import Network.HTTP ( urlEncode )
35+import Codec.Archive.Zip (Entry, addEntryToArchive, eRelativePath, emptyArchive,
36+ fromArchive, fromEntry, toEntry)
37+import Control.Monad (mplus, when, zipWithM)
38+import Control.Monad.Except (catchError, throwError)
39+import Control.Monad.State (State, StateT, evalState, evalStateT, get, gets,
40+ lift, modify, put)
4041import qualified Data.ByteString.Lazy as B
4142import qualified Data.ByteString.Lazy.Char8 as B8
42−import qualified Text.Pandoc.UTF8 as UTF8
43−import Codec.Archive.Zip ( emptyArchive, addEntryToArchive, eRelativePath, fromEntry , Entry, toEntry, fromArchive)
44−import Text.Pandoc.Compat.Time
45−import Text.Pandoc.Shared ( renderTags', safeRead, uniqueIdent, trim
46− , normalizeDate, stringify
47− , hierarchicalize )
48−import qualified Text.Pandoc.Shared as S (Element(..))
43+import Data.Char (isAlphaNum, isDigit, toLower)
44+import Data.List (intercalate, isInfixOf, isPrefixOf)
45+import qualified Data.Map as M
46+import Data.Maybe (catMaybes, fromMaybe)
47+import qualified Data.Set as Set
48+import Network.HTTP (urlEncode)
49+import System.FilePath (takeExtension, takeFileName)
50+import Text.HTML.TagSoup (Tag (TagOpen), fromAttrib, parseTags)
4951import Text.Pandoc.Builder (fromList, setMeta)
50−import Text.Pandoc.Options ( WriterOptions(..)
51− , WrapOption(..)
52− , HTMLMathMethod(..)
53− , EPUBVersion(..)
54− , ObfuscationMethod(NoObfuscation) )
55−import Text.Pandoc.Definition
56−import Text.Pandoc.Walk (walk, walkM, query)
57−import Text.Pandoc.UUID (getUUID)
58−import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
59−import Control.Monad (mplus, when, zipWithM)
60−import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
61− , strContent, lookupAttr, Node(..), QName(..), parseXML
62− , onlyElems, node, ppElement)
63−import Text.Pandoc.Writers.HTML ( writeHtmlStringForEPUB )
64−import Data.Char ( toLower, isDigit, isAlphaNum )
65−import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
66−import Text.HTML.TagSoup (Tag(TagOpen), fromAttrib, parseTags)
67−import Control.Monad.Except (throwError, catchError)
68−import Text.Pandoc.Error
6952import Text.Pandoc.Class (PandocMonad, report)
7053import qualified Text.Pandoc.Class as P
54+import Text.Pandoc.Compat.Time
55+import Text.Pandoc.Definition
56+import Text.Pandoc.Error
57+import Text.Pandoc.Logging
58+import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType)
59+import Text.Pandoc.Options (EPUBVersion (..), HTMLMathMethod (..),
60+ ObfuscationMethod (NoObfuscation), WrapOption (..),
61+ WriterOptions (..))
62+import Text.Pandoc.Shared (hierarchicalize, normalizeDate, renderTags',
63+ safeRead, stringify, trim, uniqueIdent)
64+import qualified Text.Pandoc.Shared as S (Element (..))
65+import qualified Text.Pandoc.UTF8 as UTF8
66+import Text.Pandoc.UUID (getUUID)
67+import Text.Pandoc.Walk (query, walk, walkM)
68+import Text.Pandoc.Writers.HTML (writeHtmlStringForEPUB)
69+import Text.Printf (printf)
70+import Text.XML.Light (Attr (..), Element (..), Node (..), QName (..),
71+ add_attrs, lookupAttr, node, onlyElems, parseXML,
72+ ppElement, strContent, unode, unqual)
7173
7274-- A Chapter includes a list of blocks and maybe a section
7375-- number offset. Note, some chapters are unnumbered. The section
@@ -82,46 +84,46 @@ data EPUBState = EPUBState {
8284type E m = StateT EPUBState m
8385
8486data EPUBMetadata = EPUBMetadata{
85− epubIdentifier :: [Identifier]
86− , epubTitle :: [Title]
87− , epubDate :: [Date]
88− , epubLanguage :: String
89− , epubCreator :: [Creator]
90− , epubContributor :: [Creator]
91− , epubSubject :: [String]
92− , epubDescription :: Maybe String
93− , epubType :: Maybe String
94− , epubFormat :: Maybe String
95− , epubPublisher :: Maybe String
96− , epubSource :: Maybe String
97− , epubRelation :: Maybe String
98− , epubCoverage :: Maybe String
99− , epubRights :: Maybe String
100− , epubCoverImage :: Maybe String
101− , epubStylesheets :: [FilePath]
102− , epubPageDirection :: Maybe ProgressionDirection
87+ epubIdentifier :: [Identifier]
88+ , epubTitle :: [Title]
89+ , epubDate :: [Date]
90+ , epubLanguage :: String
91+ , epubCreator :: [Creator]
92+ , epubContributor :: [Creator]
93+ , epubSubject :: [String]
94+ , epubDescription :: Maybe String
95+ , epubType :: Maybe String
96+ , epubFormat :: Maybe String
97+ , epubPublisher :: Maybe String
98+ , epubSource :: Maybe String
99+ , epubRelation :: Maybe String
100+ , epubCoverage :: Maybe String
101+ , epubRights :: Maybe String
102+ , epubCoverImage :: Maybe String
103+ , epubStylesheets :: [FilePath]
104+ , epubPageDirection :: Maybe ProgressionDirection
103105 } deriving Show
104106
105107data Date = Date{
106− dateText :: String
107− , dateEvent :: Maybe String
108+ dateText :: String
109+ , dateEvent :: Maybe String
108110 } deriving Show
109111
110112data Creator = Creator{
111− creatorText :: String
112− , creatorRole :: Maybe String
113− , creatorFileAs :: Maybe String
113+ creatorText :: String
114+ , creatorRole :: Maybe String
115+ , creatorFileAs :: Maybe String
114116 } deriving Show
115117
116118data Identifier = Identifier{
117− identifierText :: String
118− , identifierScheme :: Maybe String
119+ identifierText :: String
120+ , identifierScheme :: Maybe String
119121 } deriving Show
120122
121123data Title = Title{
122− titleText :: String
123− , titleFileAs :: Maybe String
124− , titleType :: Maybe String
124+ titleText :: String
125+ , titleFileAs :: Maybe String
126+ , titleType :: Maybe String
125127 } deriving Show
126128
127129data ProgressionDirection = LTR | RTL deriving Show
@@ -229,16 +231,16 @@ addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md
229231addMetadataFromXML _ md = md
230232
231233metaValueToString :: MetaValue -> String
232−metaValueToString (MetaString s) = s
234+metaValueToString (MetaString s) = s
233235metaValueToString (MetaInlines ils) = stringify ils
234−metaValueToString (MetaBlocks bs) = stringify bs
235−metaValueToString (MetaBool True) = "true"
236−metaValueToString (MetaBool False) = "false"
237−metaValueToString _ = ""
236+metaValueToString (MetaBlocks bs) = stringify bs
237+metaValueToString (MetaBool True) = "true"
238+metaValueToString (MetaBool False) = "false"
239+metaValueToString _ = ""
238240
239241metaValueToPaths:: MetaValue -> [FilePath]
240242metaValueToPaths (MetaList xs) = map metaValueToString xs
241−metaValueToPaths x = [metaValueToString x]
243+metaValueToPaths x = [metaValueToString x]
242244
243245getList :: String -> Meta -> (MetaValue -> a) -> [a]
244246getList s meta handleMetaValue =
@@ -286,8 +288,8 @@ simpleList :: String -> Meta -> [String]
286288simpleList s meta =
287289 case lookupMeta s meta of
288290 Just (MetaList xs) -> map metaValueToString xs
289− Just x -> [metaValueToString x]
290− Nothing -> []
291+ Just x -> [metaValueToString x]
292+ Nothing -> []
291293
292294metadataFromMeta :: WriterOptions -> Meta -> EPUBMetadata
293295metadataFromMeta opts meta = EPUBMetadata{
@@ -538,8 +540,8 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
538540 ("href", eRelativePath ent),
539541 ("media-type", "application/xhtml+xml")]
540542 ++ case props ent of
541− [] -> []
542− xs -> [("properties", unwords xs)])
543+ [] -> []
544+ xs -> [("properties", unwords xs)])
543545 $ ()
544546 let chapterRefNode ent = unode "itemref" !
545547 [("idref", toId $ eRelativePath ent)] $ ()
@@ -554,7 +556,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
554556 ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
555557 let plainTitle = case docTitle' meta of
556558 [] -> case epubTitle metadata of
557− [] -> "UNTITLED"
559+ [] -> "UNTITLED"
558560 (x:_) -> titleText x
559561 x -> stringify x
560562
@@ -635,7 +637,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
635637 Just x -> return x
636638 Nothing -> throwError $ PandocSomeError $ ident ++ " not found in reftable"
637639 let isSec (S.Sec lev _ _ _ _) = lev <= tocLevel
638− isSec _ = False
640+ isSec _ = False
639641 let subsecs = filter isSec children
640642 subs <- mapM (navPointNode formatter) subsecs
641643 return $ formatter n tit src subs
@@ -830,22 +832,22 @@ metadataElement version md currentTime =
830832 (("id",id') :
831833 maybe [] (\x -> [("opf:event",x)]) (dateEvent date)) $
832834 dateText date]
833− schemeToOnix "ISBN-10" = "02"
834− schemeToOnix "GTIN-13" = "03"
835− schemeToOnix "UPC" = "04"
836− schemeToOnix "ISMN-10" = "05"
837− schemeToOnix "DOI" = "06"
838− schemeToOnix "LCCN" = "13"
839− schemeToOnix "GTIN-14" = "14"
840− schemeToOnix "ISBN-13" = "15"
835+ schemeToOnix "ISBN-10" = "02"
836+ schemeToOnix "GTIN-13" = "03"
837+ schemeToOnix "UPC" = "04"
838+ schemeToOnix "ISMN-10" = "05"
839+ schemeToOnix "DOI" = "06"
840+ schemeToOnix "LCCN" = "13"
841+ schemeToOnix "GTIN-14" = "14"
842+ schemeToOnix "ISBN-13" = "15"
841843 schemeToOnix "Legal deposit number" = "17"
842− schemeToOnix "URN" = "22"
843− schemeToOnix "OCLC" = "23"
844− schemeToOnix "ISMN-13" = "25"
845− schemeToOnix "ISBN-A" = "26"
846− schemeToOnix "JP" = "27"
847− schemeToOnix "OLCC" = "28"
848− schemeToOnix _ = "01"
844+ schemeToOnix "URN" = "22"
845+ schemeToOnix "OCLC" = "23"
846+ schemeToOnix "ISMN-13" = "25"
847+ schemeToOnix "ISBN-A" = "26"
848+ schemeToOnix "JP" = "27"
849+ schemeToOnix "OLCC" = "28"
850+ schemeToOnix _ = "01"
849851
850852showDateTimeISO8601 :: UTCTime -> String
851853showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ"
@@ -936,8 +938,8 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity .
936938 let (ds,ys) = break (==';') xs
937939 rest = drop 1 ys
938940 in case safeRead ('\'':'\\':ds ++ "'") of
939− Just x -> x : unEntity rest
940− Nothing -> '&':'#':unEntity xs
941+ Just x -> x : unEntity rest
942+ Nothing -> '&':'#':unEntity xs
941943 unEntity (x:xs) = x : unEntity xs
942944
943945mediaTypeOf :: FilePath -> Maybe MimeType
@@ -945,7 +947,7 @@ mediaTypeOf x =
945947 let mediaPrefixes = ["image", "video", "audio"] in
946948 case getMimeType x of
947949 Just y | any (`isPrefixOf` y) mediaPrefixes -> Just y
948− _ -> Nothing
950+ _ -> Nothing
949951
950952-- Returns filename for chapter number.
951953showChapter :: Int -> String
src/Text/Pandoc/Writers/FB2.hs+43−43
@@ -27,37 +27,37 @@ FictionBook is an XML-based e-book format. For more information see:
2727-}
2828module Text.Pandoc.Writers.FB2 (writeFB2) where
2929
30−import Control.Monad.State (StateT, evalStateT, get, modify, lift)
30+import Control.Monad.Except (catchError, throwError)
31+import Control.Monad.State (StateT, evalStateT, get, lift, modify)
3132import Control.Monad.State (liftM)
3233import Data.ByteString.Base64 (encode)
33−import Data.Char (toLower, isSpace, isAscii, isControl)
34−import Data.List (intersperse, intercalate, isPrefixOf, stripPrefix)
34+import qualified Data.ByteString.Char8 as B8
35+import Data.Char (isAscii, isControl, isSpace, toLower)
3536import Data.Either (lefts, rights)
37+import Data.List (intercalate, intersperse, isPrefixOf, stripPrefix)
3638import Network.HTTP (urlEncode)
3739import Network.URI (isURI)
3840import Text.XML.Light
3941import qualified Text.XML.Light as X
4042import qualified Text.XML.Light.Cursor as XC
41−import qualified Data.ByteString.Char8 as B8
42−import Control.Monad.Except (throwError, catchError)
4343
44−import Text.Pandoc.Logging
45−import Text.Pandoc.Definition
46−import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
47−import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,
48− linesToPara)
49−import Text.Pandoc.Error
5044import Text.Pandoc.Class (PandocMonad, report)
5145import qualified Text.Pandoc.Class as P
46+import Text.Pandoc.Definition
47+import Text.Pandoc.Error
48+import Text.Pandoc.Logging
49+import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..), def)
50+import Text.Pandoc.Shared (capitalize, isHeaderBlock, linesToPara,
51+ orderedListMarkers)
5252
5353-- | Data to be written at the end of the document:
5454-- (foot)notes, URLs, references, images.
5555data FbRenderState = FbRenderState
56− { footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text
57− , imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path
58− , parentListMarker :: String -- ^ list marker of the parent ordered list
56+ { footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text
57+ , imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path
58+ , parentListMarker :: String -- ^ list marker of the parent ordered list
5959 , parentBulletLevel :: Int -- ^ nesting level of the unordered list
60− , writerOptions :: WriterOptions
60+ , writerOptions :: WriterOptions
6161 } deriving (Show)
6262
6363-- | FictionBook building monad.
@@ -188,7 +188,7 @@ split cond xs = let (b,a) = break cond xs
188188
189189isLineBreak :: Inline -> Bool
190190isLineBreak LineBreak = True
191−isLineBreak _ = False
191+isLineBreak _ = False
192192
193193-- | Divide the stream of block elements into sections: [(title, blocks)].
194194splitSections :: Int -> [Block] -> [([Inline], [Block])]
@@ -206,7 +206,7 @@ splitSections level blocks = reverse $ revSplit (reverse blocks)
206206 _ -> ([], before)
207207 in (header, reverse lastsec) : revSplit prevblocks
208208 sameLevel (Header n _ _) = n == level
209− sameLevel _ = False
209+ sameLevel _ = False
210210
211211-- | Make another FictionBook body with footnotes.
212212renderFootnotes :: PandocMonad m => FBM m [Content]
@@ -353,9 +353,9 @@ blockToXml (DefinitionList defs) =
353353 blocks ++ [Plain [LineBreak]]
354354 else
355355 blocks
356− needsBreak (Para _) = False
356+ needsBreak (Para _) = False
357357 needsBreak (Plain ins) = LineBreak `notElem` ins
358− needsBreak _ = True
358+ needsBreak _ = True
359359blockToXml (Header _ _ _) = -- should never happen, see renderSections
360360 throwError $ PandocShouldNeverHappenError "unexpected header in section text"
361361blockToXml HorizontalRule = return
@@ -378,9 +378,9 @@ blockToXml (Table caption aligns _ headers rows) = do
378378 return $ el tag ([align_attr align], cblocks)
379379 --
380380 align_attr a = Attr (QName "align" Nothing Nothing) (align_str a)
381− align_str AlignLeft = "left"
382− align_str AlignCenter = "center"
383− align_str AlignRight = "right"
381+ align_str AlignLeft = "left"
382+ align_str AlignCenter = "center"
383+ align_str AlignRight = "right"
384384 align_str AlignDefault = "left"
385385blockToXml Null = return []
386386
@@ -488,7 +488,7 @@ insertImage immode (Image _ alt (url,ttl)) = do
488488 modify (\s -> s { imagesToFetch = (fname, url) : images })
489489 let ttlattr = case (immode, null ttl) of
490490 (NormalImage, False) -> [ uattr "title" ttl ]
491− _ -> []
491+ _ -> []
492492 return . list $
493493 el "image" $
494494 [ attr ("l","href") ('#':fname)
@@ -512,11 +512,11 @@ replaceImagesWithAlt missingHrefs body =
512512 else c
513513 in case XC.nextDF c' of
514514 (Just cnext) -> replaceAll cnext
515− Nothing -> c' -- end of document
515+ Nothing -> c' -- end of document
516516 --
517517 isImage :: Content -> Bool
518518 isImage (Elem e) = (elName e) == (uname "image")
519− isImage _ = False
519+ isImage _ = False
520520 --
521521 isMissing (Elem img@(Element _ _ _ _)) =
522522 let imgAttrs = elAttribs img
@@ -555,25 +555,25 @@ list = (:[])
555555
556556-- | Convert an 'Inline' to plaintext.
557557plain :: Inline -> String
558−plain (Str s) = s
559−plain (Emph ss) = concat (map plain ss)
560−plain (Span _ ss) = concat (map plain ss)
561−plain (Strong ss) = concat (map plain ss)
562−plain (Strikeout ss) = concat (map plain ss)
563−plain (Superscript ss) = concat (map plain ss)
564−plain (Subscript ss) = concat (map plain ss)
565−plain (SmallCaps ss) = concat (map plain ss)
566−plain (Quoted _ ss) = concat (map plain ss)
567−plain (Cite _ ss) = concat (map plain ss) -- FIXME
568−plain (Code _ s) = s
569−plain Space = " "
570−plain SoftBreak = " "
571−plain LineBreak = "\n"
572−plain (Math _ s) = s
573−plain (RawInline _ _) = ""
558+plain (Str s) = s
559+plain (Emph ss) = concat (map plain ss)
560+plain (Span _ ss) = concat (map plain ss)
561+plain (Strong ss) = concat (map plain ss)
562+plain (Strikeout ss) = concat (map plain ss)
563+plain (Superscript ss) = concat (map plain ss)
564+plain (Subscript ss) = concat (map plain ss)
565+plain (SmallCaps ss) = concat (map plain ss)
566+plain (Quoted _ ss) = concat (map plain ss)
567+plain (Cite _ ss) = concat (map plain ss) -- FIXME
568+plain (Code _ s) = s
569+plain Space = " "
570+plain SoftBreak = " "
571+plain LineBreak = "\n"
572+plain (Math _ s) = s
573+plain (RawInline _ _) = ""
574574plain (Link _ text (url,_)) = concat (map plain text ++ [" <", url, ">"])
575−plain (Image _ alt _) = concat (map plain alt)
576−plain (Note _) = "" -- FIXME
575+plain (Image _ alt _) = concat (map plain alt)
576+plain (Note _) = "" -- FIXME
577577
578578-- | Create an XML element.
579579el :: (Node t)
src/Text/Pandoc/Writers/HTML.hs+53−50
@@ -1,4 +1,7 @@
1−{-# LANGUAGE OverloadedStrings, CPP, ViewPatterns, ScopedTypeVariables #-}
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
4+{-# LANGUAGE ViewPatterns #-}
25{-
36Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
47
@@ -40,61 +43,61 @@ module Text.Pandoc.Writers.HTML (
4043 writeDZSlides,
4144 writeRevealJs
4245 ) where
43−import Text.Pandoc.Definition
44−import Text.Pandoc.Walk
46+import Control.Monad.State
47+import Data.Char (ord, toLower)
48+import Data.List (intersperse, isPrefixOf)
49+import Data.Maybe (catMaybes, fromMaybe, isJust)
4550import Data.Monoid ((<>))
46−import Text.Pandoc.Shared
47−import Text.Pandoc.Writers.Shared
48−import Text.Pandoc.Options
51+import Data.String (fromString)
52+import Network.HTTP (urlEncode)
53+import Network.URI (URI (..), parseURIReference, unEscapeString)
54+import Numeric (showHex)
55+import Text.Blaze.Html hiding (contents)
56+import Text.Pandoc.Definition
57+import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtmlInline, highlight,
58+ styleToCss)
4959import Text.Pandoc.ImageSize
60+import Text.Pandoc.Options
61+import Text.Pandoc.Shared
62+import Text.Pandoc.Slides
5063import Text.Pandoc.Templates
64+import Text.Pandoc.Walk
5165import Text.Pandoc.Writers.Math
52−import Text.Pandoc.Slides
53−import Text.Pandoc.Highlighting ( highlight, styleToCss,
54− formatHtmlInline, formatHtmlBlock )
55−import Text.Pandoc.XML (fromEntities, escapeStringForXML)
56−import Network.URI ( parseURIReference, URI(..), unEscapeString )
57−import Network.HTTP ( urlEncode )
58−import Numeric ( showHex )
59−import Data.Char ( ord, toLower )
60−import Data.List ( isPrefixOf, intersperse )
61−import Data.String ( fromString )
62−import Data.Maybe ( catMaybes, fromMaybe, isJust )
63−import Control.Monad.State
64−import Text.Blaze.Html hiding(contents)
66+import Text.Pandoc.Writers.Shared
67+import Text.Pandoc.XML (escapeStringForXML, fromEntities)
6568#if MIN_VERSION_blaze_markup(0,6,3)
6669#else
67−import Text.Blaze.Internal(preEscapedString)
70+import Text.Blaze.Internal (preEscapedString)
6871#endif
6972#if MIN_VERSION_blaze_html(0,5,1)
7073import qualified Text.Blaze.XHtml5 as H5
7174#else
7275import qualified Text.Blaze.Html5 as H5
7376#endif
77+import Control.Monad.Except (throwError)
78+import Data.Aeson (Value)
79+import System.FilePath (takeExtension)
80+import Text.Blaze.Html.Renderer.String (renderHtml)
7481import qualified Text.Blaze.XHtml1.Transitional as H
7582import qualified Text.Blaze.XHtml1.Transitional.Attributes as A
76−import Text.Blaze.Html.Renderer.String (renderHtml)
77−import Text.TeXMath
78−import Text.XML.Light.Output
79−import Text.XML.Light (unode, elChildren, unqual)
80−import qualified Text.XML.Light as XML
81−import System.FilePath (takeExtension)
82−import Data.Aeson (Value)
83−import Control.Monad.Except (throwError)
84−import Text.Pandoc.Error
8583import Text.Pandoc.Class (PandocMonad, report)
84+import Text.Pandoc.Error
8685import Text.Pandoc.Logging
86+import Text.TeXMath
87+import Text.XML.Light (elChildren, unode, unqual)
88+import qualified Text.XML.Light as XML
89+import Text.XML.Light.Output
8790
8891data WriterState = WriterState
89− { stNotes :: [Html] -- ^ List of notes
90− , stMath :: Bool -- ^ Math is used in document
91− , stQuotes :: Bool -- ^ <q> tag is used
92− , stHighlighting :: Bool -- ^ Syntax highlighting is used
93− , stSecNum :: [Int] -- ^ Number of current section
94− , stElement :: Bool -- ^ Processing an Element
95− , stHtml5 :: Bool -- ^ Use HTML5
96− , stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
97− , stSlideVariant :: HTMLSlideVariant
92+ { stNotes :: [Html] -- ^ List of notes
93+ , stMath :: Bool -- ^ Math is used in document
94+ , stQuotes :: Bool -- ^ <q> tag is used
95+ , stHighlighting :: Bool -- ^ Syntax highlighting is used
96+ , stSecNum :: [Int] -- ^ Number of current section
97+ , stElement :: Bool -- ^ Processing an Element
98+ , stHtml5 :: Bool -- ^ Use HTML5
99+ , stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
100+ , stSlideVariant :: HTMLSlideVariant
98101 }
99102
100103defaultWriterState :: WriterState
@@ -290,8 +293,8 @@ pandocToHtml opts (Pandoc meta blocks) = do
290293prefixedId :: WriterOptions -> String -> Attribute
291294prefixedId opts s =
292295 case s of
293− "" -> mempty
294− _ -> A.id $ toValue $ writerIdentifierPrefix opts ++ s
296+ "" -> mempty
297+ _ -> A.id $ toValue $ writerIdentifierPrefix opts ++ s
295298
296299toList :: PandocMonad m
297300 => (Html -> Html)
@@ -387,8 +390,8 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
387390 let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
388391 isPause _ = False
389392 let fragmentClass = case slideVariant of
390− RevealJsSlides -> "fragment"
391− _ -> "incremental"
393+ RevealJsSlides -> "fragment"
394+ _ -> "incremental"
392395 let inDiv xs = Blk (RawBlock (Format "html") ("<div class=\""
393396 ++ fragmentClass ++ "\">")) :
394397 (xs ++ [Blk (RawBlock (Format "html") "</div>")])
@@ -515,7 +518,7 @@ imgAttrsToHtml opts attr =
515518 kvs' = filter isNotDim kvs
516519 isNotDim ("width", _) = False
517520 isNotDim ("height", _) = False
518− isNotDim _ = True
521+ isNotDim _ = True
519522
520523dimensionsToAttrList :: WriterOptions -> Attr -> [(String, String)]
521524dimensionsToAttrList opts attr = (go Width) ++ (go Height)
@@ -581,7 +584,7 @@ blockToHtml opts (Para lst)
581584 return $ H.p contents
582585 where
583586 isEmptyRaw [RawInline f _] = f /= (Format "html")
584− isEmptyRaw _ = False
587+ isEmptyRaw _ = False
585588blockToHtml opts (LineBlock lns) =
586589 if writerWrapText opts == WrapNone
587590 then blockToHtml opts $ linesToPara lns
@@ -767,9 +770,9 @@ tableRowToHtml :: PandocMonad m
767770tableRowToHtml opts aligns rownum cols' = do
768771 let mkcell = if rownum == 0 then H.th else H.td
769772 let rowclass = case rownum of
770− 0 -> "header"
773+ 0 -> "header"
771774 x | x `rem` 2 == 1 -> "odd"
772− _ -> "even"
775+ _ -> "even"
773776 cols'' <- sequence $ zipWith
774777 (\alignment item -> tableItemToHtml opts mkcell alignment item)
775778 aligns cols'
@@ -821,9 +824,9 @@ annotateMML :: XML.Element -> String -> XML.Element
821824annotateMML e tex = math (unode "semantics" [cs, unode "annotation" (annotAttrs, tex)])
822825 where
823826 cs = case elChildren e of
824− [] -> unode "mrow" ()
827+ [] -> unode "mrow" ()
825828 [x] -> x
826− xs -> unode "mrow" xs
829+ xs -> unode "mrow" xs
827830 math childs = XML.Element q as [XML.Elem childs] l
828831 where
829832 (XML.Element q as _ l) = e
@@ -908,7 +911,7 @@ inlineToHtml opts inline = do
908911 JsMath _ -> do
909912 let m = preEscapedString str
910913 return $ case t of
911− InlineMath -> H.span ! A.class_ mathClass $ m
914+ InlineMath -> H.span ! A.class_ mathClass $ m
912915 DisplayMath -> H.div ! A.class_ mathClass $ m
913916 WebTeX url -> do
914917 let imtag = if html5 then H5.img else H.img
@@ -939,7 +942,7 @@ inlineToHtml opts inline = do
939942 DisplayMath -> "\\[" ++ str ++ "\\]"
940943 KaTeX _ _ -> return $ H.span ! A.class_ mathClass $
941944 toHtml (case t of
942− InlineMath -> str
945+ InlineMath -> str
943946 DisplayMath -> "\\displaystyle " ++ str)
944947 PlainMath -> do
945948 x <- lift (texMathToInlines t str) >>= inlineListToHtml opts
src/Text/Pandoc/Writers/Haddock.hs+14−12
@@ -1,4 +1,6 @@
1−{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE TupleSections #-}
24{-
35Copyright (C) 2014 John MacFarlane <jgm@berkeley.edu>
46
@@ -31,19 +33,19 @@ Conversion of 'Pandoc' documents to haddock markup.
3133Haddock: <http://www.haskell.org/haddock/doc/html/>
3234-}
3335module Text.Pandoc.Writers.Haddock (writeHaddock) where
34−import Text.Pandoc.Definition
35−import Text.Pandoc.Templates (renderTemplate')
36−import Text.Pandoc.Shared
37−import Text.Pandoc.Writers.Shared
38−import Text.Pandoc.Options
39−import Data.List ( intersperse, transpose )
40−import Text.Pandoc.Pretty
4136import Control.Monad.State
42−import Text.Pandoc.Writers.Math (texMathToInlines)
43−import Network.URI (isURI)
4437import Data.Default
38+import Data.List (intersperse, transpose)
39+import Network.URI (isURI)
4540import Text.Pandoc.Class (PandocMonad, report)
41+import Text.Pandoc.Definition
4642import Text.Pandoc.Logging
43+import Text.Pandoc.Options
44+import Text.Pandoc.Pretty
45+import Text.Pandoc.Shared
46+import Text.Pandoc.Templates (renderTemplate')
47+import Text.Pandoc.Writers.Math (texMathToInlines)
48+import Text.Pandoc.Writers.Shared
4749
4850type Notes = [[Block]]
4951data WriterState = WriterState { stNotes :: Notes }
@@ -269,7 +271,7 @@ orderedListItemToHaddock opts marker items = do
269271 contents <- blockListToHaddock opts items
270272 let sps = case length marker - writerTabStop opts of
271273 n | n > 0 -> text $ replicate n ' '
272− _ -> text " "
274+ _ -> text " "
273275 let start = text marker <> sps
274276 return $ hang (writerTabStop opts) start $ contents <> cr
275277
@@ -356,7 +358,7 @@ inlineToHaddock _ (Link _ txt (src, _)) = do
356358 let useAuto = isURI src &&
357359 case txt of
358360 [Str s] | escapeURI s == src -> True
359− _ -> False
361+ _ -> False
360362 return $ nowrap $ "<" <> text src <>
361363 (if useAuto then empty else space <> linktext) <> ">"
362364inlineToHaddock opts (Image attr alternate (source, tit)) = do
src/Text/Pandoc/Writers/ICML.hs+25−23
@@ -1,4 +1,6 @@
1−{-# LANGUAGE OverloadedStrings, FlexibleContexts, ScopedTypeVariables #-}
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
24
35{- |
46 Module : Text.Pandoc.Writers.ICML
@@ -14,25 +16,25 @@ InCopy is the companion word-processor to Adobe InDesign and ICML documents can
1416into InDesign with File -> Place.
1517-}
1618module Text.Pandoc.Writers.ICML (writeICML) where
17−import Text.Pandoc.Definition
18−import Text.Pandoc.Error (PandocError(..))
19−import Text.Pandoc.XML
20−import Text.Pandoc.Writers.Math (texMathToInlines)
21−import Text.Pandoc.Writers.Shared
22−import Text.Pandoc.Shared (linesToPara, splitBy)
23−import Text.Pandoc.Options
24−import Text.Pandoc.Templates (renderTemplate')
25−import Text.Pandoc.Pretty
26−import Text.Pandoc.ImageSize
27−import Data.List (isPrefixOf, isInfixOf, stripPrefix, intersperse)
28−import Data.Text as Text (breakOnAll, pack)
29−import Control.Monad.State
3019import Control.Monad.Except (catchError)
31−import Network.URI (isURI)
20+import Control.Monad.State
21+import Data.List (intersperse, isInfixOf, isPrefixOf, stripPrefix)
3222import qualified Data.Set as Set
23+import Data.Text as Text (breakOnAll, pack)
24+import Network.URI (isURI)
3325import Text.Pandoc.Class (PandocMonad, report)
34−import Text.Pandoc.Logging
3526import qualified Text.Pandoc.Class as P
27+import Text.Pandoc.Definition
28+import Text.Pandoc.Error (PandocError (..))
29+import Text.Pandoc.ImageSize
30+import Text.Pandoc.Logging
31+import Text.Pandoc.Options
32+import Text.Pandoc.Pretty
33+import Text.Pandoc.Shared (linesToPara, splitBy)
34+import Text.Pandoc.Templates (renderTemplate')
35+import Text.Pandoc.Writers.Math (texMathToInlines)
36+import Text.Pandoc.Writers.Shared
37+import Text.Pandoc.XML
3638
3739type Style = [String]
3840type Hyperlink = [(Int, String)]
@@ -384,11 +386,11 @@ listItemToICML :: PandocMonad m => WriterOptions -> Style -> Bool-> Maybe ListAt
384386listItemToICML opts style isFirst attribs item =
385387 let makeNumbStart (Just (beginsWith, numbStl, _)) =
386388 let doN DefaultStyle = []
387− doN LowerRoman = [lowerRomanName]
388− doN UpperRoman = [upperRomanName]
389− doN LowerAlpha = [lowerAlphaName]
390− doN UpperAlpha = [upperAlphaName]
391− doN _ = []
389+ doN LowerRoman = [lowerRomanName]
390+ doN UpperRoman = [upperRomanName]
391+ doN LowerAlpha = [lowerAlphaName]
392+ doN UpperAlpha = [upperAlphaName]
393+ doN _ = []
392394 bw = if beginsWith > 1
393395 then [beginsWithName ++ show beginsWith]
394396 else []
@@ -483,9 +485,9 @@ mergeSpaces (x:xs) = x : (mergeSpaces xs)
483485mergeSpaces [] = []
484486
485487isSp :: Inline -> Bool
486−isSp Space = True
488+isSp Space = True
487489isSp SoftBreak = True
488−isSp _ = False
490+isSp _ = False
489491
490492-- | Intersperse line breaks
491493intersperseBrs :: [Doc] -> Doc
src/Text/Pandoc/Writers/LaTeX.hs+62−62
@@ -1,5 +1,6 @@
1−{-# LANGUAGE OverloadedStrings, ScopedTypeVariables,
2− PatternGuards #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE PatternGuards #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
34{-
45Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
56
@@ -33,32 +34,31 @@ module Text.Pandoc.Writers.LaTeX (
3334 writeLaTeX
3435 , writeBeamer
3536 ) where
36−import Text.Pandoc.Definition
37−import Text.Pandoc.Walk
38−import Text.Pandoc.Shared
39−import Text.Pandoc.Writers.Shared
40−import Text.Pandoc.Options
41−import Text.Pandoc.Templates
42−import Text.Pandoc.Logging
43−import Text.Printf ( printf )
44−import Network.URI ( isURI, unEscapeString )
45−import Data.Aeson (object, (.=), FromJSON)
46−import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse,
47− nub, nubBy, foldl' )
48−import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit,
49− ord, isAlphaNum )
50−import Data.Maybe ( fromMaybe, isJust, catMaybes )
51−import qualified Data.Text as T
5237import Control.Applicative ((<|>))
5338import Control.Monad.State
54−import qualified Text.Parsec as P
55−import Text.Pandoc.Pretty
39+import Data.Aeson (FromJSON, object, (.=))
40+import Data.Char (isAlphaNum, isAscii, isDigit, isLetter, isPunctuation, ord,
41+ toLower)
42+import Data.List (foldl', intercalate, intersperse, isInfixOf, nub, nubBy,
43+ stripPrefix, (\\))
44+import Data.Maybe (catMaybes, fromMaybe, isJust)
45+import qualified Data.Text as T
46+import Network.URI (isURI, unEscapeString)
47+import Text.Pandoc.Class (PandocMonad, report)
48+import Text.Pandoc.Definition
49+import Text.Pandoc.Highlighting (formatLaTeXBlock, formatLaTeXInline, highlight,
50+ styleToLaTeX, toListingsLanguage)
5651import Text.Pandoc.ImageSize
52+import Text.Pandoc.Logging
53+import Text.Pandoc.Options
54+import Text.Pandoc.Pretty
55+import Text.Pandoc.Shared
5756import Text.Pandoc.Slides
58−import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
59− formatLaTeXInline, formatLaTeXBlock,
60− toListingsLanguage)
61−import Text.Pandoc.Class (PandocMonad, report)
57+import Text.Pandoc.Templates
58+import Text.Pandoc.Walk
59+import Text.Pandoc.Writers.Shared
60+import qualified Text.Parsec as P
61+import Text.Printf (printf)
6262
6363data WriterState =
6464 WriterState { stInNote :: Bool -- true if we're in a note
@@ -131,11 +131,11 @@ pandocToLaTeX options (Pandoc meta blocks) = do
131131 let blocks' = if method == Biblatex || method == Natbib
132132 then case reverse blocks of
133133 (Div (_,["references"],_) _):xs -> reverse xs
134− _ -> blocks
134+ _ -> blocks
135135 else blocks
136136 -- see if there are internal links
137− let isInternalLink (Link _ _ ('#':xs,_)) = [xs]
138− isInternalLink _ = []
137+ let isInternalLink (Link _ _ ('#':xs,_)) = [xs]
138+ isInternalLink _ = []
139139 modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }
140140 let template = maybe "" id $ writerTemplate options
141141 -- set stBook depending on documentclass
@@ -408,8 +408,8 @@ isListBlock _ = False
408408isLineBreakOrSpace :: Inline -> Bool
409409isLineBreakOrSpace LineBreak = True
410410isLineBreakOrSpace SoftBreak = True
411−isLineBreakOrSpace Space = True
412−isLineBreakOrSpace _ = False
411+isLineBreakOrSpace Space = True
412+isLineBreakOrSpace _ = False
413413
414414-- | Convert Pandoc block element to LaTeX.
415415blockToLaTeX :: PandocMonad m
@@ -584,10 +584,10 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
584584 Example -> "\\arabic" <> braces x
585585 DefaultStyle -> "\\arabic" <> braces x
586586 let todelim x = case numdelim of
587− OneParen -> x <> ")"
588− TwoParens -> parens x
589− Period -> x <> "."
590− _ -> x <> "."
587+ OneParen -> x <> ")"
588+ TwoParens -> parens x
589+ Period -> x <> "."
590+ _ -> x <> "."
591591 let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
592592 let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
593593 then empty
@@ -710,7 +710,7 @@ fixLineBreaks' ils = case splitBy (== LineBreak) ils of
710710-- math breaks in simple tables.
711711displayMathToInline :: Inline -> Inline
712712displayMathToInline (Math DisplayMath x) = Math InlineMath x
713−displayMathToInline x = x
713+displayMathToInline x = x
714714
715715tableCellToLaTeX :: PandocMonad m => Bool -> (Double, Alignment, [Block])
716716 -> LW m Doc
@@ -783,10 +783,10 @@ sectionHeader :: PandocMonad m
783783sectionHeader unnumbered ident level lst = do
784784 txt <- inlineListToLaTeX lst
785785 plain <- stringToLaTeX TextString $ concatMap stringify lst
786− let removeInvalidInline (Note _) = []
786+ let removeInvalidInline (Note _) = []
787787 removeInvalidInline (Span (id', _, _) _) | not (null id') = []
788− removeInvalidInline (Image _ _ _) = []
789− removeInvalidInline x = [x]
788+ removeInvalidInline (Image _ _ _) = []
789+ removeInvalidInline x = [x]
790790 let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
791791 txtNoNotes <- inlineListToLaTeX lstNoNotes
792792 -- footnotes in sections don't work (except for starred variants)
@@ -889,7 +889,7 @@ inlineListToLaTeX lst =
889889
890890isQuoted :: Inline -> Bool
891891isQuoted (Quoted _ _) = True
892−isQuoted _ = False
892+isQuoted _ = False
893893
894894-- | Convert inline element to LaTeX
895895inlineToLaTeX :: PandocMonad m
@@ -1092,8 +1092,8 @@ citationsToNatbib (one:[])
10921092 }
10931093 = one
10941094 c = case m of
1095− AuthorInText -> "citet"
1096− SuppressAuthor -> "citeyearpar"
1095+ AuthorInText -> "citet"
1096+ SuppressAuthor -> "citeyearpar"
10971097 NormalCitation -> "citep"
10981098
10991099citationsToNatbib cits
@@ -1140,7 +1140,7 @@ citeArguments p s k = do
11401140 let s' = case s of
11411141 (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r
11421142 (Str (x:xs) : r) | isPunctuation x -> Str xs : r
1143− _ -> s
1143+ _ -> s
11441144 pdoc <- inlineListToLaTeX p
11451145 sdoc <- inlineListToLaTeX s'
11461146 let optargs = case (isEmpty pdoc, isEmpty sdoc) of
@@ -1181,7 +1181,7 @@ citationsToBiblatex _ = return empty
11811181
11821182-- Determine listings language from list of class attributes.
11831183getListingsLanguage :: [String] -> Maybe String
1184−getListingsLanguage [] = Nothing
1184+getListingsLanguage [] = Nothing
11851185getListingsLanguage (x:xs) = toListingsLanguage x <|> getListingsLanguage xs
11861186
11871187mbBraced :: String -> String
@@ -1253,27 +1253,27 @@ toPolyglossia x = (commonFromBcp47 x, "")
12531253-- List of supported languages (slightly outdated):
12541254-- http://tug.ctan.org/language/hyph-utf8/doc/generic/hyph-utf8/hyphenation.pdf
12551255toBabel :: [String] -> String
1256−toBabel ("de":"1901":_) = "german"
1257−toBabel ("de":"AT":"1901":_) = "austrian"
1258−toBabel ("de":"AT":_) = "naustrian"
1259−toBabel ("de":"CH":"1901":_) = "swissgerman"
1260−toBabel ("de":"CH":_) = "nswissgerman"
1261−toBabel ("de":_) = "ngerman"
1262−toBabel ("dsb":_) = "lowersorbian"
1263−toBabel ("el":"polyton":_) = "polutonikogreek"
1264−toBabel ("en":"AU":_) = "australian"
1265−toBabel ("en":"CA":_) = "canadian"
1266−toBabel ("en":"GB":_) = "british"
1267−toBabel ("en":"NZ":_) = "newzealand"
1268−toBabel ("en":"UK":_) = "british"
1269−toBabel ("en":"US":_) = "american"
1270−toBabel ("fr":"CA":_) = "canadien"
1271−toBabel ("fra":"aca":_) = "acadian"
1272−toBabel ("grc":_) = "polutonikogreek"
1273−toBabel ("hsb":_) = "uppersorbian"
1256+toBabel ("de":"1901":_) = "german"
1257+toBabel ("de":"AT":"1901":_) = "austrian"
1258+toBabel ("de":"AT":_) = "naustrian"
1259+toBabel ("de":"CH":"1901":_) = "swissgerman"
1260+toBabel ("de":"CH":_) = "nswissgerman"
1261+toBabel ("de":_) = "ngerman"
1262+toBabel ("dsb":_) = "lowersorbian"
1263+toBabel ("el":"polyton":_) = "polutonikogreek"
1264+toBabel ("en":"AU":_) = "australian"
1265+toBabel ("en":"CA":_) = "canadian"
1266+toBabel ("en":"GB":_) = "british"
1267+toBabel ("en":"NZ":_) = "newzealand"
1268+toBabel ("en":"UK":_) = "british"
1269+toBabel ("en":"US":_) = "american"
1270+toBabel ("fr":"CA":_) = "canadien"
1271+toBabel ("fra":"aca":_) = "acadian"
1272+toBabel ("grc":_) = "polutonikogreek"
1273+toBabel ("hsb":_) = "uppersorbian"
12741274toBabel ("la":"x":"classic":_) = "classiclatin"
1275−toBabel ("sl":_) = "slovene"
1276−toBabel x = commonFromBcp47 x
1275+toBabel ("sl":_) = "slovene"
1276+toBabel x = commonFromBcp47 x
12771277
12781278-- Takes a list of the constituents of a BCP 47 language code
12791279-- and converts it to a string shared by Babel and Polyglossia.
src/Text/Pandoc/Writers/Man.hs+16−16
@@ -29,25 +29,25 @@ Conversion of 'Pandoc' documents to groff man page format.
2929
3030-}
3131module Text.Pandoc.Writers.Man ( writeMan) where
32−import Text.Pandoc.Definition
33−import Text.Pandoc.Templates
34−import Text.Pandoc.Shared
35−import Text.Pandoc.Writers.Shared
36−import Text.Pandoc.Options
37−import Text.Pandoc.Writers.Math
38−import Text.Printf ( printf )
39−import Data.List ( stripPrefix, intersperse, intercalate )
32+import Control.Monad.Except (throwError)
33+import Control.Monad.State
34+import Data.List (intercalate, intersperse, stripPrefix)
4035import Data.Maybe (fromMaybe)
41−import Text.Pandoc.Pretty
4236import Text.Pandoc.Builder (deleteMeta)
43−import Control.Monad.State
44−import Text.Pandoc.Error
45−import Control.Monad.Except (throwError)
4637import Text.Pandoc.Class (PandocMonad, report)
38+import Text.Pandoc.Definition
39+import Text.Pandoc.Error
4740import Text.Pandoc.Logging
41+import Text.Pandoc.Options
42+import Text.Pandoc.Pretty
43+import Text.Pandoc.Shared
44+import Text.Pandoc.Templates
45+import Text.Pandoc.Writers.Math
46+import Text.Pandoc.Writers.Shared
47+import Text.Printf (printf)
4848
4949type Notes = [[Block]]
50−data WriterState = WriterState { stNotes :: Notes
50+data WriterState = WriterState { stNotes :: Notes
5151 , stHasTables :: Bool }
5252
5353-- | Convert Pandoc to Man.
@@ -131,7 +131,7 @@ escapeCode = concat . intersperse "\n" . map escapeLine . lines where
131131 escapeLine codeline =
132132 case escapeStringUsing (manEscapes ++ backslashEscapes "\t ") codeline of
133133 a@('.':_) -> "\\&" ++ a
134− b -> b
134+ b -> b
135135
136136-- We split inline lists into sentences, and print one sentence per
137137-- line. groff/troff treats the line-ending period differently.
@@ -143,8 +143,8 @@ breakSentence [] = ([],[])
143143breakSentence xs =
144144 let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True
145145 isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True
146− isSentenceEndInline (LineBreak) = True
147− isSentenceEndInline _ = False
146+ isSentenceEndInline (LineBreak) = True
147+ isSentenceEndInline _ = False
148148 (as, bs) = break isSentenceEndInline xs
149149 in case bs of
150150 [] -> (as, [])
src/Text/Pandoc/Writers/Markdown.hs+60−57
@@ -1,4 +1,7 @@
1−{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables, MultiWayIf #-}
1+{-# LANGUAGE MultiWayIf #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
4+{-# LANGUAGE TupleSections #-}
25{-
36Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
47
@@ -31,36 +34,36 @@ Conversion of 'Pandoc' documents to markdown-formatted plain text.
3134Markdown: <http://daringfireball.net/projects/markdown/>
3235-}
3336module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where
34−import Text.Pandoc.Definition
35−import Text.Pandoc.Walk
36−import Text.Pandoc.Templates (renderTemplate')
37−import Text.Pandoc.Shared
38−import Text.Pandoc.Writers.Shared
39−import Text.Pandoc.Options
40−import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)
41−import Data.Maybe (fromMaybe)
42−import Data.Monoid (Any(..))
43−import Data.List ( group, stripPrefix, find, intersperse, transpose, sortBy )
44−import Data.Char ( isSpace, isPunctuation, ord, chr )
45−import Data.Ord ( comparing )
46−import Text.Pandoc.Pretty
37+import Control.Monad.Except (throwError)
4738import Control.Monad.Reader
4839import Control.Monad.State
49−import Control.Monad.Except (throwError)
50−import Text.Pandoc.Writers.HTML (writeHtml5String)
51−import Text.Pandoc.Writers.Math (texMathToInlines)
52−import Text.HTML.TagSoup (parseTags, isTagText, Tag(..))
53−import Network.URI (isURI)
40+import Data.Char (chr, isPunctuation, isSpace, ord)
5441import Data.Default
55−import Data.Yaml (Value(Object,String,Array,Bool,Number))
5642import qualified Data.HashMap.Strict as H
57−import qualified Data.Vector as V
58−import qualified Data.Text as T
43+import Data.List (find, group, intersperse, sortBy, stripPrefix, transpose)
44+import Data.Maybe (fromMaybe)
45+import Data.Monoid (Any (..))
46+import Data.Ord (comparing)
5947import qualified Data.Set as Set
60−import Network.HTTP ( urlEncode )
61−import Text.Pandoc.Error
48+import qualified Data.Text as T
49+import qualified Data.Vector as V
50+import Data.Yaml (Value (Array, Bool, Number, Object, String))
51+import Network.HTTP (urlEncode)
52+import Network.URI (isURI)
53+import Text.HTML.TagSoup (Tag (..), isTagText, parseTags)
6254import Text.Pandoc.Class (PandocMonad, report)
55+import Text.Pandoc.Definition
56+import Text.Pandoc.Error
6357import Text.Pandoc.Logging
58+import Text.Pandoc.Options
59+import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)
60+import Text.Pandoc.Pretty
61+import Text.Pandoc.Shared
62+import Text.Pandoc.Templates (renderTemplate')
63+import Text.Pandoc.Walk
64+import Text.Pandoc.Writers.HTML (writeHtml5String)
65+import Text.Pandoc.Writers.Math (texMathToInlines)
66+import Text.Pandoc.Writers.Shared
6467
6568type Notes = [[Block]]
6669type Ref = ([Inline], Target, Attr)
@@ -71,11 +74,11 @@ type MD m = ReaderT WriterEnv (StateT WriterState m)
7174evalMD :: PandocMonad m => MD m a -> WriterEnv -> WriterState -> m a
7275evalMD md env st = evalStateT (runReaderT md env) st
7376
74−data WriterEnv = WriterEnv { envInList :: Bool
75− , envPlain :: Bool
77+data WriterEnv = WriterEnv { envInList :: Bool
78+ , envPlain :: Bool
7679 , envRefShortcutable :: Bool
7780 , envBlockLevel :: Int
78− , envEscapeSpaces :: Bool
81+ , envEscapeSpaces :: Bool
7982 }
8083
8184instance Default WriterEnv
@@ -86,9 +89,9 @@ instance Default WriterEnv
8689 , envEscapeSpaces = False
8790 }
8891
89−data WriterState = WriterState { stNotes :: Notes
90− , stRefs :: Refs
91− , stIds :: Set.Set String
92+data WriterState = WriterState { stNotes :: Notes
93+ , stRefs :: Refs
94+ , stIds :: Set.Set String
9295 , stNoteNum :: Int
9396 }
9497
@@ -206,7 +209,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
206209 let blocks' = if isEnabled Ext_citations opts
207210 then case reverse blocks of
208211 (Div (_,["references"],_) _):xs -> reverse xs
209− _ -> blocks
212+ _ -> blocks
210213 else blocks
211214 body <- blockListToMarkdown opts blocks'
212215 notesAndRefs' <- notesAndRefs opts
@@ -260,7 +263,7 @@ noteToMarkdown opts num blocks = do
260263 let markerSize = 4 + offset num'
261264 let spacer = case writerTabStop opts - markerSize of
262265 n | n > 0 -> text $ replicate n ' '
263− _ -> text " "
266+ _ -> text " "
264267 return $ if isEnabled Ext_footnotes opts
265268 then hang (writerTabStop opts) (marker <> spacer) contents
266269 else marker <> spacer <> contents
@@ -282,11 +285,11 @@ escapeString opts (c:cs) =
282285 '-' | isEnabled Ext_smart opts ->
283286 case cs of
284287 '-':_ -> '\\':'-':escapeString opts cs
285− _ -> '-':escapeString opts cs
288+ _ -> '-':escapeString opts cs
286289 '.' | isEnabled Ext_smart opts ->
287290 case cs of
288291 '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest
289− _ -> '.':escapeString opts cs
292+ _ -> '.':escapeString opts cs
290293 _ -> c : escapeString opts cs
291294
292295-- | Construct table of contents from list of header blocks.
@@ -342,8 +345,8 @@ olMarker = do (start, style', delim) <- anyOrderedListMarker
342345beginsWithOrderedListMarker :: String -> Bool
343346beginsWithOrderedListMarker str =
344347 case runParser olMarker defaultParserState "para start" (take 10 str) of
345− Left _ -> False
346− Right _ -> True
348+ Left _ -> False
349+ Right _ -> True
347350
348351notesAndRefs :: PandocMonad m => WriterOptions -> MD m Doc
349352notesAndRefs opts = do
@@ -727,7 +730,7 @@ itemEndsWithTightList bs =
727730 case bs of
728731 [Plain _, BulletList xs] -> isTightList xs
729732 [Plain _, OrderedList _ xs] -> isTightList xs
730− _ -> False
733+ _ -> False
731734
732735-- | Convert bullet list item (list of blocks) to markdown.
733736bulletListItemToMarkdown :: PandocMonad m => WriterOptions -> [Block] -> MD m Doc
@@ -751,7 +754,7 @@ orderedListItemToMarkdown opts marker bs = do
751754 contents <- blockListToMarkdown opts bs
752755 let sps = case length marker - writerTabStop opts of
753756 n | n > 0 -> text $ replicate n ' '
754− _ -> text " "
757+ _ -> text " "
755758 let start = text marker <> sps
756759 -- remove trailing blank line if item ends with a tight list
757760 let contents' = if itemEndsWithTightList bs
@@ -774,7 +777,7 @@ definitionListItemToMarkdown opts (label, defs) = do
774777 let leader = if isPlain then " " else ": "
775778 let sps = case writerTabStop opts - 3 of
776779 n | n > 0 -> text $ replicate n ' '
777− _ -> text " "
780+ _ -> text " "
778781 if isEnabled Ext_compact_definition_lists opts
779782 then do
780783 let contents = vcat $ map (\d -> hang tabStop (leader <> sps)
@@ -785,7 +788,7 @@ definitionListItemToMarkdown opts (label, defs) = do
785788 $ vcat d <> cr) defs'
786789 let isTight = case defs of
787790 ((Plain _ : _): _) -> True
788− _ -> False
791+ _ -> False
789792 return $ blankline <> nowrap labelText <>
790793 (if isTight then cr else blankline) <> contents <> blankline
791794 else do
@@ -849,20 +852,20 @@ inlineListToMarkdown opts lst = do
849852 go (i:is) = case i of
850853 (Link _ _ _) -> case is of
851854 -- If a link is followed by another link or '[' we don't shortcut
852− (Link _ _ _):_ -> unshortcutable
853− Space:(Link _ _ _):_ -> unshortcutable
854− Space:(Str('[':_)):_ -> unshortcutable
855− Space:(RawInline _ ('[':_)):_ -> unshortcutable
856− Space:(Cite _ _):_ -> unshortcutable
857− SoftBreak:(Link _ _ _):_ -> unshortcutable
858− SoftBreak:(Str('[':_)):_ -> unshortcutable
855+ (Link _ _ _):_ -> unshortcutable
856+ Space:(Link _ _ _):_ -> unshortcutable
857+ Space:(Str('[':_)):_ -> unshortcutable
858+ Space:(RawInline _ ('[':_)):_ -> unshortcutable
859+ Space:(Cite _ _):_ -> unshortcutable
860+ SoftBreak:(Link _ _ _):_ -> unshortcutable
861+ SoftBreak:(Str('[':_)):_ -> unshortcutable
859862 SoftBreak:(RawInline _ ('[':_)):_ -> unshortcutable
860− SoftBreak:(Cite _ _):_ -> unshortcutable
861− (Cite _ _):_ -> unshortcutable
862− Str ('[':_):_ -> unshortcutable
863− (RawInline _ ('[':_)):_ -> unshortcutable
864− (RawInline _ (' ':'[':_)):_ -> unshortcutable
865− _ -> shortcutable
863+ SoftBreak:(Cite _ _):_ -> unshortcutable
864+ (Cite _ _):_ -> unshortcutable
865+ Str ('[':_):_ -> unshortcutable
866+ (RawInline _ ('[':_)):_ -> unshortcutable
867+ (RawInline _ (' ':'[':_)):_ -> unshortcutable
868+ _ -> shortcutable
866869 _ -> shortcutable
867870 where shortcutable = liftM2 (<>) (inlineToMarkdown opts i) (go is)
868871 unshortcutable = do
@@ -872,9 +875,9 @@ inlineListToMarkdown opts lst = do
872875 fmap (iMark <>) (go is)
873876
874877isSp :: Inline -> Bool
875−isSp Space = True
878+isSp Space = True
876879isSp SoftBreak = True
877−isSp _ = False
880+isSp _ = False
878881
879882avoidBadWrapsInList :: [Inline] -> [Inline]
880883avoidBadWrapsInList [] = []
@@ -1109,7 +1112,7 @@ inlineToMarkdown opts lnk@(Link attr txt (src, tit))
11091112 let useAuto = isURI src &&
11101113 case txt of
11111114 [Str s] | escapeURI s == srcSuffix -> True
1112− _ -> False
1115+ _ -> False
11131116 let useRefLinks = writerReferenceLinks opts && not useAuto
11141117 shortcutable <- asks envRefShortcutable
11151118 let useShortcutRefLinks = shortcutable &&
@@ -1160,5 +1163,5 @@ makeMathPlainer :: [Inline] -> [Inline]
11601163makeMathPlainer = walk go
11611164 where
11621165 go (Emph xs) = Span nullAttr xs
1163− go x = x
1166+ go x = x
11641167
src/Text/Pandoc/Writers/Math.hs+1−1
@@ -7,7 +7,7 @@ where
77import Text.Pandoc.Class
88import Text.Pandoc.Definition
99import Text.Pandoc.Logging
10−import Text.TeXMath (Exp, writePandoc, DisplayType(..), readTeX)
10+import Text.TeXMath (DisplayType (..), Exp, readTeX, writePandoc)
1111
1212-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
1313-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
src/Text/Pandoc/Writers/MediaWiki.hs+26−26
@@ -30,30 +30,30 @@ Conversion of 'Pandoc' documents to MediaWiki markup.
3030MediaWiki: <http://www.mediawiki.org/wiki/MediaWiki>
3131-}
3232module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki ) where
33+import Control.Monad.Reader
34+import Control.Monad.State
35+import Data.List (intercalate)
36+import qualified Data.Set as Set
37+import Network.URI (isURI)
38+import Text.Pandoc.Class (PandocMonad)
3339import Text.Pandoc.Definition
40+import Text.Pandoc.ImageSize
3441import Text.Pandoc.Options
35−import Text.Pandoc.Shared
36−import Text.Pandoc.Writers.Shared
3742import Text.Pandoc.Pretty (render)
38−import Text.Pandoc.ImageSize
43+import Text.Pandoc.Shared
3944import Text.Pandoc.Templates (renderTemplate')
40−import Text.Pandoc.XML ( escapeStringForXML )
41−import Data.List ( intercalate )
42−import qualified Data.Set as Set
43−import Network.URI ( isURI )
44−import Control.Monad.Reader
45−import Control.Monad.State
46−import Text.Pandoc.Class (PandocMonad)
45+import Text.Pandoc.Writers.Shared
46+import Text.Pandoc.XML (escapeStringForXML)
4747
4848data WriterState = WriterState {
49− stNotes :: Bool -- True if there are notes
50− , stOptions :: WriterOptions -- writer options
49+ stNotes :: Bool -- True if there are notes
50+ , stOptions :: WriterOptions -- writer options
5151 }
5252
5353data WriterReader = WriterReader {
54− options :: WriterOptions -- Writer options
55− , listLevel :: String -- String at beginning of list items, e.g. "**"
56− , useTags :: Bool -- True if we should use HTML tags because we're in a complex list
54+ options :: WriterOptions -- Writer options
55+ , listLevel :: String -- String at beginning of list items, e.g. "**"
56+ , useTags :: Bool -- True if we should use HTML tags because we're in a complex list
5757 }
5858
5959type MediaWikiWriter = ReaderT WriterReader (State WriterState)
@@ -253,18 +253,18 @@ isSimpleListItem :: [Block] -> Bool
253253isSimpleListItem [] = True
254254isSimpleListItem [x] =
255255 case x of
256− Plain _ -> True
257− Para _ -> True
258− BulletList _ -> isSimpleList x
259− OrderedList _ _ -> isSimpleList x
260− DefinitionList _ -> isSimpleList x
261− _ -> False
256+ Plain _ -> True
257+ Para _ -> True
258+ BulletList _ -> isSimpleList x
259+ OrderedList _ _ -> isSimpleList x
260+ DefinitionList _ -> isSimpleList x
261+ _ -> False
262262isSimpleListItem [x, y] | isPlainOrPara x =
263263 case y of
264− BulletList _ -> isSimpleList y
265− OrderedList _ _ -> isSimpleList y
266− DefinitionList _ -> isSimpleList y
267− _ -> False
264+ BulletList _ -> isSimpleList y
265+ OrderedList _ _ -> isSimpleList y
266+ DefinitionList _ -> isSimpleList y
267+ _ -> False
268268isSimpleListItem _ = False
269269
270270isPlainOrPara :: Block -> Bool
@@ -322,7 +322,7 @@ imageToMediaWiki attr = do
322322 let (_, cls, _) = attr
323323 toPx = fmap (showInPixel opts) . checkPct
324324 checkPct (Just (Percent _)) = Nothing
325− checkPct maybeDim = maybeDim
325+ checkPct maybeDim = maybeDim
326326 go (Just w) Nothing = '|':w ++ "px"
327327 go (Just w) (Just h) = '|':w ++ "x" ++ h ++ "px"
328328 go Nothing (Just h) = "|x" ++ h ++ "px"
src/Text/Pandoc/Writers/Native.hs+3−3
@@ -30,11 +30,11 @@ Conversion of a 'Pandoc' document to a string representation.
3030-}
3131module Text.Pandoc.Writers.Native ( writeNative )
3232where
33−import Text.Pandoc.Options ( WriterOptions(..), WrapOption(..) )
34−import Data.List ( intersperse )
33+import Data.List (intersperse)
34+import Text.Pandoc.Class (PandocMonad)
3535import Text.Pandoc.Definition
36+import Text.Pandoc.Options (WrapOption (..), WriterOptions (..))
3637import Text.Pandoc.Pretty
37−import Text.Pandoc.Class (PandocMonad)
3838
3939prettyList :: [Doc] -> Doc
4040prettyList ds =
src/Text/Pandoc/Writers/ODT.hs+20−20
@@ -29,30 +29,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2929Conversion of 'Pandoc' documents to ODT.
3030-}
3131module Text.Pandoc.Writers.ODT ( writeODT ) where
32−import Data.List ( isPrefixOf )
33−import Data.Maybe ( fromMaybe )
34−import Text.XML.Light.Output
35−import Text.TeXMath
36−import qualified Data.ByteString.Lazy as B
37−import Text.Pandoc.UTF8 ( fromStringLazy )
3832import Codec.Archive.Zip
39−import Text.Pandoc.Options ( WriterOptions(..), WrapOption(..) )
40−import Text.Pandoc.Shared ( stringify )
41−import Text.Pandoc.ImageSize
42−import Text.Pandoc.MIME ( getMimeType, extensionFromMimeType )
43−import Text.Pandoc.Definition
44−import Text.Pandoc.Walk
45−import Text.Pandoc.Writers.Shared ( fixDisplayMath )
46−import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument )
47−import Control.Monad.State
4833import Control.Monad.Except (catchError)
49−import Text.Pandoc.Error (PandocError(..))
50−import Text.Pandoc.XML
51−import Text.Pandoc.Pretty
52−import System.FilePath ( takeExtension, takeDirectory, (<.>))
53−import Text.Pandoc.Class ( PandocMonad, report )
34+import Control.Monad.State
35+import qualified Data.ByteString.Lazy as B
36+import Data.List (isPrefixOf)
37+import Data.Maybe (fromMaybe)
38+import System.FilePath (takeDirectory, takeExtension, (<.>))
39+import Text.Pandoc.Class (PandocMonad, report)
5440import qualified Text.Pandoc.Class as P
41+import Text.Pandoc.Definition
42+import Text.Pandoc.Error (PandocError (..))
43+import Text.Pandoc.ImageSize
5544import Text.Pandoc.Logging
45+import Text.Pandoc.MIME (extensionFromMimeType, getMimeType)
46+import Text.Pandoc.Options (WrapOption (..), WriterOptions (..))
47+import Text.Pandoc.Pretty
48+import Text.Pandoc.Shared (stringify)
49+import Text.Pandoc.UTF8 (fromStringLazy)
50+import Text.Pandoc.Walk
51+import Text.Pandoc.Writers.OpenDocument (writeOpenDocument)
52+import Text.Pandoc.Writers.Shared (fixDisplayMath)
53+import Text.Pandoc.XML
54+import Text.TeXMath
55+import Text.XML.Light.Output
5656
5757data ODTState = ODTState { stEntries :: [Entry]
5858 }
src/Text/Pandoc/Writers/OPML.hs+10−10
@@ -29,20 +29,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2929Conversion of 'Pandoc' documents to OPML XML.
3030-}
3131module Text.Pandoc.Writers.OPML ( writeOPML) where
32+import Control.Monad.Except (throwError)
33+import qualified Text.Pandoc.Builder as B
34+import Text.Pandoc.Class (PandocMonad)
35+import Text.Pandoc.Compat.Time
3236import Text.Pandoc.Definition
33−import Text.Pandoc.XML
34−import Text.Pandoc.Writers.Shared
35−import Text.Pandoc.Shared
37+import Text.Pandoc.Error
3638import Text.Pandoc.Options
39+import Text.Pandoc.Pretty
40+import Text.Pandoc.Shared
3741import Text.Pandoc.Templates (renderTemplate')
3842import Text.Pandoc.Writers.HTML (writeHtml5String)
3943import Text.Pandoc.Writers.Markdown (writeMarkdown)
40−import Text.Pandoc.Pretty
41−import Text.Pandoc.Compat.Time
42−import qualified Text.Pandoc.Builder as B
43−import Text.Pandoc.Error
44−import Control.Monad.Except (throwError)
45−import Text.Pandoc.Class (PandocMonad)
44+import Text.Pandoc.Writers.Shared
45+import Text.Pandoc.XML
4646
4747-- | Convert Pandoc document to string in OPML format.
4848writeOPML :: PandocMonad m => WriterOptions -> Pandoc -> m String
@@ -86,7 +86,7 @@ elementToOPML _ (Blk _) = return empty
8686elementToOPML opts (Sec _ _num _ title elements) = do
8787 let isBlk :: Element -> Bool
8888 isBlk (Blk _) = True
89− isBlk _ = False
89+ isBlk _ = False
9090
9191 fromBlk :: PandocMonad m => Element -> m Block
9292 fromBlk (Blk x) = return x
src/Text/Pandoc/Writers/OpenDocument.hs+24−22
@@ -1,4 +1,6 @@
1−{-# LANGUAGE PatternGuards, OverloadedStrings, FlexibleContexts #-}
1+{-# LANGUAGE FlexibleContexts #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE PatternGuards #-}
24{-
35Copyright (C) 2008-2015 Andrea Rossato <andrea.rossato@ing.unitn.it>
46 and John MacFarlane.
@@ -30,29 +32,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3032Conversion of 'Pandoc' documents to OpenDocument XML.
3133-}
3234module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where
35+import Control.Arrow ((***), (>>>))
36+import Control.Monad.State hiding (when)
37+import Data.Char (chr)
38+import Data.List (sortBy)
39+import qualified Data.Map as Map
40+import Data.Ord (comparing)
41+import qualified Data.Set as Set
42+import Text.Pandoc.Class (PandocMonad, report)
3343import Text.Pandoc.Definition
44+import Text.Pandoc.Logging
3445import Text.Pandoc.Options
35−import Text.Pandoc.XML
46+import Text.Pandoc.Pretty
3647import Text.Pandoc.Shared (linesToPara)
3748import Text.Pandoc.Templates (renderTemplate')
3849import Text.Pandoc.Writers.Math
39−import Text.Pandoc.Pretty
40−import Text.Printf ( printf )
41−import Control.Arrow ( (***), (>>>) )
42−import Control.Monad.State hiding ( when )
43−import Data.Char (chr)
44−import qualified Data.Set as Set
45−import qualified Data.Map as Map
4650import Text.Pandoc.Writers.Shared
47−import Data.List (sortBy)
48−import Data.Ord (comparing)
49−import Text.Pandoc.Class (PandocMonad, report)
50−import Text.Pandoc.Logging
51+import Text.Pandoc.XML
52+import Text.Printf (printf)
5153
5254-- | Auxiliary function to convert Plain block to Para.
5355plainToPara :: Block -> Block
5456plainToPara (Plain x) = Para x
55−plainToPara x = x
57+plainToPara x = x
5658
5759--
5860-- OpenDocument writer
@@ -426,10 +428,10 @@ toChunks o (x : xs)
426428 where (ys, zs) = span isChunkable xs
427429
428430isChunkable :: Inline -> Bool
429−isChunkable (Str _) = True
430−isChunkable Space = True
431+isChunkable (Str _) = True
432+isChunkable Space = True
431433isChunkable SoftBreak = True
432−isChunkable _ = False
434+isChunkable _ = False
433435
434436-- | Convert an inline element to OpenDocument.
435437inlineToOpenDocument :: PandocMonad m => WriterOptions -> Inline -> OD m Doc
@@ -514,11 +516,11 @@ orderedListLevelStyle (s,n, d) (l,ls) =
514516 ,("style:num-suffix", ")")]
515517 _ -> [("style:num-suffix", ".")]
516518 format = case n of
517− UpperAlpha -> "A"
518− LowerAlpha -> "a"
519− UpperRoman -> "I"
520− LowerRoman -> "i"
521− _ -> "1"
519+ UpperAlpha -> "A"
520+ LowerAlpha -> "a"
521+ UpperRoman -> "I"
522+ LowerRoman -> "i"
523+ _ -> "1"
522524 listStyle = inTags True "text:list-level-style-number"
523525 ([ ("text:level" , show $ 1 + length ls )
524526 , ("text:style-name" , "Numbering_20_Symbols")
src/Text/Pandoc/Writers/Org.hs+17−17
@@ -33,21 +33,21 @@ Conversion of 'Pandoc' documents to Emacs Org-Mode.
3333Org-Mode: <http://orgmode.org>
3434-}
3535module Text.Pandoc.Writers.Org ( writeOrg) where
36+import Control.Monad.State
37+import Data.Char (isAlphaNum, toLower)
38+import Data.List (intersect, intersperse, isPrefixOf, partition, transpose)
39+import Text.Pandoc.Class (PandocMonad)
3640import Text.Pandoc.Definition
3741import Text.Pandoc.Options
38−import Text.Pandoc.Shared
39−import Text.Pandoc.Writers.Shared
4042import Text.Pandoc.Pretty
43+import Text.Pandoc.Shared
4144import Text.Pandoc.Templates (renderTemplate')
42−import Data.Char ( isAlphaNum, toLower )
43−import Data.List ( isPrefixOf, intersect, intersperse, partition, transpose )
44−import Control.Monad.State
45−import Text.Pandoc.Class (PandocMonad)
45+import Text.Pandoc.Writers.Shared
4646
4747data WriterState =
48− WriterState { stNotes :: [[Block]]
49− , stHasMath :: Bool
50− , stOptions :: WriterOptions
48+ WriterState { stNotes :: [[Block]]
49+ , stHasMath :: Bool
50+ , stOptions :: WriterOptions
5151 }
5252
5353-- | Convert Pandoc to Org.
@@ -352,9 +352,9 @@ inlineToOrg Space = return space
352352inlineToOrg SoftBreak = do
353353 wrapText <- gets (writerWrapText . stOptions)
354354 case wrapText of
355− WrapPreserve -> return cr
356− WrapAuto -> return space
357− WrapNone -> return space
355+ WrapPreserve -> return cr
356+ WrapAuto -> return space
357+ WrapNone -> return space
358358inlineToOrg (Link _ txt (src, _)) = do
359359 case txt of
360360 [Str x] | escapeURI x == src -> -- autolink
@@ -373,11 +373,11 @@ inlineToOrg (Note contents) = do
373373orgPath :: String -> String
374374orgPath src =
375375 case src of
376− [] -> mempty -- wiki link
377− ('#':_) -> src -- internal link
378− _ | isUrl src -> src
379− _ | isFilePath src -> src
380− _ -> "file:" <> src
376+ [] -> mempty -- wiki link
377+ ('#':_) -> src -- internal link
378+ _ | isUrl src -> src
379+ _ | isFilePath src -> src
380+ _ -> "file:" <> src
381381 where
382382 isFilePath :: String -> Bool
383383 isFilePath cs = any (`isPrefixOf` cs) ["/", "./", "../", "file:"]
src/Text/Pandoc/Writers/RST.hs+29−29
@@ -31,20 +31,20 @@ Conversion of 'Pandoc' documents to reStructuredText.
3131reStructuredText: <http://docutils.sourceforge.net/rst.html>
3232-}
3333module Text.Pandoc.Writers.RST ( writeRST ) where
34+import Control.Monad.State
35+import Data.Char (isSpace, toLower)
36+import Data.List (intersperse, isPrefixOf, stripPrefix, transpose)
37+import Data.Maybe (fromMaybe)
38+import Network.URI (isURI)
39+import Text.Pandoc.Builder (deleteMeta)
40+import Text.Pandoc.Class (PandocMonad)
3441import Text.Pandoc.Definition
42+import Text.Pandoc.ImageSize
3543import Text.Pandoc.Options
44+import Text.Pandoc.Pretty
3645import Text.Pandoc.Shared
37−import Text.Pandoc.Writers.Shared
38−import Text.Pandoc.ImageSize
3946import Text.Pandoc.Templates (renderTemplate')
40−import Text.Pandoc.Builder (deleteMeta)
41−import Data.Maybe (fromMaybe)
42−import Data.List ( isPrefixOf, stripPrefix, intersperse, transpose )
43−import Network.URI (isURI)
44−import Text.Pandoc.Pretty
45−import Control.Monad.State
46−import Data.Char (isSpace, toLower)
47−import Text.Pandoc.Class (PandocMonad)
47+import Text.Pandoc.Writers.Shared
4848
4949type Refs = [([Inline], Target)]
5050
@@ -76,7 +76,7 @@ pandocToRST (Pandoc meta blocks) = do
7676 else Nothing
7777 let subtit = case lookupMeta "subtitle" meta of
7878 Just (MetaBlocks [Plain xs]) -> xs
79− _ -> []
79+ _ -> []
8080 title <- titleToRST (docTitle meta) subtit
8181 metadata <- metaToJSON opts
8282 (fmap (render colwidth) . blockListToRST)
@@ -108,7 +108,7 @@ pandocToRST (Pandoc meta blocks) = do
108108 Header lev a i:normalizeHeadings (lev+1) cont ++ normalizeHeadings lev bs'
109109 where (cont,bs') = break (headerLtEq l) bs
110110 headerLtEq level (Header l' _ _) = l' <= level
111− headerLtEq _ _ = False
111+ headerLtEq _ _ = False
112112 normalizeHeadings lev (b:bs) = b:normalizeHeadings lev bs
113113 normalizeHeadings _ [] = []
114114
@@ -171,11 +171,11 @@ escapeString opts (c:cs) =
171171 '-' | isEnabled Ext_smart opts ->
172172 case cs of
173173 '-':_ -> '\\':'-':escapeString opts cs
174− _ -> '-':escapeString opts cs
174+ _ -> '-':escapeString opts cs
175175 '.' | isEnabled Ext_smart opts ->
176176 case cs of
177177 '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest
178− _ -> '.':escapeString opts cs
178+ _ -> '.':escapeString opts cs
179179 _ -> c : escapeString opts cs
180180
181181titleToRST :: [Inline] -> [Inline] -> State WriterState Doc
@@ -412,19 +412,19 @@ inlineListToRST lst =
412412 okBeforeComplex (Str (c:_)) = isSpace c || c `elem` ("-:/'\"<([{–—" :: String)
413413 okBeforeComplex _ = False
414414 isComplex :: Inline -> Bool
415− isComplex (Emph _) = True
416− isComplex (Strong _) = True
417− isComplex (SmallCaps _) = True
418− isComplex (Strikeout _) = True
415+ isComplex (Emph _) = True
416+ isComplex (Strong _) = True
417+ isComplex (SmallCaps _) = True
418+ isComplex (Strikeout _) = True
419419 isComplex (Superscript _) = True
420− isComplex (Subscript _) = True
421− isComplex (Link _ _ _) = True
422− isComplex (Image _ _ _) = True
423− isComplex (Code _ _) = True
424− isComplex (Math _ _) = True
425− isComplex (Cite _ (x:_)) = isComplex x
426− isComplex (Span _ (x:_)) = isComplex x
427− isComplex _ = False
420+ isComplex (Subscript _) = True
421+ isComplex (Link _ _ _) = True
422+ isComplex (Image _ _ _) = True
423+ isComplex (Code _ _) = True
424+ isComplex (Math _ _) = True
425+ isComplex (Cite _ (x:_)) = isComplex x
426+ isComplex (Span _ (x:_)) = isComplex x
427+ isComplex _ = False
428428
429429-- | Convert Pandoc inline element to RST.
430430inlineToRST :: Inline -> State WriterState Doc
@@ -485,9 +485,9 @@ inlineToRST Space = return space
485485inlineToRST SoftBreak = do
486486 wrapText <- gets $ writerWrapText . stOptions
487487 case wrapText of
488− WrapPreserve -> return cr
489− WrapAuto -> return space
490− WrapNone -> return space
488+ WrapPreserve -> return cr
489+ WrapAuto -> return space
490+ WrapNone -> return space
491491-- autolink
492492inlineToRST (Link _ [Str str] (src, _))
493493 | isURI src &&
src/Text/Pandoc/Writers/RTF.hs+18−18
@@ -30,24 +30,24 @@ Conversion of 'Pandoc' documents to RTF (rich text format).
3030-}
3131module Text.Pandoc.Writers.RTF ( writeRTF
3232 ) where
33+import Control.Monad.Except (catchError, throwError)
34+import qualified Data.ByteString as B
35+import Data.Char (chr, isDigit, ord)
36+import Data.List (intercalate, isSuffixOf)
37+import qualified Data.Map as M
38+import Text.Pandoc.Class (PandocMonad, report)
39+import qualified Text.Pandoc.Class as P
3340import Text.Pandoc.Definition
41+import Text.Pandoc.Error
42+import Text.Pandoc.ImageSize
43+import Text.Pandoc.Logging
3444import Text.Pandoc.Options
3545import Text.Pandoc.Shared
36−import Text.Pandoc.Writers.Shared
37−import Text.Pandoc.Writers.Math
3846import Text.Pandoc.Templates (renderTemplate')
3947import Text.Pandoc.Walk
40−import Text.Pandoc.Logging
41−import Data.List ( isSuffixOf, intercalate )
42−import Data.Char ( ord, chr, isDigit )
43−import qualified Data.ByteString as B
44−import qualified Data.Map as M
45−import Text.Printf ( printf )
46−import Text.Pandoc.ImageSize
47−import Control.Monad.Except (throwError, catchError)
48−import Text.Pandoc.Error
49−import Text.Pandoc.Class (PandocMonad, report)
50−import qualified Text.Pandoc.Class as P
48+import Text.Pandoc.Writers.Math
49+import Text.Pandoc.Writers.Shared
50+import Text.Printf (printf)
5151
5252-- | Convert Image inlines into a raw RTF embedded image, read from a file,
5353-- or a MediaBag, or the internet.
@@ -106,7 +106,7 @@ writeRTF options doc = do
106106 Pandoc meta@(Meta metamap) blocks <- walkM (rtfEmbedImage options) doc
107107 let spacer = not $ all null $ docTitle meta : docDate meta : docAuthors meta
108108 let toPlain (MetaBlocks [Para ils]) = MetaInlines ils
109− toPlain x = x
109+ toPlain x = x
110110 -- adjust title, author, date so we don't get para inside para
111111 let meta' = Meta $ M.adjust toPlain "title"
112112 . M.adjust toPlain "author"
@@ -118,7 +118,7 @@ writeRTF options doc = do
118118 meta'
119119 body <- blocksToRTF 0 AlignDefault blocks
120120 let isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options
121− isTOCHeader _ = False
121+ isTOCHeader _ = False
122122 toc <- tableOfContents $ filter isTOCHeader blocks
123123 let context = defField "body" body
124124 $ defField "spacer" spacer
@@ -193,9 +193,9 @@ rtfParSpaced :: Int -- ^ space after (in twips)
193193 -> String
194194rtfParSpaced spaceAfter indent firstLineIndent alignment content =
195195 let alignString = case alignment of
196− AlignLeft -> "\\ql "
197− AlignRight -> "\\qr "
198− AlignCenter -> "\\qc "
196+ AlignLeft -> "\\ql "
197+ AlignRight -> "\\qr "
198+ AlignCenter -> "\\qc "
199199 AlignDefault -> "\\ql "
200200 in "{\\pard " ++ alignString ++
201201 "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++
src/Text/Pandoc/Writers/Shared.hs+14−13
@@ -41,19 +41,20 @@ module Text.Pandoc.Writers.Shared (
4141 , unsmartify
4242 )
4343where
44−import Text.Pandoc.Definition
45−import Text.Pandoc.Pretty
46−import Text.Pandoc.Options
47−import Text.Pandoc.XML (escapeStringForXML)
4844import Control.Monad (liftM)
45+import Data.Aeson (FromJSON (..), Result (..), ToJSON (..), Value (Object),
46+ encode, fromJSON)
4947import qualified Data.HashMap.Strict as H
48+import Data.List (groupBy)
5049import qualified Data.Map as M
50+import Data.Maybe (isJust)
5151import qualified Data.Text as T
52−import Data.Aeson (FromJSON(..), fromJSON, ToJSON (..), Value(Object), Result(..), encode)
53−import Text.Pandoc.UTF8 (toStringLazy)
5452import qualified Data.Traversable as Traversable
55−import Data.List ( groupBy )
56−import Data.Maybe ( isJust )
53+import Text.Pandoc.Definition
54+import Text.Pandoc.Options
55+import Text.Pandoc.Pretty
56+import Text.Pandoc.UTF8 (toStringLazy)
57+import Text.Pandoc.XML (escapeStringForXML)
5758
5859-- | Create JSON value for template from a 'Meta' and an association list
5960-- of variables, specified at the command line or in the writer.
@@ -94,7 +95,7 @@ addVariablesToJSON opts metadata =
9495 (writerVariables opts)
9596 `combineMetadata` metadata
9697 where combineMetadata (Object o1) (Object o2) = Object $ H.union o1 o2
97− combineMetadata x _ = x
98+ combineMetadata x _ = x
9899
99100metaValueToJSON :: Monad m
100101 => ([Block] -> m String)
@@ -134,8 +135,8 @@ setField field val (Object hashmap) =
134135 Object $ H.insertWith combine (T.pack field) (toJSON val) hashmap
135136 where combine newval oldval =
136137 case fromJSON oldval of
137− Success xs -> toJSON $ xs ++ [newval]
138− _ -> toJSON [oldval, newval]
138+ Success xs -> toJSON $ xs ++ [newval]
139+ _ -> toJSON [oldval, newval]
139140setField _ _ x = x
140141
141142resetField :: ToJSON a
@@ -183,9 +184,9 @@ isDisplayMath _ = False
183184
184185stripLeadingTrailingSpace :: [Inline] -> [Inline]
185186stripLeadingTrailingSpace = go . reverse . go . reverse
186− where go (Space:xs) = xs
187+ where go (Space:xs) = xs
187188 go (SoftBreak:xs) = xs
188− go xs = xs
189+ go xs = xs
189190
190191-- Put display math in its own block (for ODT/DOCX).
191192fixDisplayMath :: Block -> Block
src/Text/Pandoc/Writers/TEI.hs+12−11
@@ -1,4 +1,5 @@
1−{-# LANGUAGE OverloadedStrings, PatternGuards #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE PatternGuards #-}
23{-
34Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu>
45
@@ -29,19 +30,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2930Conversion of 'Pandoc' documents to Docbook XML.
3031-}
3132module Text.Pandoc.Writers.TEI (writeTEI) where
33+import Data.Char (toLower)
34+import Data.List (isPrefixOf, stripPrefix)
35+import qualified Text.Pandoc.Builder as B
36+import Text.Pandoc.Class (PandocMonad)
3237import Text.Pandoc.Definition
33−import Text.Pandoc.XML
34−import Text.Pandoc.Shared
35−import Text.Pandoc.Writers.Shared
38+import Text.Pandoc.Highlighting (languages, languagesByExtension)
39+import Text.Pandoc.ImageSize
3640import Text.Pandoc.Options
37−import Text.Pandoc.Templates (renderTemplate')
38−import Data.List ( stripPrefix, isPrefixOf )
39−import Data.Char ( toLower )
40−import Text.Pandoc.Highlighting ( languages, languagesByExtension )
4141import Text.Pandoc.Pretty
42−import Text.Pandoc.ImageSize
43−import qualified Text.Pandoc.Builder as B
44−import Text.Pandoc.Class ( PandocMonad )
42+import Text.Pandoc.Shared
43+import Text.Pandoc.Templates (renderTemplate')
44+import Text.Pandoc.Writers.Shared
45+import Text.Pandoc.XML
4546
4647-- | Convert list of authors to a docbook <author> section
4748authorToTEI :: WriterOptions -> [Inline] -> B.Inlines
src/Text/Pandoc/Writers/Texinfo.hs+15−15
@@ -29,25 +29,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2929Conversion of 'Pandoc' format into Texinfo.
3030-}
3131module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where
32−import Text.Pandoc.Definition
33−import Text.Pandoc.Options
34−import Text.Pandoc.Shared
35−import Text.Pandoc.Writers.Shared
36−import Text.Pandoc.Templates (renderTemplate')
37−import Text.Printf ( printf )
38−import Data.List ( transpose, maximumBy )
39−import Data.Ord ( comparing )
40−import Data.Char ( chr, ord )
32+import Control.Monad.Except (throwError)
4133import Control.Monad.State
42−import Text.Pandoc.Pretty
43−import Text.Pandoc.ImageSize
44−import Network.URI ( isURI, unEscapeString )
45−import System.FilePath
34+import Data.Char (chr, ord)
35+import Data.List (maximumBy, transpose)
36+import Data.Ord (comparing)
4637import qualified Data.Set as Set
47−import Control.Monad.Except (throwError)
48−import Text.Pandoc.Error
38+import Network.URI (isURI, unEscapeString)
39+import System.FilePath
4940import Text.Pandoc.Class (PandocMonad, report)
41+import Text.Pandoc.Definition
42+import Text.Pandoc.Error
43+import Text.Pandoc.ImageSize
5044import Text.Pandoc.Logging
45+import Text.Pandoc.Options
46+import Text.Pandoc.Pretty
47+import Text.Pandoc.Shared
48+import Text.Pandoc.Templates (renderTemplate')
49+import Text.Pandoc.Writers.Shared
50+import Text.Printf (printf)
5151
5252data WriterState =
5353 WriterState { stStrikeout :: Bool -- document contains strikeout
src/Text/Pandoc/Writers/Textile.hs+18−18
@@ -30,18 +30,18 @@ Conversion of 'Pandoc' documents to Textile markup.
3030Textile: <http://thresholdstate.com/articles/4312/the-textile-reference-manual>
3131-}
3232module Text.Pandoc.Writers.Textile ( writeTextile ) where
33+import Control.Monad.State
34+import Data.Char (isSpace)
35+import Data.List (intercalate)
36+import Text.Pandoc.Class (PandocMonad)
3337import Text.Pandoc.Definition
38+import Text.Pandoc.ImageSize
3439import Text.Pandoc.Options
35−import Text.Pandoc.Shared
3640import Text.Pandoc.Pretty (render)
37−import Text.Pandoc.ImageSize
38−import Text.Pandoc.Writers.Shared
41+import Text.Pandoc.Shared
3942import Text.Pandoc.Templates (renderTemplate')
40−import Text.Pandoc.XML ( escapeStringForXML )
41−import Data.List ( intercalate )
42−import Control.Monad.State
43−import Data.Char ( isSpace )
44−import Text.Pandoc.Class ( PandocMonad )
43+import Text.Pandoc.Writers.Shared
44+import Text.Pandoc.XML (escapeStringForXML)
4545
4646data WriterState = WriterState {
4747 stNotes :: [String] -- Footnotes
@@ -302,16 +302,16 @@ isSimpleListItem :: [Block] -> Bool
302302isSimpleListItem [] = True
303303isSimpleListItem [x] =
304304 case x of
305− Plain _ -> True
306− Para _ -> True
307− BulletList _ -> isSimpleList x
308− OrderedList _ _ -> isSimpleList x
309− _ -> False
305+ Plain _ -> True
306+ Para _ -> True
307+ BulletList _ -> isSimpleList x
308+ OrderedList _ _ -> isSimpleList x
309+ _ -> False
310310isSimpleListItem [x, y] | isPlainOrPara x =
311311 case y of
312− BulletList _ -> isSimpleList y
313− OrderedList _ _ -> isSimpleList y
314− _ -> False
312+ BulletList _ -> isSimpleList y
313+ OrderedList _ _ -> isSimpleList y
314+ _ -> False
315315isSimpleListItem _ = False
316316
317317isPlainOrPara :: Block -> Bool
@@ -334,9 +334,9 @@ tableRowToTextile :: WriterOptions
334334tableRowToTextile opts alignStrings rownum cols' = do
335335 let celltype = if rownum == 0 then "th" else "td"
336336 let rowclass = case rownum of
337− 0 -> "header"
337+ 0 -> "header"
338338 x | x `rem` 2 == 1 -> "odd"
339− _ -> "even"
339+ _ -> "even"
340340 cols'' <- sequence $ zipWith
341341 (\alignment item -> tableItemToTextile opts celltype alignment item)
342342 alignStrings cols'
src/Text/Pandoc/Writers/ZimWiki.hs+22−22
@@ -31,27 +31,27 @@ http://zim-wiki.org/manual/Help/Wiki_Syntax.html
3131-}
3232
3333module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
34+import Control.Monad (zipWithM)
35+import Control.Monad.State (State, evalState, gets, modify)
36+import Data.Default (Default (..))
37+import Data.List (intercalate, isInfixOf, isPrefixOf, transpose)
38+import qualified Data.Map as Map
39+import Data.Text (breakOnAll, pack)
40+import Network.URI (isURI)
41+import Text.Pandoc.Class (PandocMonad)
3442import Text.Pandoc.Definition
35−import Text.Pandoc.Options ( WriterOptions(writerTableOfContents, writerTemplate, writerWrapText), WrapOption(..) )
36−import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting, trimr
37− , substitute )
38−import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
3943import Text.Pandoc.ImageSize
40−import Text.Pandoc.Templates ( renderTemplate' )
41−import Data.List ( intercalate, isPrefixOf, transpose, isInfixOf )
42−import Data.Text ( breakOnAll, pack )
43−import Data.Default (Default(..))
44−import Network.URI ( isURI )
45−import Control.Monad ( zipWithM )
46−import Control.Monad.State ( modify, State, gets, evalState )
47−import Text.Pandoc.Class ( PandocMonad )
48−import qualified Data.Map as Map
44+import Text.Pandoc.Options (WrapOption (..), WriterOptions (writerTableOfContents, writerTemplate, writerWrapText))
45+import Text.Pandoc.Shared (escapeURI, linesToPara, removeFormatting, substitute,
46+ trimr)
47+import Text.Pandoc.Templates (renderTemplate')
48+import Text.Pandoc.Writers.Shared (defField, metaToJSON)
4949
5050data WriterState = WriterState {
51− stItemNum :: Int,
52− stIndent :: String, -- Indent after the marker at the beginning of list items
53− stInTable :: Bool, -- Inside a table
54− stInLink :: Bool -- Inside a link description
51+ stItemNum :: Int,
52+ stIndent :: String, -- Indent after the marker at the beginning of list items
53+ stInTable :: Bool, -- Inside a table
54+ stInLink :: Bool -- Inside a link description
5555 }
5656
5757instance Default WriterState where
@@ -139,7 +139,7 @@ blockToZimWiki _ (CodeBlock (_,classes,_) str) = do
139139 (x:_) -> "{{{code: lang=\"" ++
140140 (case Map.lookup x langmap of
141141 Nothing -> x
142− Just y -> y) ++ "\" linenumbers=\"True\"\n" ++ str ++ "\n}}}\n" -- for zim's code plugin, go verbatim on the lang spec
142+ Just y -> y) ++ "\" linenumbers=\"True\"\n" ++ str ++ "\n}}}\n" -- for zim's code plugin, go verbatim on the lang spec
143143
144144blockToZimWiki opts (BlockQuote blocks) = do
145145 contents <- blockListToZimWiki opts blocks
@@ -319,7 +319,7 @@ inlineToZimWiki _ (Str str) = do
319319 inTable <- gets stInTable
320320 inLink <- gets stInLink
321321 if inTable
322− then return $ substitute "|" "\\|" . escapeString $ str
322+ then return $ substitute "|" "\\|" . escapeString $ str
323323 else
324324 if inLink
325325 then return $ str
@@ -371,10 +371,10 @@ inlineToZimWiki opts (Image attr alt (source, tit)) = do
371371 alt' <- inlineListToZimWiki opts alt
372372 inTable <- gets stInTable
373373 let txt = case (tit, alt, inTable) of
374− ("",[], _) -> ""
374+ ("",[], _) -> ""
375375 ("", _, False ) -> "|" ++ alt'
376376 (_ , _, False ) -> "|" ++ tit
377− (_ , _, True ) -> ""
377+ (_ , _, True ) -> ""
378378 -- Relative links fail isURI and receive a colon
379379 prefix = if isURI source then "" else ":"
380380 return $ "{{" ++ prefix ++ source ++ imageDims opts attr ++ txt ++ "}}"
@@ -389,7 +389,7 @@ imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height
389389 where
390390 toPx = fmap (showInPixel opts) . checkPct
391391 checkPct (Just (Percent _)) = Nothing
392− checkPct maybeDim = maybeDim
392+ checkPct maybeDim = maybeDim
393393 go (Just w) Nothing = "?" ++ w
394394 go (Just w) (Just h) = "?" ++ w ++ "x" ++ h
395395 go Nothing (Just h) = "?0x" ++ h
src/Text/Pandoc/XML.hs+9−9
@@ -36,18 +36,18 @@ module Text.Pandoc.XML ( escapeCharForXML,
3636 toEntities,
3737 fromEntities ) where
3838
39−import Text.Pandoc.Pretty
40−import Data.Char (ord, isAscii, isSpace)
39+import Data.Char (isAscii, isSpace, ord)
4140import Text.HTML.TagSoup.Entity (lookupEntity)
41+import Text.Pandoc.Pretty
4242
4343-- | Escape one character as needed for XML.
4444escapeCharForXML :: Char -> String
4545escapeCharForXML x = case x of
46− '&' -> "&amp;"
47− '<' -> "&lt;"
48− '>' -> "&gt;"
49− '"' -> "&quot;"
50− c -> [c]
46+ '&' -> "&amp;"
47+ '<' -> "&lt;"
48+ '>' -> "&gt;"
49+ '"' -> "&quot;"
50+ c -> [c]
5151
5252-- | Escape string as needed for XML. Entity references are not preserved.
5353escapeStringForXML :: String -> String
@@ -108,8 +108,8 @@ fromEntities ('&':xs) =
108108 (zs, ys) -> (zs,ys)
109109 ent' = case ent of
110110 '#':'X':ys -> '#':'x':ys -- workaround tagsoup bug
111− '#':_ -> ent
112− _ -> ent ++ ";"
111+ '#':_ -> ent
112+ _ -> ent ++ ";"
113113
114114fromEntities (x:xs) = x : fromEntities xs
115115fromEntities [] = []
test/Tests/Command.hs+15−16
@@ -1,21 +1,20 @@
11module Tests.Command (findPandoc, runTest, tests)
22where
33
4−import Tests.Helpers
5−import Test.Framework
6−import Test.Framework.Providers.HUnit
7−import Test.HUnit ( assertBool )
8−import System.FilePath ( (</>), takeDirectory, splitDirectories,
9− joinPath )
10−import System.Process
4+import Data.Algorithm.Diff
5+import Data.List (isSuffixOf)
6+import Prelude hiding (readFile)
117import System.Directory
128import System.Exit
9+import System.FilePath (joinPath, splitDirectories, takeDirectory, (</>))
10+import System.Process
11+import Test.Framework
12+import Test.Framework.Providers.HUnit
13+import Test.HUnit (assertBool)
14+import Tests.Helpers
1315import Text.Pandoc
14−import Data.Algorithm.Diff
15−import Prelude hiding ( readFile )
16−import qualified Text.Pandoc.UTF8 as UTF8
17−import Data.List (isSuffixOf)
1816import Text.Pandoc.Shared (trimr)
17+import qualified Text.Pandoc.UTF8 as UTF8
1918
2019-- | Run a test with normalize function, return True if test passed.
2120runTest :: String -- ^ Title of test
@@ -25,9 +24,9 @@ runTest :: String -- ^ Title of test
2524 -> Test
2625runTest testname cmd inp norm = testCase testname $ do
2726 let cmd' = cmd ++ " --quiet --data-dir ../data"
28− let findDynlibDir [] = Nothing
27+ let findDynlibDir [] = Nothing
2928 findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
30− findDynlibDir (_:xs) = findDynlibDir xs
29+ findDynlibDir (_:xs) = findDynlibDir xs
3130 let mbDynlibDir = findDynlibDir (reverse $ splitDirectories $
3231 takeDirectory $ takeWhile (/=' ') cmd)
3332 let dynlibEnv = case mbDynlibDir of
@@ -58,15 +57,15 @@ tests = buildTest $ do
5857
5958isCodeBlock :: Block -> Bool
6059isCodeBlock (CodeBlock _ _) = True
61−isCodeBlock _ = False
60+isCodeBlock _ = False
6261
6362extractCode :: Block -> String
6463extractCode (CodeBlock _ code) = code
65−extractCode _ = ""
64+extractCode _ = ""
6665
6766dropPercent :: String -> String
6867dropPercent ('%':xs) = dropWhile (== ' ') xs
69−dropPercent xs = xs
68+dropPercent xs = xs
7069
7170runCommandTest :: FilePath -> (Int, String) -> IO Test
7271runCommandTest pandocpath (num, code) = do
test/Tests/Helpers.hs+13−12
@@ -1,4 +1,5 @@
1−{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
1+{-# LANGUAGE FlexibleInstances #-}
2+{-# LANGUAGE TypeSynonymInstances #-}
23-- Utility functions for the test suite.
34
45module Tests.Helpers ( test
@@ -13,24 +14,24 @@ module Tests.Helpers ( test
1314 )
1415 where
1516
16−import Text.Pandoc.Definition
17−import Text.Pandoc.Builder (Inlines, Blocks, doc, plain)
18−import Text.Pandoc.Class
17+import Data.Algorithm.Diff
18+import qualified Data.Map as M
19+import System.Directory
20+import System.Environment.Executable (getExecutablePath)
21+import System.Exit
22+import System.FilePath
1923import Test.Framework
2024import Test.Framework.Providers.HUnit
2125import Test.Framework.Providers.QuickCheck2
2226import Test.HUnit (assertBool)
23−import Text.Pandoc.Shared (trimr)
27+import qualified Test.QuickCheck.Property as QP
28+import Text.Pandoc.Builder (Blocks, Inlines, doc, plain)
29+import Text.Pandoc.Class
30+import Text.Pandoc.Definition
2431import Text.Pandoc.Options
32+import Text.Pandoc.Shared (trimr)
2533import Text.Pandoc.Writers.Native (writeNative)
2634import Text.Printf
27−import System.Environment.Executable (getExecutablePath)
28−import qualified Test.QuickCheck.Property as QP
29−import Data.Algorithm.Diff
30−import qualified Data.Map as M
31−import System.Exit
32−import System.Directory
33−import System.FilePath
3435
3536test :: (ToString a, ToString b, ToString c)
3637 => (a -> b) -- ^ function to test
test/Tests/Old.hs+14−14
@@ -1,16 +1,16 @@
11module Tests.Old (tests) where
22
3−import Tests.Helpers hiding (test)
4−import Test.Framework (testGroup, Test )
5−import Test.Framework.Providers.HUnit
6−import Test.HUnit ( assertBool )
7−import System.IO ( openTempFile, stderr )
8−import System.Process ( runProcess, waitForProcess )
9−import System.FilePath ( (</>), (<.>), splitDirectories, joinPath )
3+import Data.Algorithm.Diff
4+import Prelude hiding (readFile)
105import System.Directory
116import System.Exit
12−import Data.Algorithm.Diff
13−import Prelude hiding ( readFile )
7+import System.FilePath (joinPath, splitDirectories, (<.>), (</>))
8+import System.IO (openTempFile, stderr)
9+import System.Process (runProcess, waitForProcess)
10+import Test.Framework (Test, testGroup)
11+import Test.Framework.Providers.HUnit
12+import Test.HUnit (assertBool)
13+import Tests.Helpers hiding (test)
1414import qualified Text.Pandoc.UTF8 as UTF8
1515
1616tests :: [Test]
@@ -187,10 +187,10 @@ fb2WriterTest title opts inputfile normfile =
187187 title (["-t", "fb2"]++opts) inputfile normfile
188188 where
189189 formatXML xml = splitTags $ zip xml (drop 1 xml)
190− splitTags [] = []
191− splitTags [end] = fst end : snd end : []
190+ splitTags [] = []
191+ splitTags [end] = fst end : snd end : []
192192 splitTags (('>','<'):rest) = ">\n" ++ splitTags rest
193− splitTags ((c,_):rest) = c : splitTags rest
193+ splitTags ((c,_):rest) = c : splitTags rest
194194 ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines
195195 startsWith tag str = all (uncurry (==)) $ zip tag str
196196
@@ -219,9 +219,9 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do
219219 let normPath = norm
220220 let options = ["--quiet", "--data-dir", ".." </> "data"] ++ [inpPath] ++ opts
221221 let cmd = pandocPath ++ " " ++ unwords options
222− let findDynlibDir [] = Nothing
222+ let findDynlibDir [] = Nothing
223223 findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
224− findDynlibDir (_:xs) = findDynlibDir xs
224+ findDynlibDir (_:xs) = findDynlibDir xs
225225 let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath)
226226 let dynlibEnv = case mbDynlibDir of
227227 Nothing -> []
test/Tests/Readers/Docx.hs+7−7
@@ -1,15 +1,15 @@
11module Tests.Readers.Docx (tests) where
22
3−import Text.Pandoc
4−import Tests.Helpers
5−import Test.Framework
6−import Test.HUnit (assertBool)
7−import Test.Framework.Providers.HUnit
3+import Codec.Archive.Zip
84import qualified Data.ByteString.Lazy as B
95import qualified Data.Map as M
10−import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
11−import Codec.Archive.Zip
6+import Test.Framework
7+import Test.Framework.Providers.HUnit
8+import Test.HUnit (assertBool)
9+import Tests.Helpers
10+import Text.Pandoc
1211import qualified Text.Pandoc.Class as P
12+import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
1313
1414-- We define a wrapper around pandoc that doesn't normalize in the
1515-- tests. Since we do our own normalization, we want to make sure
test/Tests/Readers/EPUB.hs+5−5
@@ -1,13 +1,13 @@
11module Tests.Readers.EPUB (tests) where
22
3−import Text.Pandoc.Options
3+import qualified Data.ByteString.Lazy as BL
44import Test.Framework
5−import Test.HUnit (assertBool)
65import Test.Framework.Providers.HUnit
7−import qualified Data.ByteString.Lazy as BL
8−import Text.Pandoc.Readers.EPUB
9−import Text.Pandoc.MediaBag (MediaBag, mediaDirectory)
6+import Test.HUnit (assertBool)
107import qualified Text.Pandoc.Class as P
8+import Text.Pandoc.MediaBag (MediaBag, mediaDirectory)
9+import Text.Pandoc.Options
10+import Text.Pandoc.Readers.EPUB
1111
1212getMediaBag :: FilePath -> IO MediaBag
1313getMediaBag fp = do
test/Tests/Readers/HTML.hs+2−3
@@ -1,12 +1,11 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.HTML (tests) where
33
4−import Text.Pandoc.Definition
54import Test.Framework
65import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
8−import Text.Pandoc.Builder
96import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
109
1110html :: String -> Pandoc
1211html = purely $ readHtml def
test/Tests/Readers/LaTeX.hs+2−3
@@ -1,12 +1,11 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.LaTeX (tests) where
33
4−import Text.Pandoc.Definition
54import Test.Framework
65import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
8−import Text.Pandoc.Builder
96import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
109
1110latex :: String -> Pandoc
1211latex = purely $ readLaTeX def{
test/Tests/Readers/Markdown.hs+2−3
@@ -1,12 +1,11 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.Markdown (tests) where
33
4−import Text.Pandoc.Definition
54import Test.Framework
65import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
8−import Text.Pandoc.Builder
96import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
109
1110markdown :: String -> Pandoc
1211markdown = purely $ readMarkdown def { readerExtensions =
test/Tests/Readers/Odt.hs+4−4
@@ -1,11 +1,11 @@
11module Tests.Readers.Odt (tests) where
22
3−import Control.Monad ( liftM )
4−import Text.Pandoc
5−import Tests.Helpers
6−import Test.Framework
3+import Control.Monad (liftM)
74import qualified Data.ByteString.Lazy as B
85import qualified Data.Map as M
6+import Test.Framework
7+import Tests.Helpers
8+import Text.Pandoc
99
1010defopts :: ReaderOptions
1111defopts = def{ readerExtensions = getDefaultExtensions "odt" }
test/Tests/Readers/Org.hs+3−4
@@ -1,16 +1,15 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.Org (tests) where
33
4−import Text.Pandoc.Definition
4+import Data.List (intersperse)
55import Test.Framework
66import Tests.Helpers
7−import Text.Pandoc.Builder
87import Text.Pandoc
9−import Data.List (intersperse)
8+import Text.Pandoc.Builder
109
1110org :: String -> Pandoc
1211org = purely $ readOrg def{ readerExtensions = getDefaultExtensions "org" }
13−
12+
1413orgSmart :: String -> Pandoc
1514orgSmart = purely $ readOrg def { readerExtensions =
1615 enableExtension Ext_smart $ getDefaultExtensions "org" }
test/Tests/Readers/RST.hs+4−4
@@ -1,12 +1,12 @@
1−{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
1+{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
23module Tests.Readers.RST (tests) where
34
4−import Text.Pandoc.Definition
55import Test.Framework
66import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
8−import Text.Pandoc.Builder
97import Text.Pandoc
8+import Text.Pandoc.Arbitrary ()
9+import Text.Pandoc.Builder
1010
1111rst :: String -> Pandoc
1212rst = purely $ readRST def{ readerStandalone = True }
test/Tests/Readers/Txt2Tags.hs+3−5
@@ -1,16 +1,14 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.Txt2Tags (tests) where
33
4−import Text.Pandoc.Definition
4+import Data.List (intersperse)
55import Test.Framework
66import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
8−import Text.Pandoc.Builder
97import Text.Pandoc
10−import Data.List (intersperse)
8+import Text.Pandoc.Arbitrary ()
9+import Text.Pandoc.Builder
1110import Text.Pandoc.Class
1211
13−
1412t2t :: String -> Pandoc
1513-- t2t = handleError . readTxt2Tags (T2TMeta "date" "mtime" "in" "out") def
1614t2t = purely $ \s -> do
test/Tests/Shared.hs+4−4
@@ -1,12 +1,12 @@
11module Tests.Shared (tests) where
22
3−import Text.Pandoc.Shared
3+import System.FilePath.Posix (joinPath)
44import Test.Framework
5−import Text.Pandoc.Arbitrary()
65import Test.Framework.Providers.HUnit
7−import Test.HUnit ( assertBool, (@?=) )
6+import Test.HUnit (assertBool, (@?=))
7+import Text.Pandoc.Arbitrary ()
88import Text.Pandoc.Builder
9−import System.FilePath.Posix (joinPath)
9+import Text.Pandoc.Shared
1010
1111tests :: [Test]
1212tests = [ testGroup "compactifyDL"
test/Tests/Writers/AsciiDoc.hs+3−3
@@ -1,10 +1,10 @@
11module Tests.Writers.AsciiDoc (tests) where
22
33import Test.Framework
4−import Text.Pandoc.Builder
5−import Text.Pandoc
64import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
5+import Text.Pandoc
6+import Text.Pandoc.Arbitrary ()
7+import Text.Pandoc.Builder
88
99asciidoc :: (ToPandoc a) => a -> String
1010asciidoc = purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc
test/Tests/Writers/ConTeXt.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.ConTeXt (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010context :: (ToPandoc a) => a -> String
1111context = purely (writeConTeXt def) . toPandoc
test/Tests/Writers/Docbook.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.Docbook (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010docbook :: (ToPandoc a) => a -> String
1111docbook = docbookWithOpts def{ writerWrapText = WrapNone }
test/Tests/Writers/Docx.hs+6−6
@@ -1,14 +1,14 @@
11module Tests.Writers.Docx (tests) where
22
3−import Text.Pandoc.Options
4−import Text.Pandoc.Readers.Native
5−import Text.Pandoc.Definition
6−import Tests.Helpers
3+import System.FilePath ((</>))
74import Test.Framework
5+import Tests.Helpers
6+import Text.Pandoc.Class (runIOorExplode)
7+import Text.Pandoc.Definition
8+import Text.Pandoc.Options
89import Text.Pandoc.Readers.Docx
10+import Text.Pandoc.Readers.Native
911import Text.Pandoc.Writers.Docx
10−import System.FilePath ((</>))
11−import Text.Pandoc.Class (runIOorExplode)
1212
1313type Options = (WriterOptions, ReaderOptions)
1414
test/Tests/Writers/HTML.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.HTML (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010html :: (ToPandoc a) => a -> String
1111html = purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc
test/Tests/Writers/Markdown.hs+3−3
@@ -3,10 +3,10 @@
33module Tests.Writers.Markdown (tests) where
44
55import Test.Framework
6−import Text.Pandoc.Builder
7−import Text.Pandoc
86import Tests.Helpers
9−import Text.Pandoc.Arbitrary()
7+import Text.Pandoc
8+import Text.Pandoc.Arbitrary ()
9+import Text.Pandoc.Builder
1010
1111defopts :: WriterOptions
1212defopts = def{ writerExtensions = pandocExtensions }
test/Tests/Writers/Native.hs+2−3
@@ -1,10 +1,9 @@
11module Tests.Writers.Native (tests) where
22
33import Test.Framework
4−import Text.Pandoc.Builder
5−import Text.Pandoc
64import Tests.Helpers
7−import Text.Pandoc.Arbitrary()
5+import Text.Pandoc
6+import Text.Pandoc.Arbitrary ()
87
98p_write_rt :: Pandoc -> Bool
109p_write_rt d =
test/Tests/Writers/Org.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.Org (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010infix 4 =:
1111(=:) :: (ToString a, ToPandoc a)
test/Tests/Writers/Plain.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.Plain (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010
1111infix 4 =:
test/Tests/Writers/RST.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.RST (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010infix 4 =:
1111(=:) :: (ToString a, ToPandoc a)
test/Tests/Writers/TEI.hs+3−3
@@ -2,10 +2,10 @@
22module Tests.Writers.TEI (tests) where
33
44import Test.Framework
5−import Text.Pandoc.Builder
6−import Text.Pandoc
75import Tests.Helpers
8−import Text.Pandoc.Arbitrary()
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
99
1010{-
1111 "my test" =: X =?> Y
test/test-pandoc.hs+13−13
@@ -2,34 +2,34 @@
22
33module Main where
44
5−import Test.Framework
65import GHC.IO.Encoding
7−import qualified Tests.Old
6+import System.Environment (getArgs)
7+import Test.Framework
88import qualified Tests.Command
9+import qualified Tests.Old
10+import qualified Tests.Readers.Docx
11+import qualified Tests.Readers.EPUB
12+import qualified Tests.Readers.HTML
913import qualified Tests.Readers.LaTeX
1014import qualified Tests.Readers.Markdown
15+import qualified Tests.Readers.Odt
1116import qualified Tests.Readers.Org
12−import qualified Tests.Readers.HTML
1317import qualified Tests.Readers.RST
14−import qualified Tests.Readers.Docx
15−import qualified Tests.Readers.Odt
1618import qualified Tests.Readers.Txt2Tags
17−import qualified Tests.Readers.EPUB
19+import qualified Tests.Shared
20+import qualified Tests.Writers.AsciiDoc
1821import qualified Tests.Writers.ConTeXt
19−import qualified Tests.Writers.LaTeX
20−import qualified Tests.Writers.HTML
2122import qualified Tests.Writers.Docbook
22−import qualified Tests.Writers.Native
23+import qualified Tests.Writers.Docx
24+import qualified Tests.Writers.HTML
25+import qualified Tests.Writers.LaTeX
2326import qualified Tests.Writers.Markdown
27+import qualified Tests.Writers.Native
2428import qualified Tests.Writers.Org
2529import qualified Tests.Writers.Plain
26−import qualified Tests.Writers.AsciiDoc
27−import qualified Tests.Writers.Docx
2830import qualified Tests.Writers.RST
2931import qualified Tests.Writers.TEI
30−import qualified Tests.Shared
3132import Text.Pandoc.Shared (inDirectory)
32−import System.Environment (getArgs)
3333
3434tests :: [Test]
3535tests = [ Tests.Command.tests