git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1689 from kuribas/master
defcb5bJohn MacFarlane
README+2−1
@@ -3285,7 +3285,8 @@ literate Haskell source. This means that
3285
3285
3286 - In markdown input, "bird track" sections will be parsed as Haskell
3286 - In markdown input, "bird track" sections will be parsed as Haskell
3287 code rather than block quotations. Text between `\begin{code}`
3287 code rather than block quotations. Text between `\begin{code}`
3288− and `\end{code}` will also be treated as Haskell code.
3288+ and `\end{code}` will also be treated as Haskell code. For
3289+ atx-style headers the character '=' will be used instead of '#'.
3289
3290
3290 - In markdown output, code blocks with classes `haskell` and `literate`
3291 - In markdown output, code blocks with classes `haskell` and `literate`
3291 will be rendered using bird tracks, and block quotations will be
3292 will be rendered using bird tracks, and block quotations will be
src/Text/Pandoc/Readers/Markdown.hs+9−3
@@ -503,9 +503,15 @@ block = do
503header :: MarkdownParser (F Blocks)
503header :: MarkdownParser (F Blocks)
504header = setextHeader <|> atxHeader <?> "header"
504header = setextHeader <|> atxHeader <?> "header"
505
505
506+atxChar :: MarkdownParser Char
507+atxChar = do
508+ exts <- getOption readerExtensions
509+ return $ if Set.member Ext_literate_haskell exts
510+ then '=' else '#'
511+
506atxHeader :: MarkdownParser (F Blocks)
512atxHeader :: MarkdownParser (F Blocks)
507atxHeader = try $ do
513atxHeader = try $ do
508− level <- many1 (char '#') >>= return . length
514+ level <- atxChar >>= many1 . char >>= return . length
509 notFollowedBy $ guardEnabled Ext_fancy_lists >>
515 notFollowedBy $ guardEnabled Ext_fancy_lists >>
510 (char '.' <|> char ')') -- this would be a list
516 (char '.' <|> char ')') -- this would be a list
511 skipSpaces
517 skipSpaces
@@ -521,7 +527,7 @@ atxClosing :: MarkdownParser Attr
521atxClosing = try $ do
527atxClosing = try $ do
522 attr' <- option nullAttr
528 attr' <- option nullAttr
523 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
529 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
524− skipMany (char '#')
530+ skipMany . char =<< atxChar
525 skipSpaces
531 skipSpaces
526 attr <- option attr'
532 attr <- option attr'
527 (guardEnabled Ext_header_attributes >> attributes)
533 (guardEnabled Ext_header_attributes >> attributes)
@@ -1649,7 +1655,7 @@ endline = try $ do
1649 notFollowedBy (inList >> listStart)
1655 notFollowedBy (inList >> listStart)
1650 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1656 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1651 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1657 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1652− guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
1658+ guardEnabled Ext_blank_before_header <|> (notFollowedBy . char =<< atxChar) -- atx header
1653 guardDisabled Ext_backtick_code_blocks <|>
1659 guardDisabled Ext_backtick_code_blocks <|>
1654 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
1660 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
1655 notFollowedByHtmlCloser
1661 notFollowedByHtmlCloser