From 4926645578aecc08ea496860f1608fa3e8ffd572 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 16 Jan 2013 09:17:20 -0800 Subject: Implemented Ext_mmd_header_identifiers in markdown reader. --- src/Text/Pandoc/Options.hs | 1 + src/Text/Pandoc/Readers/Markdown.hs | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index f64926f67..8ebbef0be 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -169,6 +169,7 @@ multimarkdownExtensions :: Set Extension multimarkdownExtensions = Set.fromList [ Ext_pipe_tables , Ext_raw_html + , Ext_markdown_attribute , Ext_raw_tex , Ext_tex_math_double_backslash , Ext_intraword_underscores diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 8141187e7..05f6b084e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -396,12 +396,30 @@ atxHeader = try $ do attr' <- addToHeaderList attr text return $ B.headerWith attr' level <$> text -atxClosing :: Parser [Char] st Attr -atxClosing = - try $ skipMany (char '#') >> skipSpaces >> option nullAttr attributes <* blanklines +atxClosing :: MarkdownParser Attr +atxClosing = try $ do + attr' <- option nullAttr + (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier) + skipMany (char '#') + skipSpaces + attr <- option attr' + (guardEnabled Ext_header_attributes >> attributes) + blanklines + return attr setextHeaderEnd :: MarkdownParser Attr -setextHeaderEnd = try $ option nullAttr attributes <* blankline +setextHeaderEnd = try $ do + attr <- option nullAttr + $ (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier) + <|> (guardEnabled Ext_header_attributes >> attributes) + blanklines + return attr + +mmdHeaderIdentifier :: MarkdownParser Attr +mmdHeaderIdentifier = do + ident <- stripFirstAndLast . snd <$> reference + skipSpaces + return (ident,[],[]) setextHeader :: MarkdownParser (F Blocks) setextHeader = try $ do -- cgit v1.2.3