Skip to content

Commit a60ebc1

Browse files
committed
Fix parser to return comment line as is
1 parent f28313d commit a60ebc1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Parse.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,14 @@ line = (anyChar `manyTill` newline) <?> "rest of line"
390390
whitespacechar = oneOf " \t"
391391
whitespace = many whitespacechar
392392
whitespaceline = try (newline >> return "") <|> try (whitespacechar >> whitespacechar `manyTill` newlineoreof)
393+
393394
-- a line beginning with optional whitespace and #, or beginning with one or more * (an org node)
394-
commentline = try ((many1 (char '*') <|> (whitespace >> many1 (char '#'))) >> lineoreof) <?> "comments"
395+
commentline = try (do
396+
prefix <- many1 (char '*') <|> (whitespace >> many1 (char '#'))
397+
rest <- lineoreof
398+
return $ prefix ++ rest
399+
) <?> "comments"
400+
395401
whitespaceorcommentline = commentline <|> whitespaceline
396402
whitespaceorcommentlineoreof = choice [eofasstr, commentline, whitespaceline]
397403
eofasstr = eof >> return ""

src/Print.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ printShellTest format actualMode ShellTest{command=c,stdin=i,comments=comments,
5858
| otherwise = fail "Unsupported argument for --actual option. Allowed: all, update, or a prefix thereof."
5959

6060
printComments :: [String] -> IO ()
61-
printComments = mapM_ (putStrLn . ("#"++)) -- TODO commentline discards leading space and comment character :(
61+
printComments = mapM_ putStrLn
6262

6363
printStdin :: String -> Maybe String -> IO ()
6464
printStdin _ (Just "") = return ()

0 commit comments

Comments
 (0)