diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 79f0e1238ae5..70051327d6dc 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -418,12 +418,15 @@ orgParamValue :: Monad m => OrgParser m Text orgParamValue = try $ fmap T.pack $ skipSpaces *> notFollowedBy orgArgKey - *> noneOf "\n\r" `many1Till` endOfValue + *> (quotedValue <|> regularValue) <* skipSpaces where endOfValue = lookAhead $ try (skipSpaces <* oneOf "\n\r") <|> try (skipSpaces1 <* orgArgKey) + quotedValue = char '\"' *> manyTill anyChar (char '\"') + + regularValue = noneOf "\n\r" `many1Till` endOfValue -- -- Drawers diff --git a/test/Tests/Readers/Org/Block/CodeBlock.hs b/test/Tests/Readers/Org/Block/CodeBlock.hs index bec1fe9fe3fa..51af02931c8c 100644 --- a/test/Tests/Readers/Org/Block/CodeBlock.hs +++ b/test/Tests/Readers/Org/Block/CodeBlock.hs @@ -202,4 +202,28 @@ tests = , ("city", "Zürich") ] in codeBlockWith ( "", ["c"], params) "code body\n" + + , "Header args with quotes" =: + T.unlines [ "#+begin_src haskell :exports \"both\" :tangle \"main.hs\"" + , "main :: IO ()" + , "main = putStrLn \"Hello, World!\"" + , "#+end_src" + ] =?> + let params = [ ("exports", "both") + , ("tangle", "main.hs") + ] + in codeBlockWith ("", ["haskell"], params) + "main :: IO ()\nmain = putStrLn \"Hello, World!\"\n" + + , "Header args with colon" =: + T.unlines [ "#+begin_src haskell :exports \"both\" :session \"my :session\"" + , "main :: IO ()" + , "main = putStrLn \"Hello, World!\"" + , "#+end_src" + ] =?> + let params = [ ("exports", "both") + , ("session", "my :session") + ] + in codeBlockWith ("", ["haskell"], params) + "main :: IO ()\nmain = putStrLn \"Hello, World!\"\n" ]