@@ -43,6 +43,7 @@ import Text.Pandoc.Shared (compactify', compactify'DL)
4343
4444import Control.Applicative ( Applicative, pure
4545 , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
46+import Control.Arrow (first)
4647import Control.Monad (foldM, guard, liftM, liftM2, mzero, when)
4748import Control.Monad.Reader (Reader, runReader, ask, asks)
4849import Data.Char (isAlphaNum, toLower)
@@ -721,7 +722,6 @@ bulletList = fmap B.bulletList . fmap compactify' . sequence
721722 <$> many1 (listItem bulletListStart)
722723
723724orderedList :: OrgParser (F Blocks)
724−-- orderedList = B.orderedList . compactify' <$> many1 (listItem orderedListStart)
725725orderedList = fmap B.orderedList . fmap compactify' . sequence
726726 <$> many1 (listItem orderedListStart)
727727
@@ -746,11 +746,11 @@ definitionListItem :: OrgParser Int
746746definitionListItem parseMarkerGetLength = try $ do
747747 markerLength <- parseMarkerGetLength
748748 term <- manyTill (noneOf "\n\r") (try $ string "::")
749− first <- anyLineNewline
749+ line1 <- anyLineNewline
750750 blank <- option "" ("\n" <$ blankline)
751751 cont <- concat <$> many (listContinuation markerLength)
752752 term' <- parseFromString inline term
753− contents' <- parseFromString parseBlocks $ first ++ blank ++ cont
753+ contents' <- parseFromString parseBlocks $ line1 ++ blank ++ cont
754754 return $ (,) <$> term' <*> fmap (:[]) contents'
755755
756756
@@ -789,6 +789,7 @@ inline =
789789 , footnote
790790 , linkOrImage
791791 , anchor
792+ , inlineCodeBlock
792793 , str
793794 , endline
794795 , emph
@@ -989,6 +990,42 @@ solidify = map replaceSpecialChar
989990 | c `elem` "_.-:" = c
990991 | otherwise = '-'
991992
993+-- | Parses an inline code block and marks it as an babel block.
994+inlineCodeBlock :: OrgParser (F Inlines)
995+inlineCodeBlock = try $ do
996+ string "src_"
997+ lang <- many1 orgArgWordChar
998+ opts <- option [] $ enclosedByPair '[' ']' blockOption
999+ inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
1000+ let attrClasses = [translateLang lang, rundocBlockClass]
1001+ let attrKeyVal = map toRundocAttrib (("language", lang) : opts)
1002+ returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
1003+ where enclosedByPair s e p = char s *> many1Till p (char e)
1004+
1005+-- | The class-name used to mark rundoc blocks.
1006+rundocBlockClass :: String
1007+rundocBlockClass = "rundoc-block"
1008+
1009+blockOption :: OrgParser (String, String)
1010+blockOption = try $ (,) <$> orgArgKey <*> orgArgValue
1011+
1012+orgArgKey :: OrgParser String
1013+orgArgKey = try $
1014+ skipSpaces *> char ':'
1015+ *> many1 orgArgWordChar
1016+ <* many1 spaceChar
1017+
1018+orgArgValue :: OrgParser String
1019+orgArgValue = try $
1020+ skipSpaces *> many1 orgArgWordChar
1021+ <* skipSpaces
1022+
1023+orgArgWordChar :: OrgParser Char
1024+orgArgWordChar = alphaNum <|> oneOf "-_"
1025+
1026+toRundocAttrib :: (String, String) -> (String, String)
1027+toRundocAttrib = first ("rundoc-" ++)
1028+
9921029emph :: OrgParser (F Inlines)
9931030emph = fmap B.emph <$> emphasisBetween '/'
9941031