Skip to content

Commit 95cfe2b

Browse files
committed
use fmap
1 parent 59bd1bd commit 95cfe2b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Text/Pandoc/Readers/Markdown.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,11 +2393,11 @@ doubleQuoted = do
23932393
<|> (return (return (B.str "\8220")))
23942394

23952395
-- | Extract a block with a specific ID from a list of blocks
2396-
extractBlockById :: Text -> Blocks -> F Inlines
2396+
extractBlockById :: Text -> Blocks -> Inlines
23972397
extractBlockById targetId blocks =
23982398
case findBlockById targetId (B.toList blocks) of
2399-
Just block -> return $ blocksToInlines' [block]
2400-
Nothing -> return mempty
2399+
Just block -> blocksToInlines' [block]
2400+
Nothing -> mempty
24012401

24022402
-- | Find a block with a specific ID in a list of blocks
24032403
findBlockById :: Text -> [Block] -> Maybe Block
@@ -2412,11 +2412,11 @@ findBlockById targetId = go
24122412
_ -> go rest
24132413

24142414
-- | Extract content under a specific heading from a list of blocks
2415-
extractHeadingById :: Text -> Blocks -> F Inlines
2415+
extractHeadingById :: Text -> Blocks -> Inlines
24162416
extractHeadingById targetHeading blocks =
24172417
case extractContentUnderHeading targetHeading (B.toList blocks) of
2418-
[] -> return mempty
2419-
content -> return $ blocksToInlines' content
2418+
[] -> mempty
2419+
content -> blocksToInlines' content
24202420

24212421
-- | Parse a file and convert all blocks to inlines for transclusion
24222422
parseTranscludedInlines :: PandocMonad m => MarkdownParser m (F Inlines)
@@ -2428,13 +2428,13 @@ parseTranscludedInlines = do
24282428
parseBlockTransclusion :: PandocMonad m => Text -> MarkdownParser m (F Inlines)
24292429
parseBlockTransclusion blockId = do
24302430
blocks <- parseBlocks
2431-
return $ blocks >>= extractBlockById blockId
2431+
return $ fmap (extractBlockById blockId) blocks
24322432

24332433
-- | Parse a file and extract content under a specific heading for transclusion
24342434
parseHeadingTransclusion :: PandocMonad m => Text -> MarkdownParser m (F Inlines)
24352435
parseHeadingTransclusion headingText = do
24362436
blocks <- parseBlocks
2437-
return $ blocks >>= extractHeadingById headingText
2437+
return $ fmap (extractHeadingById headingText) blocks
24382438

24392439
-- | Extract all content under a heading until the next heading of same or higher level
24402440
extractContentUnderHeading :: Text -> [Block] -> [Block]

0 commit comments

Comments
 (0)