From 843fb5dc40d9a8c61b977d087460a04ac4a3742a Mon Sep 17 00:00:00 2001 From: Pagwin Date: Fri, 14 Nov 2025 01:35:44 -0500 Subject: [PATCH] debugging continues --- app/Markdown.hs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/Markdown.hs b/app/Markdown.hs index 2a4a6ec..f3d453e 100644 --- a/app/Markdown.hs +++ b/app/Markdown.hs @@ -24,6 +24,12 @@ type Parser = ParserT IO log_ :: String -> Parser () log_ = lift . putStrLn +logP :: (Show s) => Parser s -> Parser s +logP v = do + underlying <- v + log_ $ show underlying + v + anyChar :: Parser Char anyChar = anySingle @@ -71,7 +77,7 @@ element = -- Blank lines (consumed but not stored) blankLines :: Parser Element blankLines = do - skipMany1 blankLine + skipMany1 (blankLine *> notFollowedBy eof) element <|> fmap (const $ HTML HTMLTag {html_content = ""}) eof -- Parse the next element (or handle eof) blankLine :: Parser () @@ -84,11 +90,11 @@ blankLine = do headingBlock :: Parser Element headingBlock = do hashes <- some (char '#') "Heading Hashes" - log_ "heading" let level = length hashes guard (level <= 6) "Higher than level 6" 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 -- Fenced Code Block @@ -252,17 +258,18 @@ paragraphBlock = do -- Inline Elements inlineElement :: Parser InlineText inlineElement = - choice - [ try strong "Inline Strong Text", - try emphasis "Inline Italic Text", - try crossedText "Inline Crossed Text", - try codeSpan "Inline Code", - try image "Inline Image", - try link "Inline Link", - try htmlInline "Inline HTML", - try escapedChar "Escaped Character", - plainText "Inline Plain Text" - ] + logP $ + choice + [ try strong "Inline Strong Text", + try emphasis "Inline Italic Text", + try crossedText "Inline Crossed Text", + try codeSpan "Inline Code", + try image "Inline Image", + try link "Inline Link", + try htmlInline "Inline HTML", + try escapedChar "Escaped Character", + plainText "Inline Plain Text" + ] -- Strong (Bold) strong :: Parser InlineText