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
This commit is contained in:
parent
4f34345867
commit
fe1378227b
2 changed files with 20 additions and 4 deletions
|
@ -239,7 +239,7 @@ lineOfInlines = do
|
||||||
todoSequence :: Monad m => OrgParser m TodoSequence
|
todoSequence :: Monad m => OrgParser m TodoSequence
|
||||||
todoSequence = try $ do
|
todoSequence = try $ do
|
||||||
todoKws <- todoKeywords
|
todoKws <- todoKeywords
|
||||||
doneKws <- optionMaybe $ todoDoneSep *> todoKeywords
|
doneKws <- optionMaybe $ todoDoneSep *> doneKeywords
|
||||||
newline
|
newline
|
||||||
-- There must be at least one DONE keyword. The last TODO keyword is
|
-- There must be at least one DONE keyword. The last TODO keyword is
|
||||||
-- taken if necessary.
|
-- taken if necessary.
|
||||||
|
@ -250,11 +250,17 @@ todoSequence = try $ do
|
||||||
(x:xs) -> return $ keywordsToSequence (reverse xs) [x]
|
(x:xs) -> return $ keywordsToSequence (reverse xs) [x]
|
||||||
|
|
||||||
where
|
where
|
||||||
|
todoKeyword :: Monad m => OrgParser m Text
|
||||||
|
todoKeyword = many1Char nonspaceChar <* skipSpaces
|
||||||
|
|
||||||
todoKeywords :: Monad m => OrgParser m [Text]
|
todoKeywords :: Monad m => OrgParser m [Text]
|
||||||
todoKeywords = try $
|
todoKeywords = try $
|
||||||
let keyword = many1Char nonspaceChar <* skipSpaces
|
let endOfKeywords = todoDoneSep <|> void newline
|
||||||
endOfKeywords = todoDoneSep <|> void newline
|
in manyTill todoKeyword (lookAhead endOfKeywords)
|
||||||
in manyTill keyword (lookAhead endOfKeywords)
|
|
||||||
|
doneKeywords :: Monad m => OrgParser m [Text]
|
||||||
|
doneKeywords = try $
|
||||||
|
manyTill (todoKeyword <* optional todoDoneSep) (lookAhead newline)
|
||||||
|
|
||||||
todoDoneSep :: Monad m => OrgParser m ()
|
todoDoneSep :: Monad m => OrgParser m ()
|
||||||
todoDoneSep = void . try $ skipSpaces *> char '|' <* skipSpaces1
|
todoDoneSep = void . try $ skipSpaces *> char '|' <* skipSpaces1
|
||||||
|
|
|
@ -116,6 +116,16 @@ tests =
|
||||||
"#+LANGUAGE: de-DE" =?>
|
"#+LANGUAGE: de-DE" =?>
|
||||||
Pandoc (setMeta "lang" (MetaString "de-DE") nullMeta) mempty
|
Pandoc (setMeta "lang" (MetaString "de-DE") nullMeta) mempty
|
||||||
|
|
||||||
|
, testGroup "Todo sequences"
|
||||||
|
[ "not included in document" =:
|
||||||
|
"#+todo: WAITING | FINISHED" =?>
|
||||||
|
Pandoc mempty mempty
|
||||||
|
|
||||||
|
, "can contain multiple pipe characters" =:
|
||||||
|
"#+todo: UNFINISHED | RESEARCH | NOTES | CHART\n" =?>
|
||||||
|
Pandoc mempty mempty
|
||||||
|
]
|
||||||
|
|
||||||
, testGroup "LaTeX"
|
, testGroup "LaTeX"
|
||||||
[ "LATEX_HEADER" =:
|
[ "LATEX_HEADER" =:
|
||||||
"#+latex_header: \\usepackage{tikz}" =?>
|
"#+latex_header: \\usepackage{tikz}" =?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue