summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-10-15 11:23:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2022-10-15 11:43:56 -0700
commit1195f5bb3b86608af6c711893b104d5049ebcd01 (patch)
treedde999bea6c0796d02ec03f608e08b9e979f07d3 /src/Text
parent8a21aa8142fdd15af7b7dd454b141861cf11d877 (diff)
Minor code cleanups.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App.hs2
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs2
-rw-r--r--src/Text/Pandoc/App/OutputSettings.hs4
-rw-r--r--src/Text/Pandoc/Citeproc/Name.hs1
-rw-r--r--src/Text/Pandoc/Data.hs2
-rw-r--r--src/Text/Pandoc/Format.hs2
-rw-r--r--src/Text/Pandoc/Parsing/GridTable.hs4
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs5
-rw-r--r--src/Text/Pandoc/Readers/Org.hs1
-rw-r--r--src/Text/Pandoc/Readers/RTF.hs4
-rw-r--r--src/Text/Pandoc/Translations.hs2
-rw-r--r--src/Text/Pandoc/URI.hs3
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs3
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs6
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs3
-rw-r--r--src/Text/Pandoc/Writers/JATS/References.hs12
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs2
-rw-r--r--src/Text/Pandoc/Writers/Markdown/Types.hs1
-rw-r--r--src/Text/Pandoc/Writers/Native.hs1
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs5
-rw-r--r--src/Text/Pandoc/Writers/XWiki.hs3
21 files changed, 29 insertions, 39 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 1290fc1c5..b0be5a032 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 5142ab3b2..2acfba75f 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -1,11 +1,9 @@
{-# LANGUAGE CPP #-}
-{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TypeApplications #-}
{- |
Module : Text.Pandoc.App.CommandLineOptions
Copyright : Copyright (C) 2006-2022 John MacFarlane
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 2499832ba..d38618198 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -191,8 +191,8 @@ optToOutputSettings scriptingEngine opts = do
>>=
maybe return (setVariableM "title-prefix") (optTitlePrefix opts)
>>=
- maybe return (setVariableM "epub-cover-image")
- (T.pack <$> optEpubCoverImage opts)
+ maybe return (setVariableM "epub-cover-image" . T.pack)
+ (optEpubCoverImage opts)
>>=
setVariableM "curdir" (T.pack curdir)
>>=
diff --git a/src/Text/Pandoc/Citeproc/Name.hs b/src/Text/Pandoc/Citeproc/Name.hs
index 73695a2ab..2f9e4558d 100644
--- a/src/Text/Pandoc/Citeproc/Name.hs
+++ b/src/Text/Pandoc/Citeproc/Name.hs
@@ -1,5 +1,4 @@
{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
diff --git a/src/Text/Pandoc/Data.hs b/src/Text/Pandoc/Data.hs
index 712b53f8e..8a8b51e60 100644
--- a/src/Text/Pandoc/Data.hs
+++ b/src/Text/Pandoc/Data.hs
@@ -1,5 +1,7 @@
{-# LANGUAGE CPP #-}
+#ifdef EMBED_DATA_FILES
{-# LANGUAGE TemplateHaskell #-}
+#endif
{- |
Module : Text.Pandoc.Data
Copyright : Copyright (C) 2013-2022 John MacFarlane
diff --git a/src/Text/Pandoc/Format.hs b/src/Text/Pandoc/Format.hs
index 3fa044d05..be1c32f02 100644
--- a/src/Text/Pandoc/Format.hs
+++ b/src/Text/Pandoc/Format.hs
@@ -115,7 +115,7 @@ parseFlavoredFormat spec =
return ( T.pack name, extsDiff )
parseFormatName = many1 $ noneOf "-+"
(prefix, spec') = case splitExtension (T.unpack spec) of
- (_, "") -> ("", T.toLower $ spec) -- no extension
+ (_, "") -> ("", T.toLower spec) -- no extension
(p,s) -> (T.pack p, T.pack s)
pExtensionsDiff :: Stream s m Char => ParsecT s u m ExtensionsDiff
diff --git a/src/Text/Pandoc/Parsing/GridTable.hs b/src/Text/Pandoc/Parsing/GridTable.hs
index d579939b5..88c592477 100644
--- a/src/Text/Pandoc/Parsing/GridTable.hs
+++ b/src/Text/Pandoc/Parsing/GridTable.hs
@@ -155,7 +155,7 @@ gridTableWith' normalization blocks = do
in [B.Row nullAttr cells | not (null cells) &&
not (all simple cells)]
_ -> hRows
- let tfoot = B.TableFoot B.nullAttr $ fRows
+ let tfoot = B.TableFoot B.nullAttr fRows
let tbody = B.TableBody B.nullAttr 0 [] bRows
return $ TableComponents nullAttr caption colspecs thead [tbody] tfoot
@@ -181,7 +181,7 @@ convAlign GT.AlignDefault = B.AlignDefault
fractionalColumnWidths :: GT.ArrayTable a -> Int -> [Double]
fractionalColumnWidths gt charColumns =
- let widths = map ((+1) . snd) $ -- include width of separator
+ let widths = map ((+1) . snd) -- include width of separator
(elems $ GT.arrayTableColSpecs gt)
norm = fromIntegral $ max (sum widths + length widths - 2) charColumns
in map (\w -> fromIntegral w / norm) widths
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 956e8b225..2cd57d6fa 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{- |
@@ -280,12 +281,12 @@ rowsToRowspans rows = let
-> Maybe Integer -- Number of columns left below
-> Maybe [(Int, Cell)] -- (rowspan so far, cell) for the row below this one
-> [(Int, Cell)] -- (rowspan so far, cell) for this row
- g cells _ Nothing = zip (repeat 1) cells
+ g cells _ Nothing = map (1,) cells
g cells columnsLeftBelow (Just rowBelow) =
case cells of
[] -> []
thisCell@(Cell thisGridSpan _ _) : restOfRow -> case rowBelow of
- [] -> zip (repeat 1) cells
+ [] -> map (1,) cells
(spanSoFarBelow, Cell gridSpanBelow vmerge _) : _ ->
let spanSoFar = case vmerge of
Restart -> 1
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 17011f657..176e0412f 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
{- |
Module : Text.Pandoc.Readers.Org
Copyright : Copyright (C) 2014-2022 Albert Krewinkel
diff --git a/src/Text/Pandoc/Readers/RTF.hs b/src/Text/Pandoc/Readers/RTF.hs
index c29a33b32..5931ca242 100644
--- a/src/Text/Pandoc/Readers/RTF.hs
+++ b/src/Text/Pandoc/Readers/RTF.hs
@@ -251,7 +251,7 @@ tok = do
hyph <- option False $ True <$ char '-'
rest <- many digit
if null rest
- then return $! Nothing
+ then return Nothing
else do
let pstr = T.pack rest
case TR.decimal pstr of
@@ -259,7 +259,7 @@ tok = do
return $! Just $! if hyph
then (-1) * i
else i
- _ -> return $! Nothing
+ _ -> return Nothing
hexVal = do
char '\''
x <- hexDigit
diff --git a/src/Text/Pandoc/Translations.hs b/src/Text/Pandoc/Translations.hs
index 00880da46..91bc25b95 100644
--- a/src/Text/Pandoc/Translations.hs
+++ b/src/Text/Pandoc/Translations.hs
@@ -1,6 +1,4 @@
{-# LANGUAGE CPP #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{- |
Module : Text.Pandoc.Translations
diff --git a/src/Text/Pandoc/URI.hs b/src/Text/Pandoc/URI.hs
index 39abdfe43..345ada768 100644
--- a/src/Text/Pandoc/URI.hs
+++ b/src/Text/Pandoc/URI.hs
@@ -16,13 +16,12 @@ module Text.Pandoc.URI ( urlEncode
, schemes
, uriPathToPath
) where
-import Network.URI (URI (uriScheme), parseURI)
import qualified Network.HTTP.Types as HTTP
import qualified Text.Pandoc.UTF8 as UTF8
import qualified Data.Text as T
import qualified Data.Set as Set
import Data.Char (isSpace)
-import Network.URI (escapeURIString)
+import Network.URI (URI (uriScheme), parseURI, escapeURIString)
urlEncode :: T.Text -> T.Text
urlEncode = UTF8.toText . HTTP.urlEncode True . UTF8.fromText
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 5adf1efcb..bd01cb4a2 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -35,7 +35,6 @@ import qualified Data.Text.Lazy as TL
import Data.Time.Clock.POSIX
import Data.Digest.Pure.SHA (sha1, showDigest)
import Skylighting
-import Text.Collate.Lang (renderLang)
import Text.Pandoc.Class (PandocMonad, report, toLang, getMediaBag)
import Text.Pandoc.Translations (translateTerm)
import Text.Pandoc.MediaBag (lookupMedia, MediaItem(..))
@@ -64,7 +63,7 @@ import Text.TeXMath
import Text.Pandoc.Writers.OOXML
import Text.Pandoc.XML.Light as XML
import Data.Generics (mkT, everywhere)
-import Text.Collate.Lang (Lang(..))
+import Text.Collate.Lang (renderLang, Lang(..))
squashProps :: EnvProps -> [Element]
squashProps (EnvProps Nothing es) = es
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 2673735cb..68e231c3a 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -1221,8 +1221,10 @@ modifyMediaRef oldsrc = do
Just (n,_) -> return $ T.pack n
Nothing -> catchError
(do (img, mbMime) <- P.fetchItem $ T.pack oldsrc
- let ext = maybe (takeExtension (takeWhile (/='?') oldsrc)) T.unpack
- (("." <>) <$> (mbMime >>= extensionFromMimeType))
+ let ext = maybe
+ (takeExtension (takeWhile (/='?') oldsrc))
+ (T.unpack . ("." <>))
+ (mbMime >>= extensionFromMimeType)
newName <- getMediaNextNewName ext
let newPath = "media/" ++ newName
entry <- mkEntry newPath (B.fromChunks . (:[]) $ img)
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index e0ef8da04..22f5b1368 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -44,7 +44,6 @@ import Text.DocLayout (render, literal, Doc)
import Text.Blaze.Internal (MarkupM (Empty), customLeaf, customParent)
import Text.DocTemplates (FromContext (lookupContext), Context (..))
import Text.Blaze.Html hiding (contents)
-import Text.Pandoc.Translations (Term(Abstract))
import Text.Pandoc.CSS (cssAttributes)
import Text.Pandoc.Definition
import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtml4Block,
@@ -69,7 +68,7 @@ import Text.Blaze.Html.Renderer.Text (renderHtml)
import qualified Text.Blaze.XHtml1.Transitional as H
import qualified Text.Blaze.XHtml1.Transitional.Attributes as A
import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
-import Text.Pandoc.Translations (translateTerm)
+import Text.Pandoc.Translations (Term(Abstract), translateTerm)
import Text.Pandoc.Class.PandocPure (runPure)
import Text.Pandoc.Error
import Text.Pandoc.Logging
diff --git a/src/Text/Pandoc/Writers/JATS/References.hs b/src/Text/Pandoc/Writers/JATS/References.hs
index 720299f05..4bbca71cb 100644
--- a/src/Text/Pandoc/Writers/JATS/References.hs
+++ b/src/Text/Pandoc/Writers/JATS/References.hs
@@ -147,13 +147,11 @@ fourDigits :: Int -> Text
fourDigits n = T.takeEnd 4 $ "000" <> tshow n
toNameElements :: Name -> Doc Text
-toNameElements name =
- if not (isEmpty nameTags)
- then inTags' "name" [] nameTags
- else if nameLiteral name == Just "others" -- indicates an "et al."
- then "<etal/>"
- else nameLiteral name `inNameTag` "string-name"
- where
+toNameElements name
+ | not (isEmpty nameTags) = inTags' "name" [] nameTags
+ | nameLiteral name == Just "others" = "<etal/>"
+ | otherwise = nameLiteral name `inNameTag` "string-name"
+ where
inNameTag mVal tag = case mVal of
Nothing -> empty
Just val -> inTags' tag [] . literal $ escapeStringForXML val
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 7b21bbcdd..3dfba2b3f 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -961,7 +961,7 @@ inlineToLaTeX (Image attr@(_,_,kvs) _ (source, _)) = do
optList = showDim Width <> showDim Height <>
maybe [] (\x -> ["page=" <> literal x]) (lookup "page" kvs) <>
maybe [] (\x -> ["trim=" <> literal x]) (lookup "trim" kvs) <>
- maybe [] (\_ -> ["clip"]) (lookup "clip" kvs)
+ maybe [] (const ["clip"]) (lookup "clip" kvs)
options = if null optList
then empty
else brackets $ mconcat (intersperse "," optList)
diff --git a/src/Text/Pandoc/Writers/Markdown/Types.hs b/src/Text/Pandoc/Writers/Markdown/Types.hs
index 7a1d252bc..48eace517 100644
--- a/src/Text/Pandoc/Writers/Markdown/Types.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Types.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
{- |
Module : Text.Pandoc.Writers.Markdown.Types
Copyright : Copyright (C) 2006-2022 John MacFarlane
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
index b83ce1688..dded397ca 100644
--- a/src/Text/Pandoc/Writers/Native.hs
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
{- |
Module : Text.Pandoc.Writers.Native
Copyright : Copyright (C) 2006-2022 John MacFarlane
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 64cd85997..3fe643e63 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -245,8 +245,9 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
-- the number of columns will be used in case of even widths
let numcols = maximum (length aligns :| length widths :
map length (headers:rows))
- let officialWidthsInChars widths' = map (
- (\x -> if x < 1 then 1 else x) .
+ let officialWidthsInChars :: [Double] -> [Int]
+ officialWidthsInChars widths' = map (
+ (max 1) .
(\x -> x - 3) . floor .
(fromIntegral (writerColumns opts) *)
) widths'
diff --git a/src/Text/Pandoc/Writers/XWiki.hs b/src/Text/Pandoc/Writers/XWiki.hs
index 78e0d29e6..eb6a17aab 100644
--- a/src/Text/Pandoc/Writers/XWiki.hs
+++ b/src/Text/Pandoc/Writers/XWiki.hs
@@ -43,9 +43,8 @@ import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Shared
import Text.Pandoc.Writers.MediaWiki (highlightingLangs)
-import Text.Pandoc.Writers.Shared (toLegacyTable)
import Text.Pandoc.Templates (renderTemplate)
-import Text.Pandoc.Writers.Shared (defField, metaToContext)
+import Text.Pandoc.Writers.Shared (defField, metaToContext, toLegacyTable)
import Text.DocLayout (render, literal)
newtype WriterState = WriterState {