diff options
author | Joseph C. Sible <josephcsible@users.noreply.github.com> | 2020-03-30 00:11:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 21:11:05 -0700 |
commit | 377efd0ce7736685c2a43842743a11ae01ed0a0b (patch) | |
tree | fdb71f111bce17b9e8a5556c0f89739ac35eec16 | |
parent | 40fd20d43fc2431e411554c138cb6e7d15654917 (diff) | |
download | pandoc-377efd0ce7736685c2a43842743a11ae01ed0a0b.tar.gz |
Clean up some fmaps (#6226)
* Avoid fmapping when we're just binding right after anyway
* Clean up unnecessary fmaps in the LaTeX reader
-rw-r--r-- | src/Text/Pandoc/Lua/Module/MediaBag.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/DocBook.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/JATS.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 18 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 4 |
7 files changed, 22 insertions, 22 deletions
diff --git a/src/Text/Pandoc/Lua/Module/MediaBag.hs b/src/Text/Pandoc/Lua/Module/MediaBag.hs index 769f7e110..3a296ef46 100644 --- a/src/Text/Pandoc/Lua/Module/MediaBag.hs +++ b/src/Text/Pandoc/Lua/Module/MediaBag.hs @@ -85,7 +85,7 @@ insertMediaFn fp optionalMime contents = do -- | Returns iterator values to be used with a Lua @for@ loop. items :: Lua NumResults -items = stMediaBag <$> getCommonState >>= pushIterator +items = getCommonState >>= pushIterator . stMediaBag lookupMediaFn :: FilePath -> Lua NumResults diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 4bc5312d6..7f71cb3c1 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -758,8 +758,8 @@ parseBlock (Elem e) = "upperroman" -> UpperRoman _ -> Decimal let start = fromMaybe 1 $ - (attrValue "override" <$> filterElement (named "listitem") e) - >>= safeRead + filterElement (named "listitem") e + >>= safeRead . attrValue "override" orderedListWith (start,listStyle,DefaultDelim) <$> listitems "variablelist" -> definitionList <$> deflistitems diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs index 50e1e519a..597e798ab 100644 --- a/src/Text/Pandoc/Readers/JATS.hs +++ b/src/Text/Pandoc/Readers/JATS.hs @@ -164,9 +164,9 @@ parseBlock (Elem e) = "bullet" -> bulletList <$> listitems listType -> do let start = fromMaybe 1 $ - (textContent <$> (filterElement (named "list-item") e - >>= filterElement (named "label"))) - >>= safeRead + (filterElement (named "list-item") e + >>= filterElement (named "label")) + >>= safeRead . textContent orderedListWith (start, parseListStyleType listType, DefaultDelim) <$> listitems "def-list" -> definitionList <$> deflistitems diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index d16c67770..59339c606 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1018,16 +1018,16 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList , ("lstinline", dolstinline) , ("mintinline", domintinline) , ("Verb", doverb) - , ("url", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url -> - pure (link url "" (str url))) - , ("nolinkurl", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url -> - pure (code url)) - , ("href", (unescapeURL . untokenize <$> - bracedUrl <* sp) >>= \url -> - tok >>= \lab -> pure (link url "" lab)) + , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$> + bracedUrl) + , ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl) + , ("href", do url <- bracedUrl + sp + link (unescapeURL $ untokenize url) "" <$> tok) , ("includegraphics", do options <- option [] keyvals - src <- unescapeURL . removeDoubleQuotes . untokenize <$> braced - mkImage options src) + src <- braced + mkImage options . unescapeURL . removeDoubleQuotes $ + untokenize src) , ("enquote*", enquote True Nothing) , ("enquote", enquote False Nothing) -- foreignquote is supposed to use native quote marks diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 9fce8252c..c9643f1b0 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1339,8 +1339,8 @@ pipeTableRow = try $ do -- split into cells let chunk = void (code <|> math <|> rawHtmlInline <|> escapedChar <|> rawLaTeXInline') <|> void (noneOf "|\n\r") - let cellContents = ((trim . snd) <$> withRaw (many chunk)) >>= - parseFromString' pipeTableCell + let cellContents = withRaw (many chunk) >>= + parseFromString' pipeTableCell . trim . snd cells <- cellContents `sepEndBy1` char '|' -- surrounding pipes needed for a one-column table: guard $ not (length cells == 1 && not openPipe) diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index a3c44a8a1..bfaf12bc0 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -236,11 +236,11 @@ writeDocx opts doc@(Pandoc meta _) = do -- Gets the template size let mbpgsz = mbsectpr >>= filterElementName (wname (=="pgSz")) - let mbAttrSzWidth = (elAttribs <$> mbpgsz) >>= lookupAttrTextBy ((=="w") . qName) + let mbAttrSzWidth = mbpgsz >>= lookupAttrTextBy ((=="w") . qName) . elAttribs let mbpgmar = mbsectpr >>= filterElementName (wname (=="pgMar")) - let mbAttrMarLeft = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="left") . qName) - let mbAttrMarRight = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="right") . qName) + let mbAttrMarLeft = mbpgmar >>= lookupAttrTextBy ((=="left") . qName) . elAttribs + let mbAttrMarRight = mbpgmar >>= lookupAttrTextBy ((=="right") . qName) . elAttribs -- Get the available area (converting the size and the margins to int and -- doing the difference diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 304147bee..5c264aa30 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -360,9 +360,9 @@ beginsWithOrderedListMarker str = notesAndRefs :: PandocMonad m => WriterOptions -> MD m (Doc Text) notesAndRefs opts = do - notes' <- reverse <$> gets stNotes >>= notesToMarkdown opts + notes' <- gets stNotes >>= notesToMarkdown opts . reverse modify $ \s -> s { stNotes = [] } - refs' <- reverse <$> gets stRefs >>= refsToMarkdown opts + refs' <- gets stRefs >>= refsToMarkdown opts . reverse modify $ \s -> s { stPrevRefs = stPrevRefs s ++ stRefs s , stRefs = []} |