Parse empty argument array in inline src blocks.

`enclosedByPair` alone does not the handle the empty array properly since it uses `many1Till`.
This commit is contained in:
leungbk 2018-09-27 15:04:56 -07:00 committed by Albert Krewinkel
parent c07b9aebc2
commit 4f9ab7e032
2 changed files with 9 additions and 1 deletions

View file

@ -525,7 +525,8 @@ inlineCodeBlock :: PandocMonad m => OrgParser m (F Inlines)
inlineCodeBlock = try $ do
string "src_"
lang <- many1 orgArgWordChar
opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption
opts <- option [] $ try (enclosedByPair '[' ']' inlineBlockOption)
<|> (mempty <$ string "[]")
inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
let attrClasses = [translateLang lang]
let attrKeyVal = originalLang lang <> opts

View file

@ -280,6 +280,13 @@ tests =
)
"echo 'Hello, World'")
, "Inline code block with a blank argument array" =:
"src_sh[]{echo 'Hello, World'}" =?>
para (codeWith ( ""
, [ "bash" ]
, [ ("org-language", "sh") ])
"echo 'Hello, World'")
, "Inline code block with toggle" =:
"src_sh[:toggle]{echo $HOME}" =?>
para (codeWith ( ""