@@ -43,6 +43,7 @@ import Text.Pandoc.Shared (compactify', compactify'DL)
44import Control.Applicative ( Applicative, pure
44import Control.Applicative ( Applicative, pure
45 , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
45 , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
46+import Control.Arrow (first)
46import Control.Monad (foldM, guard, liftM, liftM2, mzero, when)
47import Control.Monad (foldM, guard, liftM, liftM2, mzero, when)
47import Control.Monad.Reader (Reader, runReader, ask, asks)
48import Control.Monad.Reader (Reader, runReader, ask, asks)
48import Data.Char (isAlphaNum, toLower)
49import Data.Char (isAlphaNum, toLower)
@@ -721,7 +722,6 @@ bulletList = fmap B.bulletList . fmap compactify' . sequence
721 <$> many1 (listItem bulletListStart)
722 <$> many1 (listItem bulletListStart)
723orderedList :: OrgParser (F Blocks)
724orderedList :: OrgParser (F Blocks)
724−-- orderedList = B.orderedList . compactify' <$> many1 (listItem orderedListStart)
725orderedList = fmap B.orderedList . fmap compactify' . sequence
725orderedList = fmap B.orderedList . fmap compactify' . sequence
726 <$> many1 (listItem orderedListStart)
726 <$> many1 (listItem orderedListStart)
@@ -746,11 +746,11 @@ definitionListItem :: OrgParser Int
746definitionListItem parseMarkerGetLength = try $ do
746definitionListItem parseMarkerGetLength = try $ do
747 markerLength <- parseMarkerGetLength
747 markerLength <- parseMarkerGetLength
748 term <- manyTill (noneOf "\n\r") (try $ string "::")
748 term <- manyTill (noneOf "\n\r") (try $ string "::")
749− first <- anyLineNewline
749+ line1 <- anyLineNewline
750 blank <- option "" ("\n" <$ blankline)
750 blank <- option "" ("\n" <$ blankline)
751 cont <- concat <$> many (listContinuation markerLength)
751 cont <- concat <$> many (listContinuation markerLength)
752 term' <- parseFromString inline term
752 term' <- parseFromString inline term
753− contents' <- parseFromString parseBlocks $ first ++ blank ++ cont
753+ contents' <- parseFromString parseBlocks $ line1 ++ blank ++ cont
754 return $ (,) <$> term' <*> fmap (:[]) contents'
754 return $ (,) <$> term' <*> fmap (:[]) contents'
@@ -789,6 +789,7 @@ inline =
789 , footnote
789 , footnote
790 , linkOrImage
790 , linkOrImage
793 , endline
794 , endline
@@ -989,6 +990,42 @@ solidify = map replaceSpecialChar
989 | c `elem` "_.-:" = c
990 | c `elem` "_.-:" = c
990 | otherwise = '-'
991 | otherwise = '-'
993+-- | Parses an inline code block and marks it as an babel block.
994+inlineCodeBlock :: OrgParser (F Inlines)
995+inlineCodeBlock = try $ do
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)
1005+-- | The class-name used to mark rundoc blocks.
1006+rundocBlockClass :: String
1007+rundocBlockClass = "rundoc-block"
1009+blockOption :: OrgParser (String, String)
1010+blockOption = try $ (,) <$> orgArgKey <*> orgArgValue
1012+orgArgKey :: OrgParser String
1014+ skipSpaces *> char ':'
1015+ *> many1 orgArgWordChar
1018+orgArgValue :: OrgParser String
1020+ skipSpaces *> many1 orgArgWordChar
1023+orgArgWordChar :: OrgParser Char
1024+orgArgWordChar = alphaNum <|> oneOf "-_"
1026+toRundocAttrib :: (String, String) -> (String, String)
1027+toRundocAttrib = first ("rundoc-" ++)
992emph :: OrgParser (F Inlines)
1029emph :: OrgParser (F Inlines)
993emph = fmap B.emph <$> emphasisBetween '/'
1030emph = fmap B.emph <$> emphasisBetween '/'