git.iko.soy/typeable/pandoc
on master help sign in
Org reader: allow multi-word arguments to src block params

The reader now correctly parses src block parameter list even if parameter arguments contain multiple words. Closes: #3477

commit04cb602d79df5ee386107c27107cb9c8d09b1665 authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 23 Apr 2017, 13:58 (10 years ago) parent2e43e27
2 files changed+14−2
src/Text/Pandoc/Readers/Org/Blocks.hs+5−2 test/Tests/Readers/Org.hs+9
src/Text/Pandoc/Readers/Org/Blocks.hs+5−2
@@ -589,9 +589,12 @@ blockOption = try $ do
589589orgParamValue :: Monad m => OrgParser m String
590590orgParamValue = try $
591591 skipSpaces
592− *> notFollowedBy (char ':' )
593− *> many1 nonspaceChar
592+ *> notFollowedBy orgArgKey
593+ *> noneOf "\n\r" `many1Till` endOfValue
594594 <* skipSpaces
595+ where
596+ endOfValue = lookAhead $ (try $ skipSpaces <* oneOf "\n\r")
597+ <|> (try $ skipSpaces1 <* orgArgKey)
595598
596599
597600--
test/Tests/Readers/Org.hs+9
@@ -1559,6 +1559,15 @@ tests =
15591559 params = [ ("data-org-language", "sh"), ("startFrom", "10") ]
15601560 in codeBlockWith ("", classes, params) ":() { :|:& };:\n"
15611561
1562+ , "Source block with multi-word parameter values" =:
1563+ unlines [ "#+BEGIN_SRC dot :cmdline -Kdot -Tpng "
1564+ , "digraph { id [label=\"ID\"] }"
1565+ , "#+END_SRC"
1566+ ] =?>
1567+ let classes = [ "dot" ]
1568+ params = [ ("cmdline", "-Kdot -Tpng") ]
1569+ in codeBlockWith ("", classes, params) "digraph { id [label=\"ID\"] }\n"
1570+
15621571 , "Example block" =:
15631572 unlines [ "#+begin_example"
15641573 , "A chosen representation of"