hakyll-4.2.1.0: A static website compiler library

Safe HaskellNone

Hakyll.Web.Html

Contents

Description

Provides utilities to manipulate HTML pages

Synopsis

Generic

withTags :: (Tag String -> Tag String) -> String -> StringSource

Map over all tags in the document

Headers

demoteHeaders :: String -> StringSource

Map every h1 to an h2, h2 to h3, etc.

Url manipulation

withUrls :: (String -> String) -> String -> StringSource

Apply a function to each URL on a webpage

toUrl :: FilePath -> StringSource

Convert a filepath to an URL starting from the site root

Example:

 toUrl "foo/bar.html"

Result:

 "/foo/bar.html"

toSiteRoot :: String -> StringSource

Get the relative url to the site root, for a given (absolute) url

isExternal :: String -> BoolSource

Check if an URL links to an external HTTP(S) source

Stripping/escaping

stripTags :: String -> StringSource

Strip all HTML tags from a string

Example:

 stripTags "<p>foo</p>"

Result:

 "foo"

This also works for incomplete tags

Example:

 stripTags "<p>foo</p"

Result:

 "foo"

escapeHtml :: String -> StringSource

HTML-escape a string

Example:

 escapeHtml "Me & Dean"

Result:

 "Me &amp; Dean"