@@ -681,19 +681,36 @@ specialAttr = do
681681 char '-'
682682 return $ \(id',cs,kvs) -> (id',cs ++ ["unnumbered"],kvs)
683683
684+rawAttribute :: PandocMonad m => MarkdownParser m String
685+rawAttribute = do
686+ char '{'
687+ skipMany spaceChar
688+ char '='
689+ format <- many1 $ satisfy (\c -> isAlphaNum c || c `elem` "-_")
690+ skipMany spaceChar
691+ char '}'
692+ return format
693+
684694codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks)
685695codeBlockFenced = try $ do
686696 c <- try (guardEnabled Ext_fenced_code_blocks >> lookAhead (char '~'))
687697 <|> (guardEnabled Ext_backtick_code_blocks >> lookAhead (char '`'))
688698 size <- blockDelimiter (== c) Nothing
689699 skipMany spaceChar
690− attr <- option ([],[],[]) $
691− try (guardEnabled Ext_fenced_code_attributes >> attributes)
692− <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)
700+ rawattr <-
701+ (Left <$> try (guardEnabled Ext_raw_attribute >> rawAttribute))
702+ <|>
703+ (Right <$> option ("",[],[])
704+ (try (guardEnabled Ext_fenced_code_attributes >> attributes)
705+ <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)))
693706 blankline
694− contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
707+ contents <- intercalate "\n" <$>
708+ manyTill anyLine (blockDelimiter (== c) (Just size))
695709 blanklines
696− return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
710+ return $ return $
711+ case rawattr of
712+ Left syn -> B.rawBlock syn contents
713+ Right attr -> B.codeBlockWith attr contents
697714
698715-- correctly handle github language identifiers
699716toLanguageId :: String -> String
@@ -1516,13 +1533,20 @@ code :: PandocMonad m => MarkdownParser m (F Inlines)
15161533code = try $ do
15171534 starts <- many1 (char '`')
15181535 skipSpaces
1519− result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>
1536+ result <- (trim . concat) <$>
1537+ many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>
15201538 (char '\n' >> notFollowedBy' blankline >> return " "))
15211539 (try (skipSpaces >> count (length starts) (char '`') >>
15221540 notFollowedBy (char '`')))
1523− attr <- option ([],[],[]) (try $ guardEnabled Ext_inline_code_attributes
1524− >> attributes)
1525− return $ return $ B.codeWith attr $ trim $ concat result
1541+ rawattr <-
1542+ (Left <$> try (guardEnabled Ext_raw_attribute >> rawAttribute))
1543+ <|>
1544+ (Right <$> option ("",[],[])
1545+ (try (guardEnabled Ext_inline_code_attributes >> attributes)))
1546+ return $ return $
1547+ case rawattr of
1548+ Left syn -> B.rawInline syn result
1549+ Right attr -> B.codeWith attr result
15261550
15271551math :: PandocMonad m => MarkdownParser m (F Inlines)
15281552math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))