Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Text/Pandoc/Readers/Org/Blocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will parse spaces; is that intended?
The old parser would stop if it gets to spaces followed by an orgArgKey, while this one won't, if I understand correctly.


--
-- Drawers
Expand Down
24 changes: 24 additions & 0 deletions test/Tests/Readers/Org/Block/CodeBlock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]