aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2020-11-07 19:38:03 +0100
committerGitHub <noreply@github.com>2020-11-07 10:38:03 -0800
commit527346cc7e2bc874092be2f6793001860e10a719 (patch)
tree7c26c03a30f00f63c340d98cebdadd2f6408df21 /src/Text/Pandoc/Writers
parent0ed3436588951d457eefb11351f72d3560bdc544 (diff)
downloadpandoc-527346cc7e2bc874092be2f6793001860e10a719.tar.gz
Lint code in PRs and when committing to master (#6790)
* Remove unused LANGUAGE pragmata * Apply HLint suggestions * Configure HLint to ignore some warnings * Lint code when committing to master
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/CslJson.hs6
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs2
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs11
-rw-r--r--src/Text/Pandoc/Writers/JATS.hs2
-rw-r--r--src/Text/Pandoc/Writers/Jira.hs2
-rw-r--r--src/Text/Pandoc/Writers/Ms.hs4
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs2
-rw-r--r--src/Text/Pandoc/Writers/Roff.hs2
8 files changed, 16 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Writers/CslJson.hs b/src/Text/Pandoc/Writers/CslJson.hs
index 68cdb19fb..08310de65 100644
--- a/src/Text/Pandoc/Writers/CslJson.hs
+++ b/src/Text/Pandoc/Writers/CslJson.hs
@@ -34,15 +34,15 @@ import Control.Monad.Identity
import Citeproc.Locale (getLocale)
import Citeproc.CslJson
import Text.Pandoc.Options (WriterOptions)
-import Data.Maybe (fromMaybe, mapMaybe)
+import Data.Maybe (mapMaybe)
import Data.Aeson.Encode.Pretty (Config (..), Indent (Spaces),
NumberFormat (Generic),
defConfig, encodePretty')
writeCslJson :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeCslJson _opts (Pandoc meta _) = do
- let lang = fromMaybe (Lang "en" (Just "US")) $
- parseLang <$> (lookupMeta "lang" meta >>= metaValueToText)
+ let lang = maybe (Lang "en" (Just "US")) parseLang
+ (lookupMeta "lang" meta >>= metaValueToText)
locale <- case getLocale lang of
Left e -> throwError $ PandocCiteprocError e
Right l -> return l
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
index 441684682..701ff3d9b 100644
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -83,7 +83,7 @@ pandocToFB2 opts (Pandoc meta blocks) = do
secs <- renderSections 1 blocks
let body = el "body" $ el "title" (el "p" title) : secs
notes <- renderFootnotes
- (imgs,missing) <- fmap imagesToFetch get >>= \s -> lift (fetchImages s)
+ (imgs,missing) <- get >>= (lift . fetchImages . imagesToFetch)
let body' = replaceImagesWithAlt missing body
let fb2_xml = el "FictionBook" (fb2_attrs, [desc, body'] ++ notes ++ imgs)
return $ pack $ xml_head ++ showContent fb2_xml ++ "\n"
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index bac720c66..c92131d5a 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -314,7 +314,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
"/*]]>*/\n")
| otherwise -> mempty
Nothing -> mempty
- let mCss :: Maybe [Text] = lookupContext "css" $ metadata
+ let mCss :: Maybe [Text] = lookupContext "css" metadata
let context = (if stHighlighting st
then case writerHighlightStyle opts of
Just sty -> defField "highlighting-css"
@@ -1290,8 +1290,9 @@ inlineToHtml opts inline = do
| any ((=="cite") . fst) kvs
-> (Just attr, cs)
cs -> (Nothing, cs)
- H.q `fmap` inlineListToHtml opts lst'
- >>= maybe return (addAttrs opts) maybeAttr
+ let addAttrsMb = maybe return (addAttrs opts)
+ inlineListToHtml opts lst' >>=
+ addAttrsMb maybeAttr . H.q
else (\x -> leftQuote >> x >> rightQuote)
`fmap` inlineListToHtml opts lst
(Math t str) -> do
@@ -1468,8 +1469,8 @@ cslEntryToHtml :: PandocMonad m
cslEntryToHtml opts (Para xs) = do
html5 <- gets stHtml5
let inDiv :: Text -> Html -> Html
- inDiv cls x = ((if html5 then H5.div else H.div)
- x ! A.class_ (toValue cls))
+ inDiv cls x = (if html5 then H5.div else H.div)
+ x ! A.class_ (toValue cls)
let go (Span ("",[cls],[]) ils)
| cls == "csl-block" || cls == "csl-left-margin" ||
cls == "csl-right-inline" || cls == "csl-indent"
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs
index 4dc02d686..f2820a501 100644
--- a/src/Text/Pandoc/Writers/JATS.hs
+++ b/src/Text/Pandoc/Writers/JATS.hs
@@ -108,7 +108,7 @@ docToJATS opts (Pandoc meta blocks) = do
(fmap chomp . inlinesToJATS opts)
meta
main <- fromBlocks bodyblocks
- notes <- reverse . map snd <$> gets jatsNotes
+ notes <- gets (reverse . map snd . jatsNotes)
backs <- fromBlocks backblocks
tagSet <- ask
-- In the "Article Authoring" tag set, occurrence of fn-group elements
diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs
index 4f12667d4..6bc048a61 100644
--- a/src/Text/Pandoc/Writers/Jira.hs
+++ b/src/Text/Pandoc/Writers/Jira.hs
@@ -194,7 +194,7 @@ toJiraInlines inlines = do
Jira.Monospaced (escapeSpecialChars cs)
Emph xs -> styled Jira.Emphasis xs
Underline xs -> styled Jira.Insert xs
- Image attr cap tgt -> imageToJira attr cap (fst tgt) (snd tgt)
+ Image attr cap tgt -> uncurry (imageToJira attr cap) tgt
LineBreak -> pure . singleton $ Jira.Linebreak
Link attr xs tgt -> toJiraLink attr tgt xs
Math mtype cs -> mathToJira mtype cs
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index dbf7a3d79..96914d3c6 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -489,8 +489,8 @@ cslEntryToMs atStart opts (Para xs) =
| otherwise
-> case xs of
[] -> return mempty
- (x:rest) -> (<>) <$> (inlineToMs opts x)
- <*> (cslEntryToMs False opts (Para rest))
+ (x:rest) -> (<>) <$> inlineToMs opts x
+ <*> cslEntryToMs False opts (Para rest)
cslEntryToMs _ opts x = blockToMs opts x
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 5d742b5c6..8f010d766 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -601,7 +601,7 @@ inlineToOpenDocument o ils
formatOpenDocument _fmtOpts = map (map toHlTok)
toHlTok :: Token -> Doc Text
toHlTok (toktype,tok) =
- inTags False "text:span" [("text:style-name", (T.pack $ show toktype))] $ preformatted tok
+ inTags False "text:span" [("text:style-name", T.pack $ show toktype)] $ preformatted tok
unhighlighted s = inlinedCode $ preformatted s
preformatted s = handleSpaces $ escapeStringForXML s
inlinedCode s = return $ inTags False "text:span" [("text:style-name", "Source_Text")] s
diff --git a/src/Text/Pandoc/Writers/Roff.hs b/src/Text/Pandoc/Writers/Roff.hs
index 9dd8f8008..00b027cc9 100644
--- a/src/Text/Pandoc/Writers/Roff.hs
+++ b/src/Text/Pandoc/Writers/Roff.hs
@@ -90,7 +90,7 @@ escapeString e = Text.concat . escapeString' e . Text.unpack
AllowUTF8 -> Text.singleton x : escapeString' escapeMode xs
AsciiOnly ->
let accents = catMaybes $ takeWhile isJust
- (map (\c -> Map.lookup c combiningAccentsMap) xs)
+ (map (`Map.lookup` combiningAccentsMap) xs)
rest = drop (length accents) xs
s = case Map.lookup x characterCodeMap of
Just t -> "\\[" <> Text.unwords (t:accents) <> "]"