git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1689 from kuribas/master

Use '=' instead of '#' for atx-style headers in markdown+lhs.

commitdefcb5b6b1114a7618913ebdf49856cec23e3f96 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 25 Jul 2015, 10:21 (11 years ago) parent2b68f7a0198e95
2 files changed+11−4
README+2−1 src/Text/Pandoc/Readers/Markdown.hs+9−3
README+2−1
@@ -3285,7 +3285,8 @@ literate Haskell source. This means that
32853285
32863286 - In markdown input, "bird track" sections will be parsed as Haskell
32873287 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 '#'.
32893290
32903291 - In markdown output, code blocks with classes `haskell` and `literate`
32913292 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
503503header :: MarkdownParser (F Blocks)
504504header = setextHeader <|> atxHeader <?> "header"
505505
506+atxChar :: MarkdownParser Char
507+atxChar = do
508+ exts <- getOption readerExtensions
509+ return $ if Set.member Ext_literate_haskell exts
510+ then '=' else '#'
511+
506512atxHeader :: MarkdownParser (F Blocks)
507513atxHeader = try $ do
508− level <- many1 (char '#') >>= return . length
514+ level <- atxChar >>= many1 . char >>= return . length
509515 notFollowedBy $ guardEnabled Ext_fancy_lists >>
510516 (char '.' <|> char ')') -- this would be a list
511517 skipSpaces
@@ -521,7 +527,7 @@ atxClosing :: MarkdownParser Attr
521527atxClosing = try $ do
522528 attr' <- option nullAttr
523529 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
524− skipMany (char '#')
530+ skipMany . char =<< atxChar
525531 skipSpaces
526532 attr <- option attr'
527533 (guardEnabled Ext_header_attributes >> attributes)
@@ -1649,7 +1655,7 @@ endline = try $ do
16491655 notFollowedBy (inList >> listStart)
16501656 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
16511657 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
16531659 guardDisabled Ext_backtick_code_blocks <|>
16541660 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
16551661 notFollowedByHtmlCloser