git.iko.soy/typeable/pandoc
on master help sign in
Parse empty argument array in inline src blocks.

`enclosedByPair` alone does not the handle the empty array properly since it uses `many1Till`.

commit4f9ab7e03268e576d86e697f7110869434d08557 authorleungbk <bkleung89@gmail.com> dateThu 27 Sep 2018, 15:04 (8 years ago) parentc07b9ae
2 files changed+9−1
src/Text/Pandoc/Readers/Org/Inlines.hs+2−1 test/Tests/Readers/Org/Inline.hs+7
src/Text/Pandoc/Readers/Org/Inlines.hs+2−1
@@ -525,7 +525,8 @@ inlineCodeBlock :: PandocMonad m => OrgParser m (F Inlines)
525525inlineCodeBlock = try $ do
526526 string "src_"
527527 lang <- many1 orgArgWordChar
528− opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption
528+ opts <- option [] $ try (enclosedByPair '[' ']' inlineBlockOption)
529+ <|> (mempty <$ string "[]")
529530 inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
530531 let attrClasses = [translateLang lang]
531532 let attrKeyVal = originalLang lang <> opts
test/Tests/Readers/Org/Inline.hs+7
@@ -280,6 +280,13 @@ tests =
280280 )
281281 "echo 'Hello, World'")
282282
283+ , "Inline code block with a blank argument array" =:
284+ "src_sh[]{echo 'Hello, World'}" =?>
285+ para (codeWith ( ""
286+ , [ "bash" ]
287+ , [ ("org-language", "sh") ])
288+ "echo 'Hello, World'")
289+
283290 , "Inline code block with toggle" =:
284291 "src_sh[:toggle]{echo $HOME}" =?>
285292 para (codeWith ( ""