pretty-html: Produce nice human-readable HTML

[ html, library, mit ] [ Propose Tags ]
This version is deprecated.

An HTML-building library that gives you some control over how the HTML is rendered, to produce human-readable results.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1 (info)
Dependencies base (>=4.13 && <4.17), text (>=1.2.4 && <1.3) [details]
License MIT
Copyright 2022 Mission Valley Software LLC
Author Chris Martin
Maintainer Chris Martin, Julie Moronuki
Category HTML
Home page https://github.com/typeclasses/pretty-html
Bug tracker https://github.com/typeclasses/pretty-html/issues
Source repo head: git clone https://github.com/typeclasses/pretty-html
Uploaded by chris_martin at 2022-02-22T12:30:59Z
Distributions NixOS:0.1.0.1
Downloads 127 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-02-22 [all 1 reports]

Readme for pretty-html-0.1.0.0

[back to package description]

Example:

document :: Html
document =
  fold
    [ tag' "!doctype" [attr' "html"]
    , inline $ comment "This is an HTML document."
    , tag "html" [attr "lang" "en"] $
        fold
          [ comment $ LazyText.unlines
              [ "A document consists of two main parts:"
              , "  1. The head, containing metadata"
              , "  2. The body, containing the visible content."
              ]
          , tag "head" [] $ fold
              [ inline $ tag "title" [] $ text "Example document"
              , tag' "meta"
                  [ attr "name" "viewport"
                  , attr "content" "width=device-width, initial-scale=1"
                  ]
              , tag' "meta"
                  [ attr "property" "description"
                  , attr "content" "This <html> was \"generated\" with Haskell."
                  ]
              , tag' "link"
                  [ attr "rel" "stylesheet"
                  , attr "type" "text/css"
                  , attr "href" "../examples.css"
                  ]
              ]
          , tag "body" [] $ fold
              [ inline $ tag "h1" [] $ text "The example doc"
              , inline $ tag "p" [] $ text "A list of uninteresting facts:"
              , tag "ol" [] $ fold
                  [ inline $ fold
                      [ tag' "li" []
                      , text "4 < 7"
                      ]
                  , inline $ fold
                      [ tag' "li" []
                      , text "Sometimes "
                      , tag "span" [attr "style" "font-weight: bold"] $
                          text "emboldened"
                      , text " text is used for emphasis."
                      ]
                  ]
              , inline $ tag "p" [] $ text "Please sign my guest book."
              , tag "form" [ attr "method" "POST"
                           , attr "action" "/cgi-bin/guestbook.php" ] $ fold
                  [ tag' "textarea" [attr "name" "message", attr' "autofocus"]
                  , tag' "br" []
                  , inline $ tag "button" [attr "type" "submit"] $ text "Submit"
                  ]
              ]
          ]
    ]

Generates the following HTML output:

<!doctype html>
<!-- This is an HTML document. -->
<html lang="en">
	<!--
		A document consists of two main parts:
		  1. The head, containing metadata
		  2. The body, containing the visible content.
	-->
	<head>
		<title>Example document</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta property="description" content="This &lt;htmlgt; was &quot;generated&quot; with Haskell.">
		<link rel="stylesheet" type="text/css" href="../examples.css">
	</head>
	<body>
		<h1>The example doc</h1>
		<p>A list of uninteresting facts:</p>
		<ol>
			<li>4 &lt; 7
			<li>Sometimes <span style="font-weight: bold">emboldened</span> text is used for emphasis.
		</ol>
		<p>Please sign my guest book.</p>
		<form method="POST" action="/cgi-bin/guestbook.php">
			<textarea name="message" autofocus>
			<br>
			<button type="submit">Submit</button>
		</form>
	</body>
</html>