From 3982b23428f9ef8db82c7e360d9f2b896b531c86 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 13 Nov 2019 21:18:39 -0800 Subject: Markdown reader: don't parse footnote body unless extension enabled. --- src/Text/Pandoc/Readers/Markdown.hs | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/Text/Pandoc/Readers/Markdown.hs') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index f8349ea99..911105045 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -460,24 +460,26 @@ rawLines = do return $ T.unlines (first:rest) noteBlock :: PandocMonad m => MarkdownParser m (F Blocks) -noteBlock = try $ do - pos <- getPosition - skipNonindentSpaces - ref <- noteMarker - char ':' - optional blankline - optional indentSpaces - first <- rawLines - rest <- many $ try $ blanklines >> indentSpaces >> rawLines - let raw = T.unlines (first:rest) <> "\n" - optional blanklines - parsed <- parseFromString' parseBlocks raw - oldnotes <- stateNotes' <$> getState - case M.lookup ref oldnotes of - Just _ -> logMessage $ DuplicateNoteReference ref pos - Nothing -> return () - updateState $ \s -> s { stateNotes' = M.insert ref (pos, parsed) oldnotes } - return mempty +noteBlock = do + guardEnabled Ext_footnotes + do pos <- getPosition + skipNonindentSpaces + ref <- noteMarker + char ':' + optional blankline + optional indentSpaces + first <- rawLines + rest <- many $ try $ blanklines >> indentSpaces >> rawLines + let raw = T.unlines (first:rest) <> "\n" + optional blanklines + parsed <- parseFromString' parseBlocks raw + oldnotes <- stateNotes' <$> getState + case M.lookup ref oldnotes of + Just _ -> logMessage $ DuplicateNoteReference ref pos + Nothing -> return () + updateState $ \s -> s { stateNotes' = + M.insert ref (pos, parsed) oldnotes } + return mempty -- -- parsing blocks -- cgit v1.2.3