c55a54796a
Three categories of fixes:
1. Multi-line steps: removed \n from pText exclusion list so newlines
within a step are consumed as regular text
2. Range timers (e.g. ~{14-18%minutes}): handle hyphen-separated
ranges in parseSimpleRational by taking the lower value
3. & in ingredient names: added & to pSingleNameChar and
pMultiNameChar char sets
4. Markdown-style # headings: added pAnyChar fallback so # followed
by invalid cookware name falls through to text consumption
5. Note detection: tightened > check to require > (with space)
or > followed by non->, preventing >> metadata from being
treated as notes
28 lines
1.0 KiB
Haskell
28 lines
1.0 KiB
Haskell
module Main where
|
|
|
|
import System.Directory (listDirectory)
|
|
import System.FilePath (takeExtension)
|
|
import qualified Data.Text as T
|
|
import qualified Data.Text.IO as TIO
|
|
import Roux.Parser (parseCookFile)
|
|
|
|
main :: IO ()
|
|
main = do
|
|
entries <- listDirectory "/work/personal-recipes"
|
|
let cookFiles = filter ((== ".cook") . takeExtension) (map ("/work/personal-recipes/" ++) entries)
|
|
results <- mapM testParse cookFiles
|
|
let failures = [(name, err) | Right (name, err) <- results]
|
|
successes = length [() | Left name <- results]
|
|
putStrLn $ "\n=== Summary ==="
|
|
putStrLn $ "Total: " ++ show (length results)
|
|
putStrLn $ "OK: " ++ show successes
|
|
putStrLn $ "Failures: " ++ show (length failures)
|
|
mapM_ (\(name, err) -> putStrLn $ "\n " ++ name ++ ":\n " ++ err) failures
|
|
where
|
|
testParse fp = do
|
|
let name = reverse . takeWhile (/= '/') . reverse $ fp
|
|
content <- TIO.readFile fp
|
|
case parseCookFile content of
|
|
Left err -> pure (Right (name, err))
|
|
Right _ -> pure (Left name)
|