git.iko.soy/typeable/pandoc
on master help sign in
Use '=' instead of '#' for atx-style headers in markdown+lhs.
0198e95Kristof Bastiaensen
README+2−1
@@ -3080,7 +3080,8 @@ literate Haskell source. This means that
3080
3080
3081 - In markdown input, "bird track" sections will be parsed as Haskell
3081 - In markdown input, "bird track" sections will be parsed as Haskell
3082 code rather than block quotations. Text between `\begin{code}`
3082 code rather than block quotations. Text between `\begin{code}`
3083− and `\end{code}` will also be treated as Haskell code.
3083+ and `\end{code}` will also be treated as Haskell code. For
3084+ atx-style headers the character '=' will be used instead of '#'.
3084
3085
3085 - In markdown output, code blocks with classes `haskell` and `literate`
3086 - In markdown output, code blocks with classes `haskell` and `literate`
3086 will be rendered using bird tracks, and block quotations will be
3087 will be rendered using bird tracks, and block quotations will be
src/Text/Pandoc/Readers/Markdown.hs+9−3
@@ -487,9 +487,15 @@ block = do
487header :: MarkdownParser (F Blocks)
487header :: MarkdownParser (F Blocks)
488header = setextHeader <|> atxHeader <?> "header"
488header = setextHeader <|> atxHeader <?> "header"
489
489
490+atxChar :: MarkdownParser Char
491+atxChar = do
492+ exts <- getOption readerExtensions
493+ return $ if Set.member Ext_literate_haskell exts
494+ then '=' else '#'
495+
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