@@ -532,8 +532,13 @@ atxHeader = try $ do
532 (char '.' <|> char ')') -- this would be a list
532 (char '.' <|> char ')') -- this would be a list
533 guardDisabled Ext_space_in_atx_header <|> notFollowedBy nonspaceChar
533 guardDisabled Ext_space_in_atx_header <|> notFollowedBy nonspaceChar
534 skipSpaces
534 skipSpaces
535− (text, raw) <- withRaw $
535+ (text, raw) <- withRaw $ do
536+ oldAllowLineBreaks <- stateAllowLineBreaks <$> getState
537+ updateState $ \st -> st{ stateAllowLineBreaks = False }
538+ res <- trimInlinesF . mconcat <$>
536− trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)
539+ many (notFollowedBy atxClosing >> inline)
540+ updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }
537 attr <- atxClosing
542 attr <- atxClosing
538 attr' <- registerHeader attr (runF text defaultParserState)
543 attr' <- registerHeader attr (runF text defaultParserState)
539 guardDisabled Ext_implicit_header_references
544 guardDisabled Ext_implicit_header_references
@@ -576,8 +581,13 @@ setextHeader = try $ do
576 -- unless necessary -- it gives a significant performance boost.
581 -- unless necessary -- it gives a significant performance boost.
577 lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline
582 lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline
578 skipSpaces
583 skipSpaces
579− (text, raw) <- withRaw $
584+ (text, raw) <- withRaw $ do
585+ oldAllowLineBreaks <- stateAllowLineBreaks <$> getState
586+ updateState $ \st -> st{ stateAllowLineBreaks = False }
587+ res <- trimInlinesF . mconcat <$>
580− trimInlinesF . mconcat <$> many1 (notFollowedBy setextHeaderEnd >> inline)
588+ many (notFollowedBy setextHeaderEnd >> inline)
589+ updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }
581 attr <- setextHeaderEnd
591 attr <- setextHeaderEnd
582 underlineChar <- oneOf setextHChars
592 underlineChar <- oneOf setextHChars
583 many (char underlineChar)
593 many (char underlineChar)
@@ -1730,6 +1740,7 @@ endline :: PandocMonad m => MarkdownParser m (F Inlines)
1730endline = try $ do
1740endline = try $ do
1732 notFollowedBy blankline
1742 notFollowedBy blankline
1743+ getState >>= guard . stateAllowLineBreaks
1733 -- parse potential list-starts differently if in a list:
1744 -- parse potential list-starts differently if in a list:
1734 notFollowedBy (inList >> listStart)
1745 notFollowedBy (inList >> listStart)
1735 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1746 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart