This commit is contained in:
Pagwin 2025-09-21 17:52:22 -04:00
parent 94d7047534
commit 0658c2806b
No known key found for this signature in database
GPG key ID: 81137023740CA260
4 changed files with 29 additions and 15 deletions

View file

@ -4,6 +4,10 @@
- minify js and css when copying over instead of just copying
- look into adding postcss support perhaps
- setup fingerprinting in file names for css and js
- dev server setup (with live reloading)
- see if performance can be improved (it isn't slow atm but it definitely feels like there's a bottleneck)
- look into adding postcss support perhaps

View file

@ -20,7 +20,6 @@ data List = L {list_type :: ListType, items :: [ListItem]}
data Table = T {header :: TableHeader, rows :: [TableRow]}
-- TODO: layout/sizing info?
newtype TableHeader = TH [Text]
newtype TableRow = TR Text
@ -29,7 +28,7 @@ newtype HTML = Raw Text
newtype Paragraph = P [InlineText]
data InlineText = Normal Text | Bold InlineText | Italic InlineText | CodeLine Text | Link {nest :: InlineText, href :: Text}
data InlineText = Normal Text | Escaped Char | Bold InlineText | Italic InlineText | CodeLine Text | Link {nest :: InlineText, href :: Text} | HTMLIn Text
data BlankLine = BL

View file

@ -39,7 +39,8 @@ paragraph :: Parser Element
paragraph = do
first <- paragraphLine
rem <- many paragraphContinuation
pure $ Paragraph $ P []
let combined = Prelude.concat (first : rem)
pure $ Paragraph $ P combined
paragraphLine :: Parser [InlineText]
paragraphLine = many inlineText <* endOfLine
@ -48,12 +49,24 @@ paragraphContinuation :: Parser [InlineText]
paragraphContinuation = notFollowedBy blockElemStart *> paragraphLine
inlineText :: Parser InlineText
inlineText = choice [emphasis, strong, inlineCode, link, image, inlineHTML, paragraphLineBreak, escapedChar, plainText]
inlineText = choice [emphasis, strong, inlineCode, link, image, inlineHTML, escapedChar, plainText]
plainText :: Parser Text
plainText =
plainText :: Parser InlineText
-- abnf is very specific about what's allowed due to actual ABNF not allowing negation but I'm lazy
plainText = fmap (Normal . pack) $ many $ noneOf "*_`[]()<>#+-.!&\\\n"
blankLine :: Parser Element
blankLine = do
endOfLine
pure $ BlankLine BL
escapedChar :: Parser InlineText
escapedChar = char '\\' *> fmap Escaped visibleChar
htmlInline :: Parser InlineText
htmlInline = do
_ <- char '<'
remaining <- htmlInlineRemainder
pure $ HTMLIn $ pack $ '<' : remaining
where
htmlInlineRemainder = tagName *> attrList
tagName = many $ choice [alphaNum, char '-', char ':']
visibleChar :: Parser Char
-- technically more strict but I'm just going to hope I never have to deal with that
visibleChar = anyChar

View file

@ -73,11 +73,11 @@ paragraph-continuation = paragraph-first-element *( inline-element ) line-ending
; First element of paragraph - anything that's not a block starter
paragraph-first-element = emphasis / strong / code-span / link / image /
html-inline / line-break / escaped-char / plain-text
html-inline / escaped-char / plain-text
; Inline elements
inline-element = emphasis / strong / code-span / link / image /
html-inline / line-break / escaped-char / plain-text
html-inline / escaped-char / plain-text
; Emphasis and strong (left-factored by delimiter)
emphasis = emphasis-asterisk / emphasis-underscore
@ -135,8 +135,6 @@ attribute-value-squote = *( %x20-26 / %x28-10FFFF ) ; Everything except '
attribute-value-unquoted = 1*( %x21-22 / %x24-26 / %x28-2F / %x30-3D / %x3F-10FFFF )
html-content = *( %x20-3B / %x3D-10FFFF ) ; Everything except <
; Line breaks and escaped characters
line-break = 2*WSP line-ending
escaped-char = "\" VCHAR
; Plain text variations (to avoid conflicts)