pretty-html: Produce nice human-readable HTML

[ html, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

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


[Skip to Readme]

library pretty-html

library pretty-html:pretty-html-paths

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

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)
Change log changelog.md
Dependencies base (>=4.14 && <4.19), text (>=1.2.4 && <1.3 || >=2.0 && <2.1) [details]
License MIT
Copyright 2022 Mission Valley Software LLC
Author Chris Martin
Maintainer Chris Martin, Julie Moronuki
Revised Revision 1 made by chris_martin at 2023-05-23T18:45:51Z
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 2023-01-10T21:08:53Z
Distributions NixOS:0.1.0.1
Downloads 170 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-01-10 [all 1 reports]

Readme for pretty-html-0.1.0.1

[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;html&gt; 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>