Hakyll.Web.Html

hakyll-4.7.5.1: A static website compiler library

Safe Haskell | None
Language | Haskell98

Hakyll.Web.Html

Contents

- Generic
- Headers
- Url manipulation
- Stripping/escaping

Description

Provides utilities to manipulate HTML pages

Synopsis

- withTags :: (Tag String -> Tag String) -> String -> String
- demoteHeaders :: String -> String
- getUrls :: [Tag String] -> [String]
- withUrls :: (String -> String) -> String -> String
- toUrl :: FilePath -> String
- toSiteRoot :: String -> String
- isExternal :: String -> Bool
- stripTags :: String -> String
- escapeHtml :: String -> String

# Generic

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

Map over all tags in the document

# Headers

demoteHeaders :: String -> String

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

# Url manipulation

getUrls :: [Tag String] -> [String]

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

Apply a function to each URL on a webpage

toUrl :: FilePath -> String

Convert a filepath to an URL starting from the site root

Example:

    toUrl "foo/bar.html"

Result:

    "/foo/bar.html"

This also sanitizes the URL, e.g. converting spaces into '%20'

toSiteRoot :: String -> String

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

isExternal :: String -> Bool

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

# Stripping/escaping

stripTags :: String -> String

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 -> String

HTML-escape a string

Example:

    escapeHtml "Me & Dean"

Result:

    "Me &amp; Dean"