git.iko.soy/typeable/pandoc
on master help sign in
Use '=' instead of '#' for atx-style headers in markdown+lhs.
commit0198e9507190e5b7d4000605641694aa570f3c10 authorKristof Bastiaensen <kristof@vleeuwen.org> dateTue 14 Oct 2014, 13:28 (12 years ago) parent8b60d43
2 files changed+11−4
README+2−1 src/Text/Pandoc/Readers/Markdown.hs+9−3
README+2−1
@@ -3080,7 +3080,8 @@ literate Haskell source. This means that
30803080
30813081 - In markdown input, "bird track" sections will be parsed as Haskell
30823082 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 '#'.
30843085
30853086 - In markdown output, code blocks with classes `haskell` and `literate`
30863087 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
487487header :: MarkdownParser (F Blocks)
488488header = setextHeader <|> atxHeader <?> "header"
489489
490+atxChar :: MarkdownParser Char
491+atxChar = do
492+ exts <- getOption readerExtensions
493+ return $ if Set.member Ext_literate_haskell exts
494+ then '=' else '#'
495+
490496atxHeader :: MarkdownParser (F Blocks)
491497atxHeader = try $ do
492− level <- many1 (char '#') >>= return . length
498+ level <- atxChar >>= many1 . char >>= return . length
493499 notFollowedBy $ guardEnabled Ext_fancy_lists >>
494500 (char '.' <|> char ')') -- this would be a list
495501 skipSpaces
@@ -502,7 +508,7 @@ atxClosing :: MarkdownParser Attr
502508atxClosing = try $ do
503509 attr' <- option nullAttr
504510 (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
505− skipMany (char '#')
511+ skipMany . char =<< atxChar
506512 skipSpaces
507513 attr <- option attr'
508514 (guardEnabled Ext_header_attributes >> attributes)
@@ -1614,7 +1620,7 @@ endline = try $ do
16141620 when (stateParserContext st == ListItemState) $ notFollowedBy listStart
16151621 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
16161622 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
16181624 guardDisabled Ext_backtick_code_blocks <|>
16191625 notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
16201626 notFollowedByHtmlCloser