git.iko.soy/typeable/pandoc
on master help sign in
Added Ext_fenced_code_attributes.
commitdc6a133dbfdfcae670ee64e86700fd8234540643 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 21 Aug 2012, 19:35 (14 years ago) parentb985d33
3 files changed+12−6
src/Text/Pandoc/Options.hs+2 src/Text/Pandoc/Readers/Markdown.hs+6−4 src/Text/Pandoc/Writers/Markdown.hs+4−2
src/Text/Pandoc/Options.hs+2
@@ -65,6 +65,7 @@ data Extension =
6565 | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
6666 | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
6767 | Ext_fenced_code_blocks -- ^ Parse fenced code blocks
68+ | Ext_fenced_code_attributes -- ^ Allow attributes on fenced code blocks
6869 | Ext_inline_code_attributes -- ^ Allow attributes on inline code
6970 | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
7071 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
@@ -105,6 +106,7 @@ pandocExtensions = Set.fromList
105106 , Ext_tex_math_dollars
106107 , Ext_latex_macros
107108 , Ext_fenced_code_blocks
109+ , Ext_fenced_code_attributes
108110 , Ext_inline_code_attributes
109111 , Ext_markdown_in_html_blocks
110112 , Ext_escaped_line_breaks
src/Text/Pandoc/Readers/Markdown.hs+6−4
@@ -379,7 +379,7 @@ indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")
379379
380380blockDelimiter :: (Char -> Bool)
381381 -> Maybe Int
382− -> Parser [Char] st (Int, (String, [String], [(String, String)]), Char)
382+ -> Parser [Char] ParserState (Int, (String, [String], [(String, String)]), Char)
383383blockDelimiter f len = try $ do
384384 c <- lookAhead (satisfy f)
385385 size <- case len of
@@ -387,9 +387,11 @@ blockDelimiter f len = try $ do
387387 Nothing -> count 3 (char c) >> many (char c) >>=
388388 return . (+ 3) . length
389389 many spaceChar
390− attr <- option ([],[],[])
391− $ attributes -- ~~~ {.ruby}
392− <|> (many1 alphaNum >>= \x -> return ([],[x],[])) -- github variant ```ruby
390+ attr <- option ([],[],[]) $ do
391+ guardEnabled Ext_fenced_code_attributes
392+ attributes -- ~~~ {.ruby}
393+ <|> (many1 alphaNum >>= \x ->
394+ return ([],[x],[])) -- github variant ```ruby
393395 blankline
394396 return (size, attr, c)
395397
src/Text/Pandoc/Writers/Markdown.hs+4−2
@@ -297,8 +297,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
297297 (tildes <> space <> attrs <> cr <> text str <>
298298 cr <> tildes) <> blankline
299299 else nest (writerTabStop opts) (text str) <> blankline
300− where tildes = text "~~~~"
301− attrs = attrsToMarkdown attribs
300+ where tildes = text "~~~~"
301+ attrs = if isEnabled Ext_fenced_code_attributes opts
302+ then attrsToMarkdown attribs
303+ else empty
302304blockToMarkdown opts (BlockQuote blocks) = do
303305 st <- get
304306 -- if we're writing literate haskell, put a space before the bird tracks