From 2a87e61a0542139028a8e45993b2f918a9cff2e6 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Fri, 27 Feb 2026 22:51:28 -0500 Subject: [PATCH] oop html block got parsed correct and then didn't do correct whitespace --- TODO.md | 10 ++++++---- src/Markdown.hs | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 6745b57..88b2bfc 100644 --- a/TODO.md +++ b/TODO.md @@ -10,14 +10,16 @@ - Borsh - https://crates.io/crates/tree-sitter-highlight - Or potentially https://docs.rs/arborium/latest/arborium/ -- [ ] Refactor template handling so templates include other templates via lambda rather than implicitly https://hackage-content.haskell.org/package/mustache-2.4.3.1/docs/Text-Mustache.html#v:overText - [ ] Make a function which takes IR and spits out some kind of table of contents +- [ ] swap from using `draft` to using `date` for determing draft status, lack of date = draft +- [ ] setup font subsetting (font file minimization) + - `pyftsubset` (`fonttools subset`) is an external tool I can and probably should use + for this +- [ ] Refactor template handling so templates include other templates via lambda rather than implicitly https://hackage-content.haskell.org/package/mustache-2.4.3.1/docs/Text-Mustache.html#v:overText +- [ ] Fix time via timestamps potentially meaning something (via preshim?) and use local offset instead of absolute time https://www.rfc-editor.org/rfc/rfc3339#section-4.2 - [ ] Add rst or org support and convert markdown handling to custom parser instead of pandoc - [ ] Add in functionality for footnotes - There should be a per footnote template as well and also either the default or post template should have an attribute which handles footnotes -- [ ] swap from using `draft` to using `date` for determing draft status, lack of date = draft -- [ ] Fix time via timestamps potentially meaning something (via preshim?) and use local offset instead of absolute time https://www.rfc-editor.org/rfc/rfc3339#section-4.2 -- [ ] setup font subsetting (font file minimization) - [ ] dev server setup (with live reloading) - https://hackage-content.haskell.org/package/warp-3.4.10 - https://hackage.haskell.org/package/file-embed diff --git a/src/Markdown.hs b/src/Markdown.hs index 842575f..7702382 100644 --- a/src/Markdown.hs +++ b/src/Markdown.hs @@ -10,6 +10,7 @@ module Markdown (document, metadata) where import Control.Applicative (many, optional, some, (<|>)) import Control.Monad (guard, void) import Data.Functor.Identity (Identity) +import Data.List (intercalate) import Data.Maybe (fromMaybe, maybeToList) import Data.Proxy (Proxy (Proxy)) import Data.String (IsString) @@ -188,15 +189,16 @@ htmlBlock = do attrs <- if not hasEnded then - Just . toText . mconcat <$> htmlAttrs + Just . toText . intercalate " " <$> htmlAttrs else pure Nothing + -- technically not standard markdown but I don't want to write a full HTML parser in my inside <- many (notFollowedBy ((chunk $ " tagName <> ">") <|> chunk "") *> anySingle) end <- toText <$> ((chunk $ " tagName <> ">") <|> chunk "") -- if a blockEnding after some whitespace isn't next when we should parse this as inline text/paragraph many ((notFollowedBy lineEnding) *> spaceChar) lookAhead blockEnding - pure $ HTML $ HTMLTag $ T.concat ["<", toText tagName, fromMaybe "" attrs, ">", T.pack inside, if end == "" then "" else end] + pure $ HTML $ HTMLTag $ T.concat ["<", toText tagName, " ", fromMaybe "" attrs, ">", T.pack inside, if end == "" then "" else end] where tagNameEnd = (lookAhead spaceChar <* space) <|> char '>' htmlAttrs = ((notFollowedBy $ char '>') *> htmlAttr) `sepBy` space