git.iko.soy/typeable/pandoc
on master help sign in
Clean up some fmaps (#6226)

* Avoid fmapping when we're just binding right after anyway * Clean up unnecessary fmaps in the LaTeX reader

commit377efd0ce7736685c2a43842743a11ae01ed0a0b authorJoseph C. Sible <josephcsible@users.noreply.github.com> dateMon 30 Mar 2020, 00:11 (7 years ago) parent40fd20d
7 files changed+22−22
src/Text/Pandoc/Lua/Module/MediaBag.hs+1−1 src/Text/Pandoc/Readers/DocBook.hs+2−2 src/Text/Pandoc/Readers/JATS.hs+3−3 src/Text/Pandoc/Readers/LaTeX.hs+9−9 src/Text/Pandoc/Readers/Markdown.hs+2−2 src/Text/Pandoc/Writers/Docx.hs+3−3 src/Text/Pandoc/Writers/Markdown.hs+2−2
src/Text/Pandoc/Lua/Module/MediaBag.hs+1−1
@@ -85,7 +85,7 @@ insertMediaFn fp optionalMime contents = do
8585
8686-- | Returns iterator values to be used with a Lua @for@ loop.
8787items :: Lua NumResults
88−items = stMediaBag <$> getCommonState >>= pushIterator
88+items = getCommonState >>= pushIterator . stMediaBag
8989
9090lookupMediaFn :: FilePath
9191 -> Lua NumResults
src/Text/Pandoc/Readers/DocBook.hs+2−2
@@ -758,8 +758,8 @@ parseBlock (Elem e) =
758758 "upperroman" -> UpperRoman
759759 _ -> Decimal
760760 let start = fromMaybe 1 $
761− (attrValue "override" <$> filterElement (named "listitem") e)
762− >>= safeRead
761+ filterElement (named "listitem") e
762+ >>= safeRead . attrValue "override"
763763 orderedListWith (start,listStyle,DefaultDelim)
764764 <$> listitems
765765 "variablelist" -> definitionList <$> deflistitems
src/Text/Pandoc/Readers/JATS.hs+3−3
@@ -164,9 +164,9 @@ parseBlock (Elem e) =
164164 "bullet" -> bulletList <$> listitems
165165 listType -> do
166166 let start = fromMaybe 1 $
167− (textContent <$> (filterElement (named "list-item") e
168− >>= filterElement (named "label")))
169− >>= safeRead
167+ (filterElement (named "list-item") e
168+ >>= filterElement (named "label"))
169+ >>= safeRead . textContent
170170 orderedListWith (start, parseListStyleType listType, DefaultDelim)
171171 <$> listitems
172172 "def-list" -> definitionList <$> deflistitems
src/Text/Pandoc/Readers/LaTeX.hs+9−9
@@ -1018,16 +1018,16 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
10181018 , ("lstinline", dolstinline)
10191019 , ("mintinline", domintinline)
10201020 , ("Verb", doverb)
1021− , ("url", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url ->
1022− pure (link url "" (str url)))
1023− , ("nolinkurl", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url ->
1024− pure (code url))
1025− , ("href", (unescapeURL . untokenize <$>
1026− bracedUrl <* sp) >>= \url ->
1027− tok >>= \lab -> pure (link url "" lab))
1021+ , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
1022+ bracedUrl)
1023+ , ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
1024+ , ("href", do url <- bracedUrl
1025+ sp
1026+ link (unescapeURL $ untokenize url) "" <$> tok)
10281027 , ("includegraphics", do options <- option [] keyvals
1029− src <- unescapeURL . removeDoubleQuotes . untokenize <$> braced
1030− mkImage options src)
1028+ src <- braced
1029+ mkImage options . unescapeURL . removeDoubleQuotes $
1030+ untokenize src)
10311031 , ("enquote*", enquote True Nothing)
10321032 , ("enquote", enquote False Nothing)
10331033 -- foreignquote is supposed to use native quote marks
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -1339,8 +1339,8 @@ pipeTableRow = try $ do
13391339 -- split into cells
13401340 let chunk = void (code <|> math <|> rawHtmlInline <|> escapedChar <|> rawLaTeXInline')
13411341 <|> void (noneOf "|\n\r")
1342− let cellContents = ((trim . snd) <$> withRaw (many chunk)) >>=
1343− parseFromString' pipeTableCell
1342+ let cellContents = withRaw (many chunk) >>=
1343+ parseFromString' pipeTableCell . trim . snd
13441344 cells <- cellContents `sepEndBy1` char '|'
13451345 -- surrounding pipes needed for a one-column table:
13461346 guard $ not (length cells == 1 && not openPipe)
src/Text/Pandoc/Writers/Docx.hs+3−3
@@ -236,11 +236,11 @@ writeDocx opts doc@(Pandoc meta _) = do
236236
237237 -- Gets the template size
238238 let mbpgsz = mbsectpr >>= filterElementName (wname (=="pgSz"))
239− let mbAttrSzWidth = (elAttribs <$> mbpgsz) >>= lookupAttrTextBy ((=="w") . qName)
239+ let mbAttrSzWidth = mbpgsz >>= lookupAttrTextBy ((=="w") . qName) . elAttribs
240240
241241 let mbpgmar = mbsectpr >>= filterElementName (wname (=="pgMar"))
242− let mbAttrMarLeft = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="left") . qName)
243− let mbAttrMarRight = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="right") . qName)
242+ let mbAttrMarLeft = mbpgmar >>= lookupAttrTextBy ((=="left") . qName) . elAttribs
243+ let mbAttrMarRight = mbpgmar >>= lookupAttrTextBy ((=="right") . qName) . elAttribs
244244
245245 -- Get the available area (converting the size and the margins to int and
246246 -- doing the difference
src/Text/Pandoc/Writers/Markdown.hs+2−2
@@ -360,9 +360,9 @@ beginsWithOrderedListMarker str =
360360
361361notesAndRefs :: PandocMonad m => WriterOptions -> MD m (Doc Text)
362362notesAndRefs opts = do
363− notes' <- reverse <$> gets stNotes >>= notesToMarkdown opts
363+ notes' <- gets stNotes >>= notesToMarkdown opts . reverse
364364 modify $ \s -> s { stNotes = [] }
365− refs' <- reverse <$> gets stRefs >>= refsToMarkdown opts
365+ refs' <- gets stRefs >>= refsToMarkdown opts . reverse
366366 modify $ \s -> s { stPrevRefs = stPrevRefs s ++ stRefs s
367367 , stRefs = []}
368368