aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-08-27 10:15:00 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-08-27 10:15:00 -0700
commit167fc4bc8732b72cccda0c37139fee3ab94b05cb (patch)
tree268d1a3331f560d046cd67a2f58c838b3b63b069 /src/Text
parent7c03c26d58f092b082f815d8a7f3e09f8e6abd28 (diff)
downloadpandoc-167fc4bc8732b72cccda0c37139fee3ab94b05cb.tar.gz
Markdown reader: Headers: don't parse content over newline boundary.
Closes #5714.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index d688e3d1d..e626321e6 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -532,8 +532,13 @@ atxHeader = try $ do
(char '.' <|> char ')') -- this would be a list
guardDisabled Ext_space_in_atx_header <|> notFollowedBy nonspaceChar
skipSpaces
- (text, raw) <- withRaw $
- trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)
+ (text, raw) <- withRaw $ do
+ oldAllowLineBreaks <- stateAllowLineBreaks <$> getState
+ updateState $ \st -> st{ stateAllowLineBreaks = False }
+ res <- trimInlinesF . mconcat <$>
+ many (notFollowedBy atxClosing >> inline)
+ updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }
+ return res
attr <- atxClosing
attr' <- registerHeader attr (runF text defaultParserState)
guardDisabled Ext_implicit_header_references
@@ -576,8 +581,13 @@ setextHeader = try $ do
-- unless necessary -- it gives a significant performance boost.
lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline
skipSpaces
- (text, raw) <- withRaw $
- trimInlinesF . mconcat <$> many1 (notFollowedBy setextHeaderEnd >> inline)
+ (text, raw) <- withRaw $ do
+ oldAllowLineBreaks <- stateAllowLineBreaks <$> getState
+ updateState $ \st -> st{ stateAllowLineBreaks = False }
+ res <- trimInlinesF . mconcat <$>
+ many (notFollowedBy setextHeaderEnd >> inline)
+ updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }
+ return res
attr <- setextHeaderEnd
underlineChar <- oneOf setextHChars
many (char underlineChar)
@@ -1730,6 +1740,7 @@ endline :: PandocMonad m => MarkdownParser m (F Inlines)
endline = try $ do
newline
notFollowedBy blankline
+ getState >>= guard . stateAllowLineBreaks
-- parse potential list-starts differently if in a list:
notFollowedBy (inList >> listStart)
guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart