git.iko.soy/typeable/pandoc
on master help sign in
Added Ext_fenced_code_attributes.
dc6a133John MacFarlane
src/Text/Pandoc/Options.hs+2
@@ -65,6 +65,7 @@ data Extension =
65 | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
65 | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
66 | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
66 | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
67 | Ext_fenced_code_blocks -- ^ Parse fenced code blocks
67 | Ext_fenced_code_blocks -- ^ Parse fenced code blocks
68+ | Ext_fenced_code_attributes -- ^ Allow attributes on fenced code blocks
68 | Ext_inline_code_attributes -- ^ Allow attributes on inline code
69 | Ext_inline_code_attributes -- ^ Allow attributes on inline code
69 | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
70 | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
70 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
71 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
@@ -105,6 +106,7 @@ pandocExtensions = Set.fromList
105 , Ext_tex_math_dollars
106 , Ext_tex_math_dollars
106 , Ext_latex_macros
107 , Ext_latex_macros
107 , Ext_fenced_code_blocks
108 , Ext_fenced_code_blocks
109+ , Ext_fenced_code_attributes
108 , Ext_inline_code_attributes
110 , Ext_inline_code_attributes
109 , Ext_markdown_in_html_blocks
111 , Ext_markdown_in_html_blocks
110 , Ext_escaped_line_breaks
112 , Ext_escaped_line_breaks
src/Text/Pandoc/Readers/Markdown.hs+6−4
@@ -379,7 +379,7 @@ indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")
379
379
380blockDelimiter :: (Char -> Bool)
380blockDelimiter :: (Char -> Bool)
381 -> Maybe Int
381 -> Maybe Int
382− -> Parser [Char] st (Int, (String, [String], [(String, String)]), Char)
382+ -> Parser [Char] ParserState (Int, (String, [String], [(String, String)]), Char)
383blockDelimiter f len = try $ do
383blockDelimiter f len = try $ do
384 c <- lookAhead (satisfy f)
384 c <- lookAhead (satisfy f)
385 size <- case len of
385 size <- case len of
@@ -387,9 +387,11 @@ blockDelimiter f len = try $ do
387 Nothing -> count 3 (char c) >> many (char c) >>=
387 Nothing -> count 3 (char c) >> many (char c) >>=
388 return . (+ 3) . length
388 return . (+ 3) . length
389 many spaceChar
389 many spaceChar
390− attr <- option ([],[],[])
390+ attr <- option ([],[],[]) $ do
391+ guardEnabled Ext_fenced_code_attributes
391− $ attributes -- ~~~ {.ruby}
392+ attributes -- ~~~ {.ruby}
393+ <|> (many1 alphaNum >>= \x ->
392− <|> (many1 alphaNum >>= \x -> return ([],[x],[])) -- github variant ```ruby
394+ return ([],[x],[])) -- github variant ```ruby
393 blankline
395 blankline
394 return (size, attr, c)
396 return (size, attr, c)
395
397
src/Text/Pandoc/Writers/Markdown.hs+4−2
@@ -297,8 +297,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
297 (tildes <> space <> attrs <> cr <> text str <>
297 (tildes <> space <> attrs <> cr <> text str <>
298 cr <> tildes) <> blankline
298 cr <> tildes) <> blankline
299 else nest (writerTabStop opts) (text str) <> blankline
299 else nest (writerTabStop opts) (text str) <> blankline
300− where tildes = text "~~~~"
300+ where tildes = text "~~~~"
301+ attrs = if isEnabled Ext_fenced_code_attributes opts
301− attrs = attrsToMarkdown attribs
302+ then attrsToMarkdown attribs
303+ else empty
302blockToMarkdown opts (BlockQuote blocks) = do
304blockToMarkdown opts (BlockQuote blocks) = do
303 st <- get
305 st <- get
304 -- if we're writing literate haskell, put a space before the bird tracks
306 -- if we're writing literate haskell, put a space before the bird tracks