debugging continues

This commit is contained in:
Pagwin 2025-11-14 01:35:44 -05:00
parent ebcb13929a
commit 843fb5dc40
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -24,6 +24,12 @@ type Parser = ParserT IO
log_ :: String -> Parser () log_ :: String -> Parser ()
log_ = lift . putStrLn log_ = lift . putStrLn
logP :: (Show s) => Parser s -> Parser s
logP v = do
underlying <- v
log_ $ show underlying
v
anyChar :: Parser Char anyChar :: Parser Char
anyChar = anySingle anyChar = anySingle
@ -71,7 +77,7 @@ element =
-- Blank lines (consumed but not stored) -- Blank lines (consumed but not stored)
blankLines :: Parser Element blankLines :: Parser Element
blankLines = do blankLines = do
skipMany1 blankLine skipMany1 (blankLine *> notFollowedBy eof)
element <|> fmap (const $ HTML HTMLTag {html_content = ""}) eof -- Parse the next element (or handle eof) element <|> fmap (const $ HTML HTMLTag {html_content = ""}) eof -- Parse the next element (or handle eof)
blankLine :: Parser () blankLine :: Parser ()
@ -84,11 +90,11 @@ blankLine = do
headingBlock :: Parser Element headingBlock :: Parser Element
headingBlock = do headingBlock = do
hashes <- some (char '#') <?> "Heading Hashes" hashes <- some (char '#') <?> "Heading Hashes"
log_ "heading"
let level = length hashes let level = length hashes
guard (level <= 6) <?> "Higher than level 6" guard (level <= 6) <?> "Higher than level 6"
many (char ' ' <|> char '\t') <?> "Pre-Text Whitespace" many (char ' ' <|> char '\t') <?> "Pre-Text Whitespace"
content <- manyTill ((inlineElement <* log_ "element") <?> "Header Text") (try lineEnding <?> "Header Ending") log_ "heading content start"
content <- manyTill (inlineElement <?> "Header Text") (log_ "attempt" *> try lineEnding <?> "Header Ending")
pure $ Heading $ H level content pure $ Heading $ H level content
-- Fenced Code Block -- Fenced Code Block
@ -252,17 +258,18 @@ paragraphBlock = do
-- Inline Elements -- Inline Elements
inlineElement :: Parser InlineText inlineElement :: Parser InlineText
inlineElement = inlineElement =
choice logP $
[ try strong <?> "Inline Strong Text", choice
try emphasis <?> "Inline Italic Text", [ try strong <?> "Inline Strong Text",
try crossedText <?> "Inline Crossed Text", try emphasis <?> "Inline Italic Text",
try codeSpan <?> "Inline Code", try crossedText <?> "Inline Crossed Text",
try image <?> "Inline Image", try codeSpan <?> "Inline Code",
try link <?> "Inline Link", try image <?> "Inline Image",
try htmlInline <?> "Inline HTML", try link <?> "Inline Link",
try escapedChar <?> "Escaped Character", try htmlInline <?> "Inline HTML",
plainText <?> "Inline Plain Text" try escapedChar <?> "Escaped Character",
] plainText <?> "Inline Plain Text"
]
-- Strong (Bold) -- Strong (Bold)
strong :: Parser InlineText strong :: Parser InlineText