@@ -487,9 +487,15 @@ block = do
487header :: MarkdownParser (F Blocks)
487header :: MarkdownParser (F Blocks)
488header = setextHeader <|> atxHeader <?> "header"
488header = setextHeader <|> atxHeader <?> "header"
490+atxChar :: MarkdownParser Char
492+ exts <- getOption readerExtensions
493+ return $ if Set.member Ext_literate_haskell exts
490atxHeader :: MarkdownParser (F Blocks)
496atxHeader :: MarkdownParser (F Blocks)
491atxHeader = try $ do
497atxHeader = try $ do
492− level <- many1 (char '#') >>= return . length
498+ level <- atxChar >>= many1 . char >>= return . length
493 notFollowedBy $ guardEnabled Ext_fancy_lists >>
499 notFollowedBy $ guardEnabled Ext_fancy_lists >>
494 (char '.' <|> char ')') -- this would be a list
500 (char '.' <|> char ')') -- this would be a list
495 skipSpaces
501 skipSpaces
@@ -502,7 +508,7 @@ atxClosing :: MarkdownParser Attr
502atxClosing = try $ do
508atxClosing = try $ do
503 attr' <- option nullAttr
509 attr' <- option nullAttr
504 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
510 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
505− skipMany (char '#')
511+ skipMany . char =<< atxChar
506 skipSpaces
512 skipSpaces
507 attr <- option attr'
513 attr <- option attr'
508 (guardEnabled Ext_header_attributes >> attributes)
514 (guardEnabled Ext_header_attributes >> attributes)
@@ -1614,7 +1620,7 @@ endline = try $ do
1614 when (stateParserContext st == ListItemState) $ notFollowedBy listStart
1620 when (stateParserContext st == ListItemState) $ notFollowedBy listStart
1615 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1621 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1616 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1622 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1617− guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
1623+ guardEnabled Ext_blank_before_header <|> (notFollowedBy . char =<< atxChar) -- atx header
1618 guardDisabled Ext_backtick_code_blocks <|>
1624 guardDisabled Ext_backtick_code_blocks <|>
1619 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
1625 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
1620 notFollowedByHtmlCloser
1626 notFollowedByHtmlCloser