From 377efd0ce7736685c2a43842743a11ae01ed0a0b Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Mon, 30 Mar 2020 00:11:05 -0400 Subject: Clean up some fmaps (#6226) * Avoid fmapping when we're just binding right after anyway * Clean up unnecessary fmaps in the LaTeX reader --- src/Text/Pandoc/Readers/DocBook.hs | 4 ++-- src/Text/Pandoc/Readers/JATS.hs | 6 +++--- src/Text/Pandoc/Readers/LaTeX.hs | 18 +++++++++--------- src/Text/Pandoc/Readers/Markdown.hs | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/Readers') 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) -- cgit v1.2.3