Skip to content

Commit d1aa352

Browse files
committed
use fmap
1 parent 5bcc12a commit d1aa352

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
@@ -2411,11 +2411,11 @@ doubleQuoted = do
24112411
<|> (return (return (B.str "\8220")))
24122412

24132413
-- | Extract a block with a specific ID from a list of blocks
2414-
extractBlockById :: Text -> Blocks -> F Inlines
2414+
extractBlockById :: Text -> Blocks -> Inlines
24152415
extractBlockById targetId blocks =
24162416
case findBlockById targetId (B.toList blocks) of
2417-
Just block -> return $ blocksToInlines' [block]
2418-
Nothing -> return mempty
2417+
Just block -> blocksToInlines' [block]
2418+
Nothing -> mempty
24192419

24202420
-- | Find a block with a specific ID in a list of blocks
24212421
findBlockById :: Text -> [Block] -> Maybe Block
@@ -2430,11 +2430,11 @@ findBlockById targetId = go
24302430
_ -> go rest
24312431

24322432
-- | Extract content under a specific heading from a list of blocks
2433-
extractHeadingById :: Text -> Blocks -> F Inlines
2433+
extractHeadingById :: Text -> Blocks -> Inlines
24342434
extractHeadingById targetHeading blocks =
24352435
case extractContentUnderHeading targetHeading (B.toList blocks) of
2436-
[] -> return mempty
2437-
content -> return $ blocksToInlines' content
2436+
[] -> mempty
2437+
content -> blocksToInlines' content
24382438

24392439
-- | Parse a file and convert all blocks to inlines for transclusion
24402440
parseTranscludedInlines :: PandocMonad m => MarkdownParser m (F Inlines)
@@ -2446,13 +2446,13 @@ parseTranscludedInlines = do
24462446
parseBlockTransclusion :: PandocMonad m => Text -> MarkdownParser m (F Inlines)
24472447
parseBlockTransclusion blockId = do
24482448
blocks <- parseBlocks
2449-
return $ blocks >>= extractBlockById blockId
2449+
return $ fmap (extractBlockById blockId) blocks
24502450

24512451
-- | Parse a file and extract content under a specific heading for transclusion
24522452
parseHeadingTransclusion :: PandocMonad m => Text -> MarkdownParser m (F Inlines)
24532453
parseHeadingTransclusion headingText = do
24542454
blocks <- parseBlocks
2455-
return $ blocks >>= extractHeadingById headingText
2455+
return $ fmap (extractHeadingById headingText) blocks
24562456

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

0 commit comments

Comments
 (0)