@@ -307,6 +307,7 @@ parseBlocks = mconcat <$> manyTill block eof
308block :: Parser [Char] ParserState (F Blocks)
308block :: Parser [Char] ParserState (F Blocks)
309block = choice [ codeBlockFenced
309block = choice [ codeBlockFenced
310+ , codeBlockBackticks
310 , guardEnabled Ext_latex_macros *> (mempty <$ macro)
311 , guardEnabled Ext_latex_macros *> (mempty <$ macro)
312 , rawTeXBlock
313 , rawTeXBlock
@@ -379,21 +380,13 @@ indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")
380blockDelimiter :: (Char -> Bool)
381blockDelimiter :: (Char -> Bool)
381 -> Maybe Int
382 -> Maybe Int
382− -> Parser [Char] ParserState (Int, (String, [String], [(String, String)]), Char)
383+ -> Parser [Char] st Int
383blockDelimiter f len = try $ do
384blockDelimiter f len = try $ do
384 c <- lookAhead (satisfy f)
385 c <- lookAhead (satisfy f)
385− size <- case len of
386+ case len of
386− Just l -> count l (char c) >> many (char c) >> return l
387+ Just l -> count l (char c) >> many (char c) >> return l
387− Nothing -> count 3 (char c) >> many (char c) >>=
388+ Nothing -> count 3 (char c) >> many (char c) >>=
388− return . (+ 3) . length
389+ return . (+ 3) . length
390− attr <- option ([],[],[]) $ do
391− guardEnabled Ext_fenced_code_attributes
392− attributes -- ~~~ {.ruby}
393− <|> (many1 alphaNum >>= \x ->
394− return ([],[x],[])) -- github variant ```ruby
396− return (size, attr, c)
398attributes :: Parser [Char] st (String, [String], [(String, String)])
391attributes :: Parser [Char] st (String, [String], [(String, String)])
399attributes = try $ do
392attributes = try $ do
@@ -440,11 +433,26 @@ keyValAttr = try $ do
440codeBlockFenced :: Parser [Char] ParserState (F Blocks)
433codeBlockFenced :: Parser [Char] ParserState (F Blocks)
441codeBlockFenced = try $ do
434codeBlockFenced = try $ do
442 guardEnabled Ext_fenced_code_blocks
435 guardEnabled Ext_fenced_code_blocks
443− (size, attr, c) <- blockDelimiter (\c -> c == '~' || c == '`') Nothing
436+ size <- blockDelimiter (=='~') Nothing
438+ attr <- option ([],[],[]) $
439+ guardEnabled Ext_fenced_code_attributes >> attributes
444− contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
441+ contents <- manyTill anyLine (blockDelimiter (=='~') (Just size))
445 blanklines
442 blanklines
446 return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
443 return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
445+codeBlockBackticks :: Parser [Char] ParserState (F Blocks)
446+codeBlockBackticks = try $ do
447+ guardEnabled Ext_backtick_code_blocks
448+ blockDelimiter (=='`') (Just 3)
450+ cls <- many1 alphaNum
452+ contents <- manyTill anyLine $ blockDelimiter (=='`') (Just 3)
454+ return $ return $ B.codeBlockWith ("",[cls],[]) $ intercalate "\n" contents
448codeBlockIndented :: Parser [Char] ParserState (F Blocks)
456codeBlockIndented :: Parser [Char] ParserState (F Blocks)
449codeBlockIndented = do
457codeBlockIndented = do
450 contents <- many1 (indentedLine <|>
458 contents <- many1 (indentedLine <|>