From d87f215e575f0d41c0adafc41beeae6dbae0f8d5 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 19 Jun 2024 10:07:18 +0200 Subject: [PATCH] Remove special parsing support for some tags. Those correspond to the elements that don't have content (i.e with `const` call in the rendering function). --- src/Slab/Evaluate.hs | 6 ++++++ src/Slab/Parse.hs | 11 +---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Slab/Evaluate.hs b/src/Slab/Evaluate.hs index 91cd7f8..e3649c8 100644 --- a/src/Slab/Evaluate.hs +++ b/src/Slab/Evaluate.hs @@ -44,6 +44,12 @@ defaultEnv = -- fragment. We need to be able to define @Div@ though. ("div", Frag ["content"] emptyEnv [BlockElem Div NoSym [] [BlockDefault "content" []]]) , ("br", Block (BlockElem Br NoSym [] [])) + , ("hr", Block (BlockElem Hr NoSym [] [])) + , ("meta", Block (BlockElem Meta NoSym [] [])) + , ("link", Block (BlockElem Link NoSym [] [])) + , ("source", Block (BlockElem Source NoSym [] [])) + , ("img", Block (BlockElem Img NoSym [] [])) + , ("input", Block (BlockElem Input NoSym [] [])) ] -------------------------------------------------------------------------------- diff --git a/src/Slab/Parse.hs b/src/Slab/Parse.hs index a1c017c..9ae22ba 100644 --- a/src/Slab/Parse.hs +++ b/src/Slab/Parse.hs @@ -291,11 +291,7 @@ parserElem = case name of "html" -> pure Html "body" -> pure Body - -- @div@ is now a fragment (function) in the environment. - -- "div" -> pure Div "span" -> pure Span - -- "br" -> pure Br - "hr" -> pure Hr "h1" -> pure H1 "h2" -> pure H2 "h3" -> pure H3 @@ -304,19 +300,15 @@ parserElem = "h6" -> pure H6 "header" -> pure Header "head" -> pure Head - "meta" -> pure Meta "main" -> pure Main "audio" -> pure Audio "a" -> pure A "code" -> pure Code - "img" -> pure Img "iframe" -> pure IFrame - "input" -> pure Input "i" -> pure I "pre" -> pure Pre "p" -> pure P "ul" -> pure Ul - "link" -> pure Link "li" -> pure Li "title" -> pure Title "table" -> pure Table @@ -337,7 +329,6 @@ parserElem = "script" -> pure Script "style" -> pure Style "small" -> pure Small - "source" -> pure Source "svg" -> pure Svg "textarea" -> pure Textarea "canvas" -> pure Canvas @@ -437,7 +428,7 @@ parserText :: Parser Text parserText = T.pack <$> lexeme (some (noneOf ['\n'])) "text content" parserIdentifier :: Parser Text -parserIdentifier = T.pack <$> lexeme (some (noneOf (" .=(){}\n" :: String))) "identifier" +parserIdentifier = T.pack <$> lexeme (some (noneOf (" .=#(){}\n" :: String))) "identifier" -------------------------------------------------------------------------------- parserInclude :: Parser (L.IndentOpt Parser Block Block)