aboutsummaryrefslogtreecommitdiff
path: root/src/Html.hs
diff options
context:
space:
mode:
authorsimonmar <unknown>2004-03-25 16:00:37 +0000
committersimonmar <unknown>2004-03-25 16:00:37 +0000
commitb7948ff0df532b33856884e66087f9ed340c6776 (patch)
tree17de5a37bd278a46764acd2adc2ad15eae8d9e01 /src/Html.hs
parentc2fff7f2d6c4776a4b8e2c39a6b964a9c7c175d1 (diff)
[haddock @ 2004-03-25 16:00:36 by simonmar]
Remove all that indentation in the generated HTML to keep the file sizes down.
Diffstat (limited to 'src/Html.hs')
-rw-r--r--src/Html.hs38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/Html.hs b/src/Html.hs
index 995719c8..59331cb2 100644
--- a/src/Html.hs
+++ b/src/Html.hs
@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
--- $Id: Html.hs,v 1.4 2004/03/25 15:45:10 simonmar Exp $
+-- $Id: Html.hs,v 1.5 2004/03/25 16:00:37 simonmar Exp $
--
-- An Html combinator library
--
@@ -962,10 +962,10 @@ gui act = form ! [action act,method "POST"]
-- The output is quite messy, because space matters in
-- HTML, so we must not generate needless spaces.
-renderHtml :: (HTML html) => html -> String
-renderHtml theHtml =
+renderHtml :: (HTML html) => html -> Bool -> String
+renderHtml theHtml pretty =
renderMessage ++
- foldr (.) id (map (renderHtml' 0)
+ foldr (.) id (map (if pretty then renderHtml' 0 else unprettyHtml)
(getHtmlElements (tag "HTML" << theHtml))) "\n"
renderMessage :: String
@@ -977,15 +977,6 @@ renderMessage =
-- This is intentually very inefficent to "encorage" this,
-- but the neater version in easier when debugging.
--- Local Utilities
-prettyHtml :: (HTML html) => html -> String
-prettyHtml theHtml =
- unlines
- $ concat
- $ map prettyHtml'
- $ getHtmlElements
- $ toHtml theHtml
-
renderHtml' :: Int -> HtmlElement -> ShowS
renderHtml' _ (HtmlString str) = (++) str
renderHtml' n (HtmlTag
@@ -998,6 +989,27 @@ renderHtml' n (HtmlTag
. foldr (.) id (map (renderHtml' (n+2)) (getHtmlElements html))
. renderTag False name0 [] n)
+unprettyHtml :: HtmlElement -> ShowS
+unprettyHtml (HtmlString str) = (++) str
+unprettyHtml (HtmlTag
+ { markupTag = name0,
+ markupContent = html,
+ markupAttrs = markupAttrs0 })
+ = if isNoHtml html && elem name0 validHtmlITags
+ then renderTag True name0 markupAttrs0 0
+ else (renderTag True name0 markupAttrs0 0
+ . foldr (.) id (map unprettyHtml (getHtmlElements html))
+ . renderTag False name0 [] 0)
+
+-- Local Utilities
+prettyHtml :: (HTML html) => html -> String
+prettyHtml theHtml =
+ unlines
+ $ concat
+ $ map prettyHtml'
+ $ getHtmlElements
+ $ toHtml theHtml
+
prettyHtml' :: HtmlElement -> [String]
prettyHtml' (HtmlString str) = [str]
prettyHtml' (HtmlTag