File: Html.hs

package info (click to toggle)
haskell-hledger-lib 1.50.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,520 kB
  • sloc: haskell: 16,495; makefile: 7
file content (41 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{- |
HTML writing helpers.
This module would ideally hide the details of which HTML library is used, but it doesn't yet.

Currently hledger-web uses blaze-html, but hledger CLI reports use lucid.
lucid has a more usable API than blaze-html (https://chrisdone.com/posts/lucid).
lucid2's is even better.
Unfortunately lucid* can not render multi-line or indented text.
We want this so that humans can read and troubleshoot our HTML output.
So a transition to blaze-html may be coming.

-}

{-# LANGUAGE OverloadedStrings #-}

module Hledger.Write.Html (
  L.toHtml,
  Html,
  formatRow,
  htmlAsText,
  htmlAsLazyText,
  styledTableHtml,
  tests_Hledger_Write_Html
  ) where

import Data.Text qualified as T (Text)
import Data.Text.Lazy qualified as TL (Text, toStrict)
import Lucid qualified as L (renderText, toHtml)
import Test.Tasty (testGroup)

import Hledger.Write.Html.Lucid (Html, formatRow, styledTableHtml)


htmlAsText :: Html -> T.Text
htmlAsText = TL.toStrict . L.renderText

htmlAsLazyText :: Html -> TL.Text
htmlAsLazyText = L.renderText

tests_Hledger_Write_Html = testGroup "Write.Html" [
  ]