Merge pull request #2477 from tarleb/org-toggling-header-args
Org reader: allow toggling header args
This commit is contained in:
commit
45df87cf15
2 changed files with 35 additions and 4 deletions
|
@ -532,10 +532,16 @@ 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
|
||||
inlineBlockOption = try $ do
|
||||
argKey <- orgArgKey
|
||||
paramValue <- option "yes" orgInlineParamValue
|
||||
return (argKey, paramValue)
|
||||
|
||||
orgArgKey :: OrgParser String
|
||||
orgArgKey = try $
|
||||
|
@ -544,11 +550,17 @@ 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 $
|
||||
skipSpaces *> many1 (noneOf "\t\n\r ]") <* skipSpaces
|
||||
skipSpaces
|
||||
*> notFollowedBy (char ':')
|
||||
*> many1 (noneOf "\t\n\r ]")
|
||||
<* skipSpaces
|
||||
|
||||
orgArgWordChar :: OrgParser Char
|
||||
orgArgWordChar = alphaNum <|> oneOf "-_"
|
||||
|
|
|
@ -264,6 +264,16 @@ tests =
|
|||
)
|
||||
"echo 'Hello, World'")
|
||||
|
||||
, "Inline code block with toggle" =:
|
||||
"src_sh[:toggle]{echo $HOME}" =?>
|
||||
(para $ codeWith ( ""
|
||||
, [ "bash", "rundoc-block" ]
|
||||
, [ ("rundoc-language", "sh")
|
||||
, ("rundoc-toggle", "yes")
|
||||
]
|
||||
)
|
||||
"echo $HOME")
|
||||
|
||||
, "Citation" =:
|
||||
"[@nonexistent]" =?>
|
||||
let citation = Citation
|
||||
|
@ -1102,6 +1112,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"), ("rundoc-noeval", "yes") ]
|
||||
in codeBlockWith ("", classes, params) "echo $HOME\n"
|
||||
|
||||
, "Example block" =:
|
||||
unlines [ "#+begin_example"
|
||||
, "A chosen representation of"
|
||||
|
|
Loading…
Add table
Reference in a new issue