aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2015-10-25 08:51:53 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2015-10-25 08:54:00 +0100
commit27a8603278529cf3e1fcf0cdbaf94bc005c5472a (patch)
treeeca68d703ba5e3127bef7238f661e57acd44c3fc /src/Text
parenta7150bb6b625dec9fd641dc770ab61a32e9d4e2c (diff)
downloadpandoc-27a8603278529cf3e1fcf0cdbaf94bc005c5472a.tar.gz
Org reader: allow toggling header args
Org-mode allows to skip the argument of a code block header argument if it's toggling a value. Argument-less headers are now recognized, avoiding weird parsing errors. The fixes are not exactly pretty, but neither is the code that was fixed. So I guess it's about par for the course. However, a rewrite of the header parsing code wouldn't hurt in the long run. Thanks to @jo-tham for filing the bug report. This fixes #2269.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Org.hs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 27a8fe957..53cc74537 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -513,10 +513,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 $
@@ -525,11 +531,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 "-_"