Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #8869 in addition to proper handling of quoted header args in Org #8870

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
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"
]