git.iko.soy/typeable/pandoc
on master help sign in
Org reader: allow multiple pipe chars in todo sequences

Additional pipe chars, used to separate "action" state from "no further action" states, are ignored. E.g., for the following sequence, both `DONE` and `FINISHED` are states with no further action required. #+TODO: UNFINISHED | DONE | FINISHED Previously, parsing of the todo sequence failed if multiple pipe chars were included. Closes: #7014

commitfe1378227b24fa6a8661b2e0d377b808eb270c52 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 9 Jan 2021, 13:35 (6 years ago) parent4f34345
2 files changed+20−4
src/Text/Pandoc/Readers/Org/Meta.hs+10−4 test/Tests/Readers/Org/Meta.hs+10
src/Text/Pandoc/Readers/Org/Meta.hs+10−4
@@ -239,7 +239,7 @@ lineOfInlines = do
239239todoSequence :: Monad m => OrgParser m TodoSequence
240240todoSequence = try $ do
241241 todoKws <- todoKeywords
242− doneKws <- optionMaybe $ todoDoneSep *> todoKeywords
242+ doneKws <- optionMaybe $ todoDoneSep *> doneKeywords
243243 newline
244244 -- There must be at least one DONE keyword. The last TODO keyword is
245245 -- taken if necessary.
@@ -250,11 +250,17 @@ todoSequence = try $ do
250250 (x:xs) -> return $ keywordsToSequence (reverse xs) [x]
251251
252252 where
253+ todoKeyword :: Monad m => OrgParser m Text
254+ todoKeyword = many1Char nonspaceChar <* skipSpaces
255+
253256 todoKeywords :: Monad m => OrgParser m [Text]
254257 todoKeywords = try $
255− let keyword = many1Char nonspaceChar <* skipSpaces
256− endOfKeywords = todoDoneSep <|> void newline
257− in manyTill keyword (lookAhead endOfKeywords)
258+ let endOfKeywords = todoDoneSep <|> void newline
259+ in manyTill todoKeyword (lookAhead endOfKeywords)
260+
261+ doneKeywords :: Monad m => OrgParser m [Text]
262+ doneKeywords = try $
263+ manyTill (todoKeyword <* optional todoDoneSep) (lookAhead newline)
258264
259265 todoDoneSep :: Monad m => OrgParser m ()
260266 todoDoneSep = void . try $ skipSpaces *> char '|' <* skipSpaces1
test/Tests/Readers/Org/Meta.hs+10
@@ -116,6 +116,16 @@ tests =
116116 "#+LANGUAGE: de-DE" =?>
117117 Pandoc (setMeta "lang" (MetaString "de-DE") nullMeta) mempty
118118
119+ , testGroup "Todo sequences"
120+ [ "not included in document" =:
121+ "#+todo: WAITING | FINISHED" =?>
122+ Pandoc mempty mempty
123+
124+ , "can contain multiple pipe characters" =:
125+ "#+todo: UNFINISHED | RESEARCH | NOTES | CHART\n" =?>
126+ Pandoc mempty mempty
127+ ]
128+
119129 , testGroup "LaTeX"
120130 [ "LATEX_HEADER" =:
121131 "#+latex_header: \\usepackage{tikz}" =?>