Skip to content

Commit

Permalink
Org reader: allow toggling header args
Browse files Browse the repository at this point in the history
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.

This fixes jgm#2269.
  • Loading branch information
tarleb committed Oct 24, 2015
1 parent a7150bb commit 9334e16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Text/Pandoc/Readers/Org.hs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ rundocBlockClass :: String
rundocBlockClass = rundocPrefix ++ "block"

blockOption :: OrgParser (String, String)
blockOption = try $ (,) <$> orgArgKey <*> orgParamValue
blockOption = try $ do
argKey <- orgArgKey
paramValue <- option "yes" orgParamValue
return (argKey, paramValue)

inlineBlockOption :: OrgParser (String, String)
inlineBlockOption = try $ (,) <$> orgArgKey <*> orgInlineParamValue
Expand All @@ -525,7 +528,10 @@ orgArgKey = try $

orgParamValue :: OrgParser String
orgParamValue = try $
skipSpaces *> many1 (noneOf "\t\n\r ") <* skipSpaces
skipSpaces
*> notFollowedBy (char ':' )
*> many1 (noneOf "\t\n\r ")
<* skipSpaces

orgInlineParamValue :: OrgParser String
orgInlineParamValue = try $
Expand Down
9 changes: 9 additions & 0 deletions tests/Tests/Readers/Org.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,15 @@ tests =
, ": 65" ] =?>
rawBlock "html" ""

, "Source block with toggling header arguments" =:
unlines [ "#BEGIN_SRC sh :noeval"
, "echo $HOME"
, "#END_SRC"
] =?>
let classes = [ "bash", "rundoc-block" ]
params = [ ("rundoc-language", "sh"), ("noeval", "yes") ]
in codeBlockWith ("", classes params) "echo $HOME"

, "Example block" =:
unlines [ "#+begin_example"
, "A chosen representation of"
Expand Down

0 comments on commit 9334e16

Please sign in to comment.