lucid-svg-0.7.0.0: DSL for SVG using lucid for HTML

Copyright | (c) 2015 Jeffrey Rosenbluth
License | BSD-style (see LICENSE)
Maintainer | jeffrey.rosenbluth@gmail.com
Safe Haskell | None
Language | Haskell2010

Lucid.Svg

Contents

- Intro
- Rendering
- Re-exports
- From Lucid.Base
  - Running
  - Types
  - Classes

Description

DSL for creating SVG.

Synopsis

- type Svg = SvgT Identity
- prettyText :: Svg a -> Text
- module Lucid.Svg.Path
- module Lucid.Svg.Elements
- accent_height_ :: Text -> Attribute
- accumulate_ :: Text -> Attribute
- additive_ :: Text -> Attribute
- alignment_baseline_ :: Text -> Attribute
- alphabetic_ :: Text -> Attribute
- amplitude_ :: Text -> Attribute
- arabic_form_ :: Text -> Attribute
- ascent_ :: Text -> Attribute
- attributeName_ :: Text -> Attribute
- attributeType_ :: Text -> Attribute
- azimuth_ :: Text -> Attribute
- baseFrequency_ :: Text -> Attribute
- baseprofile_ :: Text -> Attribute
- baseline_shift_ :: Text -> Attribute
- bbox_ :: Text -> Attribute
- begin_ :: Text -> Attribute
- bias_ :: Text -> Attribute
- by_ :: Text -> Attribute
- calcMode_ :: Text -> Attribute
- cap_height_ :: Text -> Attribute
- class_ :: Text -> Attribute
- clip_ :: Text -> Attribute
- clip_path_ :: Text -> Attribute
- clip_rule_ :: Text -> Attribute
- clipPathUnits_ :: Text -> Attribute
- color_ :: Text -> Attribute
- color_interpolation_ :: Text -> Attribute
- color_interpolation_filters_ :: Text -> Attribute
- color_profile_ :: Text -> Attribute
- color_rendering_ :: Text -> Attribute
- contentScriptType_ :: Text -> Attribute
- contentStyleType_ :: Text -> Attribute
- cx_ :: Text -> Attribute
- cy_ :: Text -> Attribute
- d_ :: Text -> Attribute
- descent_ :: Text -> Attribute
- diffuseConstant_ :: Text -> Attribute
- direction_ :: Text -> Attribute
- display_ :: Text -> Attribute
- divisor_ :: Text -> Attribute
- dominant_baseline_ :: Text -> Attribute
- dur_ :: Text -> Attribute
- dx_ :: Text -> Attribute
- dy_ :: Text -> Attribute
- edgeMode_ :: Text -> Attribute
- elevation_ :: Text -> Attribute
- enable_background_ :: Text -> Attribute
- end_ :: Text -> Attribute
- exponent_ :: Text -> Attribute
- externalResourcesRequired_ :: Text -> Attribute
- fill_ :: Text -> Attribute
- fill_opacity_ :: Text -> Attribute
- fill_rule_ :: Text -> Attribute
- filterRes_ :: Text -> Attribute
- filterUnits_ :: Text -> Attribute
- flood_color_ :: Text -> Attribute
- flood_opacity_ :: Text -> Attribute
- font_family_ :: Text -> Attribute
- font_size_ :: Text -> Attribute
- font_size_adjust_ :: Text -> Attribute
- font_stretch_ :: Text -> Attribute
- font_style_ :: Text -> Attribute
- font_variant_ :: Text -> Attribute
- font_weight_ :: Text -> Attribute
- format_ :: Text -> Attribute
- from_ :: Text -> Attribute
- fx_ :: Text -> Attribute
- fy_ :: Text -> Attribute
- g1_ :: Text -> Attribute
- g2_ :: Text -> Attribute
- glyph_name_ :: Text -> Attribute
- glyph_orientation_horizontal_ :: Text -> Attribute
- glyph_orientation_vertical_ :: Text -> Attribute
- gradientTransform_ :: Text -> Attribute
- gradientUnits_ :: Text -> Attribute
- hanging_ :: Text -> Attribute
- height_ :: Text -> Attribute
- horiz_adv_x_ :: Text -> Attribute
- horiz_origin_x_ :: Text -> Attribute
- horiz_origin_y_ :: Text -> Attribute
- id_ :: Text -> Attribute
- ideographic_ :: Text -> Attribute
- image_rendering_ :: Text -> Attribute
- in_ :: Text -> Attribute
- in2_ :: Text -> Attribute
- intercept_ :: Text -> Attribute
- k_ :: Text -> Attribute
- k1_ :: Text -> Attribute
- k2_ :: Text -> Attribute
- k3_ :: Text -> Attribute
- k4_ :: Text -> Attribute
- kernelMatrix_ :: Text -> Attribute
- kernelUnitLength_ :: Text -> Attribute
- kerning_ :: Text -> Attribute
- keyPoints_ :: Text -> Attribute
- keySplines_ :: Text -> Attribute
- keyTimes_ :: Text -> Attribute
- lang_ :: Text -> Attribute
- lengthAdjust_ :: Text -> Attribute
- letter_spacing_ :: Text -> Attribute
- lighting_color_ :: Text -> Attribute
- limitingConeAngle_ :: Text -> Attribute
- local_ :: Text -> Attribute
- marker_end_ :: Text -> Attribute
- marker_mid_ :: Text -> Attribute
- marker_start_ :: Text -> Attribute
- markerHeight_ :: Text -> Attribute
- markerUnits_ :: Text -> Attribute
- markerWidth_ :: Text -> Attribute
- maskContentUnits_ :: Text -> Attribute
- maskUnits_ :: Text -> Attribute
- mathematical_ :: Text -> Attribute
- max_ :: Text -> Attribute
- media_ :: Text -> Attribute
- method_ :: Text -> Attribute
- min_ :: Text -> Attribute
- mode_ :: Text -> Attribute
- name_ :: Text -> Attribute
- numOctaves_ :: Text -> Attribute
- offset_ :: Text -> Attribute
- onabort_ :: Text -> Attribute
- onactivate_ :: Text -> Attribute
- onbegin_ :: Text -> Attribute
- onclick_ :: Text -> Attribute
- onend_ :: Text -> Attribute
- onerror_ :: Text -> Attribute
- onfocusin_ :: Text -> Attribute
- onfocusout_ :: Text -> Attribute
- onload_ :: Text -> Attribute
- onmousedown_ :: Text -> Attribute
- onmousemove_ :: Text -> Attribute
- onmouseout_ :: Text -> Attribute
- onmouseover_ :: Text -> Attribute
- onmouseup_ :: Text -> Attribute
- onrepeat_ :: Text -> Attribute
- onresize_ :: Text -> Attribute
- onscroll_ :: Text -> Attribute
- onunload_ :: Text -> Attribute
- onzoom_ :: Text -> Attribute
- opacity_ :: Text -> Attribute
- operator_ :: Text -> Attribute
- order_ :: Text -> Attribute
- orient_ :: Text -> Attribute
- orientation_ :: Text -> Attribute
- origin_ :: Text -> Attribute
- overflow_ :: Text -> Attribute
- overline_position_ :: Text -> Attribute
- overline_thickness_ :: Text -> Attribute
- panose_1_ :: Text -> Attribute
- paint_order_ :: Text -> Attribute
- pathLength_ :: Text -> Attribute
- patternContentUnits_ :: Text -> Attribute
- patternTransform_ :: Text -> Attribute
- patternUnits_ :: Text -> Attribute
- pointer_events_ :: Text -> Attribute
- points_ :: Text -> Attribute
- pointsAtX_ :: Text -> Attribute
- pointsAtY_ :: Text -> Attribute
- pointsAtZ_ :: Text -> Attribute
- preserveAlpha_ :: Text -> Attribute
- preserveAspectRatio_ :: Text -> Attribute
- primitiveUnits_ :: Text -> Attribute
- r_ :: Text -> Attribute
- radius_ :: Text -> Attribute
- refX_ :: Text -> Attribute
- refY_ :: Text -> Attribute
- rendering_intent_ :: Text -> Attribute
- repeatCount_ :: Text -> Attribute
- repeatDur_ :: Text -> Attribute
- requiredExtensions_ :: Text -> Attribute
- requiredFeatures_ :: Text -> Attribute
- restart_ :: Text -> Attribute
- result_ :: Text -> Attribute
- rotate_ :: Text -> Attribute
- rx_ :: Text -> Attribute
- ry_ :: Text -> Attribute
- scale_ :: Text -> Attribute
- seed_ :: Text -> Attribute
- shape_rendering_ :: Text -> Attribute
- slope_ :: Text -> Attribute
- spacing_ :: Text -> Attribute
- specularConstant_ :: Text -> Attribute
- specularExponent_ :: Text -> Attribute
- spreadMethod_ :: Text -> Attribute
- startOffset_ :: Text -> Attribute
- stdDeviation_ :: Text -> Attribute
- stemh_ :: Text -> Attribute
- stemv_ :: Text -> Attribute
- stitchTiles_ :: Text -> Attribute
- stop_color_ :: Text -> Attribute
- stop_opacity_ :: Text -> Attribute
- strikethrough_position_ :: Text -> Attribute
- strikethrough_thickness_ :: Text -> Attribute
- string_ :: Text -> Attribute
- stroke_ :: Text -> Attribute
- stroke_dasharray_ :: Text -> Attribute
- stroke_dashoffset_ :: Text -> Attribute
- stroke_linecap_ :: Text -> Attribute
- stroke_linejoin_ :: Text -> Attribute
- stroke_miterlimit_ :: Text -> Attribute
- stroke_opacity_ :: Text -> Attribute
- stroke_width_ :: Text -> Attribute
- surfaceScale_ :: Text -> Attribute
- systemLanguage_ :: Text -> Attribute
- tableValues_ :: Text -> Attribute
- target_ :: Text -> Attribute
- targetX_ :: Text -> Attribute
- targetY_ :: Text -> Attribute
- text_anchor_ :: Text -> Attribute
- text_decoration_ :: Text -> Attribute
- text_rendering_ :: Text -> Attribute
- textLength_ :: Text -> Attribute
- to_ :: Text -> Attribute
- transform_ :: Text -> Attribute
- type_ :: Text -> Attribute
- u1_ :: Text -> Attribute
- u2_ :: Text -> Attribute
- underline_position_ :: Text -> Attribute
- underline_thickness_ :: Text -> Attribute
- unicode_ :: Text -> Attribute
- unicode_bidi_ :: Text -> Attribute
- unicode_range_ :: Text -> Attribute
- units_per_em_ :: Text -> Attribute
- v_alphabetic_ :: Text -> Attribute
- v_hanging_ :: Text -> Attribute
- v_ideographic_ :: Text -> Attribute
- v_mathematical_ :: Text -> Attribute
- values_ :: Text -> Attribute
- version_ :: Text -> Attribute
- vert_adv_y_ :: Text -> Attribute
- vert_origin_x_ :: Text -> Attribute
- vert_origin_y_ :: Text -> Attribute
- viewBox_ :: Text -> Attribute
- viewTarget_ :: Text -> Attribute
- visibility_ :: Text -> Attribute
- width_ :: Text -> Attribute
- widths_ :: Text -> Attribute
- word_spacing_ :: Text -> Attribute
- writing_mode_ :: Text -> Attribute
- x_ :: Text -> Attribute
- x_height_ :: Text -> Attribute
- x1_ :: Text -> Attribute
- x2_ :: Text -> Attribute
- xChannelSelector_ :: Text -> Attribute
- xlinkActuate_ :: Text -> Attribute
- xlinkArcrole_ :: Text -> Attribute
- xlinkHref_ :: Text -> Attribute
- xlinkRole_ :: Text -> Attribute
- xlinkShow_ :: Text -> Attribute
- xlinkTitle_ :: Text -> Attribute
- xlinkType_ :: Text -> Attribute
- xmlBase_ :: Text -> Attribute
- xmlLang_ :: Text -> Attribute
- xmlSpace_ :: Text -> Attribute
- y_ :: Text -> Attribute
- y1_ :: Text -> Attribute
- y2_ :: Text -> Attribute
- yChannelselector_ :: Text -> Attribute
- z_ :: Text -> Attribute
- zoomAndPan_ :: Text -> Attribute
- renderText :: Html a -> Text
- renderBS :: Html a -> ByteString
- renderTextT :: Monad m => HtmlT m a -> m Text
- renderBST :: Monad m => HtmlT m a -> m ByteString
- renderToFile :: FilePath -> Html a -> IO ()
- execHtmlT :: Monad m => HtmlT m a -> m Builder
- evalHtmlT :: Monad m => HtmlT m a -> m a
- runHtmlT :: HtmlT m a -> m (HashMap Text Text -> Builder, a)
- data Attribute = Attribute !Text !Text
- class Term arg result | result -> arg where
  - term :: Text -> arg -> result
  - termWith :: Text -> [Attribute] -> arg -> result
- class ToHtml a where
  - toHtml :: Monad m => a -> HtmlT m ()
  - toHtmlRaw :: Monad m => a -> HtmlT m ()
- class With a where
  - with :: a -> [Attribute] -> a

# Intro

SVG elements and attributes in Lucid-Svg are written with a postfix ‘`_`’. Some examples:

`path_`, `circle_`, `color_`, `scale_`

Note: If you're testing in the REPL you need to add a type annotation to indicate that you want SVG. In normal code your top-level declaration signatures handle that.

Plain text is written using the `OverloadedStrings` and `ExtendedDefaultRules` extensions, and is automatically escaped:

As in Lucid, elements nest by function application:

    >>> g_ (text_ "Hello SVG") :: Svg ()
    <g><text>Hello SVG</text></g>

and elements are juxtaposed via monoidal append or monadic sequencing:

    >>> text_ "Hello" <> text_ "SVG" :: Svg ()
    <text>Hello</text><text>SVG</text>

    >>> do text_ "Hello"; text_ "SVG" :: Svg ()
    <text>Hello</text><text>SVG</text>

Attributes are set by providing an argument list. In contrast to HTML many SVG elements have no content, only attributes.

    >>> rect_ [width_ "100%", height_ "100%", fill_ "red"] :: Svg ()
    <rect height="100%" width="100%" fill="red"></rect>

Attributes and elements that share the same name are not conflicting unless they appear on the list in the note below:

    >>> mask_ [mask_ "attribute"] "element" :: Svg ()
    <mask mask="attribute">element</mask>

Note: The following element and attribute names overlap and cannot be handled polymorphically since doing so would create conflicting functional dependencies. The unqualifed name refers to the element. We qualify the attribute name as `A`. For example, `path_` and `path_`.

`colorProfile_`, `cursor_`, `filter_`, `path_`, and `style_`

Path data can be constructed using the functions in `Path` and combined monoidally:

    path_ (
      [ d_ (mA 10 80 <> qA 52.5 10 95 80 <> tA 180 80 <> z)
      , stroke_ "blue"
      , fill_ "orange"
      ])

    <path d="M 10,80 Q 52.5,10 95,80 T 180,80 Z" stroke="blue" fill="orange"></path>

A slightly longer example:

    import Lucid.Svg

    svg :: Svg () -> Svg ()
    svg content = do
      doctype_
      with (svg11_ content) [version_ "1.1", width_ "300" , height_ "200"]

    contents :: Svg ()
    contents = do
      rect_ [width_ "100%", height_ "100%", fill_ "red"]
      circle_ [cx_ "150", cy_ "100", r_ "80", fill_ "green"]
      text_ [x_ "150", y_ "125", fontSize_ "60", textAnchor_ "middle", fill_ "white"] "SVG"

    main :: IO ()
    main = do
      print $ svg contents

type Svg = SvgT Identity Source #

# Rendering

prettyText :: Svg a -> Text Source #

# Re-exports

module Lucid.Svg.Path

module Lucid.Svg.Elements

accent_height_ :: Text -> Attribute Source #

The `accentHeight` attribute.

accumulate_ :: Text -> Attribute Source #

The `accumulate` attribute.

additive_ :: Text -> Attribute Source #

The `additive` attribute.

alignment_baseline_ :: Text -> Attribute Source #

The `alignmentBaseline` attribute.

alphabetic_ :: Text -> Attribute Source #

The `alphabetic` attribute.

amplitude_ :: Text -> Attribute Source #

The `amplitude` attribute.

arabic_form_ :: Text -> Attribute Source #

The `arabicForm` attribute.

ascent_ :: Text -> Attribute Source #

The `ascent` attribute.

attributeName_ :: Text -> Attribute Source #

The `attributename` attribute.

attributeType_ :: Text -> Attribute Source #

The `attributetype` attribute.

azimuth_ :: Text -> Attribute Source #

The `azimuth` attribute.

baseFrequency_ :: Text -> Attribute Source #

The `basefrequency` attribute.

baseprofile_ :: Text -> Attribute Source #

The `baseprofile` attribute.

baseline_shift_ :: Text -> Attribute Source #

The `baselineShift` attribute.

bbox_ :: Text -> Attribute Source #

The `bbox` attribute.

begin_ :: Text -> Attribute Source #

The `begin` attribute.

bias_ :: Text -> Attribute Source #

The `bias` attribute.

by_ :: Text -> Attribute Source #

The `by` attribute.

calcMode_ :: Text -> Attribute Source #

The `calcmode` attribute.

cap_height_ :: Text -> Attribute Source #

The `capHeight` attribute.

class_ :: Text -> Attribute Source #

The `class` attribute.

clip_ :: Text -> Attribute Source #

The `clip` attribute.

clip_path_ :: Text -> Attribute Source #

The `clip-path` attribute.

clip_rule_ :: Text -> Attribute Source #

The `clipRule` attribute.

clipPathUnits_ :: Text -> Attribute Source #

The `clippathunits` attribute.

color_ :: Text -> Attribute Source #

The `color` attribute.

color_interpolation_ :: Text -> Attribute Source #

The `colorInterpolation` attribute.

color_interpolation_filters_ :: Text -> Attribute Source #

The `colorInterpolationFilters` attribute.

color_profile_ :: Text -> Attribute Source #

The `colorProfile` attribute.

color_rendering_ :: Text -> Attribute Source #

The `colorRendering` attribute.

contentScriptType_ :: Text -> Attribute Source #

The `contentscripttype` attribute.

contentStyleType_ :: Text -> Attribute Source #

The `contentstyletype` attribute.

cx_ :: Text -> Attribute Source #

The `cx` attribute.

cy_ :: Text -> Attribute Source #

The `cy` attribute.

d_ :: Text -> Attribute Source #

The `d` attribute.

descent_ :: Text -> Attribute Source #

The `descent` attribute.

diffuseConstant_ :: Text -> Attribute Source #

The `diffuseconstant` attribute.

direction_ :: Text -> Attribute Source #

The `direction` attribute.

display_ :: Text -> Attribute Source #

The `display` attribute.

divisor_ :: Text -> Attribute Source #

The `divisor` attribute.

dominant_baseline_ :: Text -> Attribute Source #

The `dominantBaseline` attribute.

dur_ :: Text -> Attribute Source #

The `dur` attribute.

dx_ :: Text -> Attribute Source #

The `dx` attribute.

dy_ :: Text -> Attribute Source #

The `dy` attribute.

edgeMode_ :: Text -> Attribute Source #

The `edgemode` attribute.

elevation_ :: Text -> Attribute Source #

The `elevation` attribute.

enable_background_ :: Text -> Attribute Source #

The `enableBackground` attribute.

end_ :: Text -> Attribute Source #

The `end` attribute.

exponent_ :: Text -> Attribute Source #

The `exponent` attribute.

externalResourcesRequired_ :: Text -> Attribute Source #

The `externalresourcesrequired` attribute.

fill_ :: Text -> Attribute Source #

The `fill` attribute.

fill_opacity_ :: Text -> Attribute Source #

The `fillOpacity` attribute.

fill_rule_ :: Text -> Attribute Source #

The `fillRule` attribute.

filterRes_ :: Text -> Attribute Source #

The `filterres` attribute.

filterUnits_ :: Text -> Attribute Source #

The `filterunits` attribute.

flood_color_ :: Text -> Attribute Source #

The `floodColor` attribute.

flood_opacity_ :: Text -> Attribute Source #

The `floodOpacity` attribute.

font_family_ :: Text -> Attribute Source #

The `fontFamily` attribute.

font_size_ :: Text -> Attribute Source #

The `fontSize` attribute.

font_size_adjust_ :: Text -> Attribute Source #

The `fontSizeAdjust` attribute.

font_stretch_ :: Text -> Attribute Source #

The `fontStretch` attribute.

font_style_ :: Text -> Attribute Source #

The `fontStyle` attribute.

font_variant_ :: Text -> Attribute Source #

The `fontVariant` attribute.

font_weight_ :: Text -> Attribute Source #

The `fontWeight` attribute.

format_ :: Text -> Attribute Source #

The `format` attribute.

from_ :: Text -> Attribute Source #

The `from` attribute.

fx_ :: Text -> Attribute Source #

The `fx` attribute.

fy_ :: Text -> Attribute Source #

The `fy` attribute.

g1_ :: Text -> Attribute Source #

The `g1` attribute.

g2_ :: Text -> Attribute Source #

The `g2` attribute.

glyph_name_ :: Text -> Attribute Source #

The `glyphName` attribute.

glyph_orientation_horizontal_ :: Text -> Attribute Source #

The `glyphOrientationHorizontal` attribute.

glyph_orientation_vertical_ :: Text -> Attribute Source #

The `glyphOrientationVertical` attribute.

gradientTransform_ :: Text -> Attribute Source #

The `-- | The` gradienttransform@ attribute.

gradientUnits_ :: Text -> Attribute Source #

The `gradientunits` attribute.

hanging_ :: Text -> Attribute Source #

The `hanging` attribute.

height_ :: Text -> Attribute Source #

The `height` attribute.

horiz_adv_x_ :: Text -> Attribute Source #

The `horizAdvX` attribute.

horiz_origin_x_ :: Text -> Attribute Source #

The `horizOriginX` attribute.

horiz_origin_y_ :: Text -> Attribute Source #

The `horizOriginY` attribute.

id_ :: Text -> Attribute Source #

The `id` attribute.

ideographic_ :: Text -> Attribute Source #

The `ideographic` attribute.

image_rendering_ :: Text -> Attribute Source #

The `imageRendering` attribute.

in_ :: Text -> Attribute Source #

The `in` attribute.

in2_ :: Text -> Attribute Source #

The `in2` attribute.

intercept_ :: Text -> Attribute Source #

The `intercept` attribute.

k_ :: Text -> Attribute Source #

The `k` attribute.

k1_ :: Text -> Attribute Source #

The `k1` attribute.

k2_ :: Text -> Attribute Source #

The `k2` attribute.

k3_ :: Text -> Attribute Source #

The `k3` attribute.

k4_ :: Text -> Attribute Source #

The `k4` attribute.

kernelMatrix_ :: Text -> Attribute Source #

The `kernelmatrix` attribute.

kernelUnitLength_ :: Text -> Attribute Source #

The `kernelunitlength` attribute.

kerning_ :: Text -> Attribute Source #

The `kerning` attribute.

keyPoints_ :: Text -> Attribute Source #

The `keypoints` attribute.

keySplines_ :: Text -> Attribute Source #

The `keysplines` attribute.

keyTimes_ :: Text -> Attribute Source #

The `keytimes` attribute.

lang_ :: Text -> Attribute Source #

The `lang` attribute.

lengthAdjust_ :: Text -> Attribute Source #

The `lengthadjust` attribute.

letter_spacing_ :: Text -> Attribute Source #

The `letterSpacing` attribute.

lighting_color_ :: Text -> Attribute Source #

The `lightingColor` attribute.

limitingConeAngle_ :: Text -> Attribute Source #

The `limitingconeangle` attribute.

local_ :: Text -> Attribute Source #

The `local` attribute.

marker_end_ :: Text -> Attribute Source #

The `markerEnd` attribute.

marker_mid_ :: Text -> Attribute Source #

The `markerMid` attribute.

marker_start_ :: Text -> Attribute Source #

The `markerStart` attribute.

markerHeight_ :: Text -> Attribute Source #

The `markerheight` attribute.

markerUnits_ :: Text -> Attribute Source #

The `markerunits` attribute.

markerWidth_ :: Text -> Attribute Source #

The `markerwidth` attribute.

maskContentUnits_ :: Text -> Attribute Source #

The `maskcontentunits` attribute.

maskUnits_ :: Text -> Attribute Source #

The `maskunits` attribute.

mathematical_ :: Text -> Attribute Source #

The `mathematical` attribute.

max_ :: Text -> Attribute Source #

The `max` attribute.

media_ :: Text -> Attribute Source #

The `media` attribute.

method_ :: Text -> Attribute Source #

The `method` attribute.

min_ :: Text -> Attribute Source #

The `min` attribute.

mode_ :: Text -> Attribute Source #

The `mode` attribute.

name_ :: Text -> Attribute Source #

The `name` attribute.

numOctaves_ :: Text -> Attribute Source #

The `numoctaves` attribute.

offset_ :: Text -> Attribute Source #

The `offset` attribute.

onabort_ :: Text -> Attribute Source #

The `onabort` attribute.

onactivate_ :: Text -> Attribute Source #

The `onactivate` attribute.

onbegin_ :: Text -> Attribute Source #

The `onbegin` attribute.

onclick_ :: Text -> Attribute Source #

The `onclick` attribute.

onend_ :: Text -> Attribute Source #

The `onend` attribute.

onerror_ :: Text -> Attribute Source #

The `onerror` attribute.

onfocusin_ :: Text -> Attribute Source #

The `onfocusin` attribute.

onfocusout_ :: Text -> Attribute Source #

The `onfocusout` attribute.

onload_ :: Text -> Attribute Source #

The `onload` attribute.

onmousedown_ :: Text -> Attribute Source #

The `onmousedown` attribute.

onmousemove_ :: Text -> Attribute Source #

The `onmousemove` attribute.

onmouseout_ :: Text -> Attribute Source #

The `onmouseout` attribute.

onmouseover_ :: Text -> Attribute Source #

The `onmouseover` attribute.

onmouseup_ :: Text -> Attribute Source #

The `onmouseup` attribute.

onrepeat_ :: Text -> Attribute Source #

The `onrepeat` attribute.

onresize_ :: Text -> Attribute Source #

The `onresize` attribute.

onscroll_ :: Text -> Attribute Source #

The `onscroll` attribute.

onunload_ :: Text -> Attribute Source #

The `onunload` attribute.

onzoom_ :: Text -> Attribute Source #

The `onzoom` attribute.

opacity_ :: Text -> Attribute Source #

The `opacity` attribute.

operator_ :: Text -> Attribute Source #

The `operator` attribute.

order_ :: Text -> Attribute Source #

The `order` attribute.

orient_ :: Text -> Attribute Source #

The `orient` attribute.

orientation_ :: Text -> Attribute Source #

The `orientation` attribute.

origin_ :: Text -> Attribute Source #

The `origin` attribute.

overflow_ :: Text -> Attribute Source #

The `overflow` attribute.

overline_position_ :: Text -> Attribute Source #

The `overlinePosition` attribute.

overline_thickness_ :: Text -> Attribute Source #

The `overlineThickness` attribute.

panose_1_ :: Text -> Attribute Source #

The `panose1` attribute.

paint_order_ :: Text -> Attribute Source #

The `paint-order` attribute.

pathLength_ :: Text -> Attribute Source #

The `pathlength` attribute.

patternContentUnits_ :: Text -> Attribute Source #

The `patterncontentunits` attribute.

patternTransform_ :: Text -> Attribute Source #

The `patterntransform` attribute.

patternUnits_ :: Text -> Attribute Source #

The `patternunits` attribute.

pointer_events_ :: Text -> Attribute Source #

The `pointerEvents` attribute.

points_ :: Text -> Attribute Source #

The `points` attribute.

pointsAtX_ :: Text -> Attribute Source #

The `pointsatx` attribute.

pointsAtY_ :: Text -> Attribute Source #

The `pointsaty` attribute.

pointsAtZ_ :: Text -> Attribute Source #

The `pointsatz` attribute.

preserveAlpha_ :: Text -> Attribute Source #

The `preservealpha` attribute.

preserveAspectRatio_ :: Text -> Attribute Source #

The `preserveaspectratio` attribute.

primitiveUnits_ :: Text -> Attribute Source #

The `primitiveunits` attribute.

r_ :: Text -> Attribute Source #

The `r` attribute.

radius_ :: Text -> Attribute Source #

The `radius` attribute.

refX_ :: Text -> Attribute Source #

The `refx` attribute.

refY_ :: Text -> Attribute Source #

The `refy` attribute.

rendering_intent_ :: Text -> Attribute Source #

The `renderingIntent` attribute.

repeatCount_ :: Text -> Attribute Source #

The `repeatcount` attribute.

repeatDur_ :: Text -> Attribute Source #

The `repeatdur` attribute.

requiredExtensions_ :: Text -> Attribute Source #

The `requiredextensions` attribute.

requiredFeatures_ :: Text -> Attribute Source #

The `requiredfeatures` attribute.

restart_ :: Text -> Attribute Source #

The `restart` attribute.

result_ :: Text -> Attribute Source #

The `result` attribute.

rotate_ :: Text -> Attribute Source #

The `rotate` attribute.

rx_ :: Text -> Attribute Source #

The `rx` attribute.

ry_ :: Text -> Attribute Source #

The `ry` attribute.

scale_ :: Text -> Attribute Source #

The `scale` attribute.

seed_ :: Text -> Attribute Source #

The `seed` attribute.

shape_rendering_ :: Text -> Attribute Source #

The `shapeRendering` attribute.

slope_ :: Text -> Attribute Source #

The `slope` attribute.

spacing_ :: Text -> Attribute Source #

The `spacing` attribute.

specularConstant_ :: Text -> Attribute Source #

The `specularconstant` attribute.

specularExponent_ :: Text -> Attribute Source #

The `specularexponent` attribute.

spreadMethod_ :: Text -> Attribute Source #

The `spreadmethod` attribute.

startOffset_ :: Text -> Attribute Source #

The `startoffset` attribute.

stdDeviation_ :: Text -> Attribute Source #

The `stddeviation` attribute.

stemh_ :: Text -> Attribute Source #

The `stemh` attribute.

stemv_ :: Text -> Attribute Source #

The `stemv` attribute.

stitchTiles_ :: Text -> Attribute Source #

The `stitchtiles` attribute.

stop_color_ :: Text -> Attribute Source #

The `stopColor` attribute.

stop_opacity_ :: Text -> Attribute Source #

The `stopOpacity` attribute.

strikethrough_position_ :: Text -> Attribute Source #

The `strikethroughPosition` attribute.

strikethrough_thickness_ :: Text -> Attribute Source #

The `strikethroughThickness` attribute.

string_ :: Text -> Attribute Source #

The `string` attribute.

stroke_ :: Text -> Attribute Source #

The `stroke` attribute.

stroke_dasharray_ :: Text -> Attribute Source #

The `strokeDasharray` attribute.

stroke_dashoffset_ :: Text -> Attribute Source #

The `strokeDashoffset` attribute.

stroke_linecap_ :: Text -> Attribute Source #

The `strokeLinecap` attribute.

stroke_linejoin_ :: Text -> Attribute Source #

The `strokeLinejoin` attribute.

stroke_miterlimit_ :: Text -> Attribute Source #

The `strokeMiterlimit` attribute.

stroke_opacity_ :: Text -> Attribute Source #

The `strokeOpacity` attribute.

stroke_width_ :: Text -> Attribute Source #

The `strokeWidth` attribute.

surfaceScale_ :: Text -> Attribute Source #

The `surfacescale` attribute.

systemLanguage_ :: Text -> Attribute Source #

The `systemlanguage` attribute.

tableValues_ :: Text -> Attribute Source #

The `tablevalues` attribute.

target_ :: Text -> Attribute Source #

The `target` attribute.

targetX_ :: Text -> Attribute Source #

The `targetx` attribute.

targetY_ :: Text -> Attribute Source #

The `targety` attribute.

text_anchor_ :: Text -> Attribute Source #

The `textAnchor` attribute.

text_decoration_ :: Text -> Attribute Source #

The `textDecoration` attribute.

text_rendering_ :: Text -> Attribute Source #

The `textRendering` attribute.

textLength_ :: Text -> Attribute Source #

The `textlength` attribute.

to_ :: Text -> Attribute Source #

The `to` attribute.

transform_ :: Text -> Attribute Source #

The `transform` attribute.

type_ :: Text -> Attribute Source #

The `type` attribute.

u1_ :: Text -> Attribute Source #

The `u1` attribute.

u2_ :: Text -> Attribute Source #

The `u2` attribute.

underline_position_ :: Text -> Attribute Source #

The `underlinePosition` attribute.

underline_thickness_ :: Text -> Attribute Source #

The `underlineThickness` attribute.

unicode_ :: Text -> Attribute Source #

The `unicode` attribute.

unicode_bidi_ :: Text -> Attribute Source #

The `unicodeBidi` attribute.

unicode_range_ :: Text -> Attribute Source #

The `unicodeRange` attribute.

units_per_em_ :: Text -> Attribute Source #

The `unitsPerEm` attribute.

v_alphabetic_ :: Text -> Attribute Source #

The `vAlphabetic` attribute.

v_hanging_ :: Text -> Attribute Source #

The `vHanging` attribute.

v_ideographic_ :: Text -> Attribute Source #

The `vIdeographic` attribute.

v_mathematical_ :: Text -> Attribute Source #

The `vMathematical` attribute.

values_ :: Text -> Attribute Source #

The `values` attribute.

version_ :: Text -> Attribute Source #

The `version` attribute.

vert_adv_y_ :: Text -> Attribute Source #

The `vertAdvY` attribute.

vert_origin_x_ :: Text -> Attribute Source #

The `vertOriginX` attribute.

vert_origin_y_ :: Text -> Attribute Source #

The `vertOriginY` attribute.

viewBox_ :: Text -> Attribute Source #

The `viewbox` attribute.

viewTarget_ :: Text -> Attribute Source #

The `viewtarget` attribute.

visibility_ :: Text -> Attribute Source #

The `visibility` attribute.

width_ :: Text -> Attribute Source #

The `width` attribute.

widths_ :: Text -> Attribute Source #

The `widths` attribute.

word_spacing_ :: Text -> Attribute Source #

The `wordSpacing` attribute.

writing_mode_ :: Text -> Attribute Source #

The `writingMode` attribute.

x_ :: Text -> Attribute Source #

The `x` attribute.

x_height_ :: Text -> Attribute Source #

The `xHeight` attribute.

x1_ :: Text -> Attribute Source #

The `x1` attribute.

x2_ :: Text -> Attribute Source #

The `x2` attribute.

xChannelSelector_ :: Text -> Attribute Source #

The `xchannelselector` attribute.

xlinkActuate_ :: Text -> Attribute Source #

The `xlinkActuate` attribute.

xlinkArcrole_ :: Text -> Attribute Source #

The `xlinkArcrole` attribute.

xlinkHref_ :: Text -> Attribute Source #

The `xlinkHref` attribute.

xlinkRole_ :: Text -> Attribute Source #

The `xlinkRole` attribute.

xlinkShow_ :: Text -> Attribute Source #

The `xlinkShow` attribute.

xlinkTitle_ :: Text -> Attribute Source #

The `xlinkTitle` attribute.

xlinkType_ :: Text -> Attribute Source #

The `xlinkType` attribute.

xmlBase_ :: Text -> Attribute Source #

The `xmlBase` attribute.

xmlLang_ :: Text -> Attribute Source #

The `xmlLang` attribute.

xmlSpace_ :: Text -> Attribute Source #

The `xmlSpace` attribute.

y_ :: Text -> Attribute Source #

The `y` attribute.

y1_ :: Text -> Attribute Source #

The `y1` attribute.

y2_ :: Text -> Attribute Source #

The `y2` attribute.

yChannelselector_ :: Text -> Attribute Source #

The `ychannelselector` attribute.

z_ :: Text -> Attribute Source #

The `z` attribute.

zoomAndPan_ :: Text -> Attribute Source #

The `zoomandpan` attribute.

# From Lucid.Base

renderText :: Html a -> Text Source #

Render the HTML to a lazy `Text`.

This is a convenience function defined in terms of `execHtmlT`, `runIdentity` and `toLazyByteString`, and `decodeUtf8`. Check the source if you're interested in the lower-level behaviour.

renderBS :: Html a -> ByteString Source #

Render the HTML to a lazy `ByteString`.

This is a convenience function defined in terms of `execHtmlT`, `runIdentity` and `toLazyByteString`. Check the source if you're interested in the lower-level behaviour.

renderTextT :: Monad m => HtmlT m a -> m Text Source #

Render the HTML to a lazy `Text`, but in a monad.

This is a convenience function defined in terms of `execHtmlT` and `toLazyByteString`, and `decodeUtf8`. Check the source if you're interested in the lower-level behaviour.

renderBST :: Monad m => HtmlT m a -> m ByteString Source #

Render the HTML to a lazy `ByteString`, but in a monad.

This is a convenience function defined in terms of `execHtmlT` and `toLazyByteString`. Check the source if you're interested in the lower-level behaviour.

renderToFile :: FilePath -> Html a -> IO () Source #

Render the HTML to a lazy `ByteString`.

This is a convenience function defined in terms of `execHtmlT`, `runIdentity` and `toLazyByteString`. Check the source if you're interested in the lower-level behaviour.

## Running

execHtmlT Source #

Arguments

:: Monad m |
=> HtmlT m a | The HTML to generate.
-> m Builder | The `a` is discarded.

Build the HTML. Analogous to `execState`.

You might want to use this is if you want to do something with the raw `Builder`. Otherwise for simple cases you can just use `renderText` or `renderBS`.

evalHtmlT Source #

Arguments

:: Monad m |
=> HtmlT m a | HTML monad to evaluate.
-> m a | Ignore the HTML output and just return the value.

Evaluate the HTML to its return value. Analogous to `evalState`.

Use this if you want to ignore the HTML output of an action completely and just get the result.

For using with the `Html` type, you'll need `runIdentity` e.g.

    >>> runIdentity (evalHtmlT (p_ "Hello!"))
    ()

runHtmlT :: HtmlT m a -> m (HashMap Text Text -> Builder, a) Source #

This is the low-level way to run the HTML transformer, finally returning an element builder and a value. You can pass `mempty` for this argument for a top-level call. See `evalHtmlT` and `execHtmlT` for easier to use functions.

## Types

data Attribute Source #

A simple attribute. Don't use the constructor, use `makeAttribute`.

Constructors

Attribute !Text !Text |

Instances

Eq Attribute |
Instance details Defined in Lucid.Base Methods (==) :: Attribute -> Attribute -> Bool Source # (/=) :: Attribute -> Attribute -> Bool Source #
Show Attribute |
Instance details Defined in Lucid.Base Methods showsPrec :: Int -> Attribute -> ShowS Source # show :: Attribute -> String Source # showList :: [Attribute] -> ShowS Source #
Hashable Attribute |
Instance details Defined in Lucid.Base Methods hashWithSalt :: Int -> Attribute -> Int hash :: Attribute -> Int
Term Text Attribute | Some terms (like `style_`, `title_`) can be used for attributes as well as elements.
Instance details Defined in Lucid.Base Methods term :: Text -> Text -> Attribute Source # termWith :: Text -> [Attribute] -> Text -> Attribute Source #
TermRaw Text Attribute | Some termRaws (like `style_`, `title_`) can be used for attributes as well as elements.
Instance details Defined in Lucid.Base Methods termRaw :: Text -> Text -> Attribute Source # termRawWith :: Text -> [Attribute] -> Text -> Attribute Source #
(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input.
Instance details Defined in Lucid.Base Methods term :: Text -> [Attribute] -> f -> HtmlT m a Source # termWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a Source #
(Monad m, ToHtml f, a ~ ()) => TermRaw [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input.
Instance details Defined in Lucid.Base Methods termRaw :: Text -> [Attribute] -> f -> HtmlT m a Source # termRawWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a Source #

## Classes

class Term arg result | result -> arg where Source #

Used to construct HTML terms.

Simplest use: p_ = term "p" yields `p_`.

Very overloaded for three cases:

- The first case is the basic `arg` of `[(Text,Text)]` which will return a function that wants children.
- The second is an `arg` which is `HtmlT m ()`, in which case the term accepts no attributes and just the children are used for the element.
- Finally, this is also used for overloaded attributes, like `style_` or `title_`. If a return type of `(Text,Text)` is inferred then an attribute will be made.

The instances look intimidating but actually the constraints make it very general so that type inference works well even in the presence of things like `OverloadedLists` and such.

Minimal complete definition

termWith

Methods

term Source #

Arguments

:: Text | Name of the element or attribute.
-> arg | Either an attribute list or children.
-> result | Result: either an element or an attribute.

Used for constructing elements e.g. `term "p"` yields `p_`.

termWith Source #

Arguments

:: Text | Name.
-> [Attribute] | Attribute transformer.
-> arg | Some argument.
-> result | Result: either an element or an attribute.

Use this if you want to make an element which inserts some pre-prepared attributes into the element.

Instances

Term Text Attribute | Some terms (like `style_`, `title_`) can be used for attributes as well as elements.
Instance details Defined in Lucid.Base Methods term :: Text -> Text -> Attribute Source # termWith :: Text -> [Attribute] -> Text -> Attribute Source #
(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input.
Instance details Defined in Lucid.Base Methods term :: Text -> [Attribute] -> f -> HtmlT m a Source # termWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a Source #
Applicative m => Term (HtmlT m a) (HtmlT m a) | Given children immediately, just use that and expect no attributes.
Instance details Defined in Lucid.Base Methods term :: Text -> HtmlT m a -> HtmlT m a Source # termWith :: Text -> [Attribute] -> HtmlT m a -> HtmlT m a Source #

class ToHtml a where Source #

Can be converted to HTML.

Methods

toHtml :: Monad m => a -> HtmlT m () Source #

Convert to HTML, doing HTML escaping.

toHtmlRaw :: Monad m => a -> HtmlT m () Source #

Convert to HTML without any escaping.

Instances

ToHtml String |
Instance details Defined in Lucid.Base Methods toHtml :: Monad m => String -> HtmlT m () Source # toHtmlRaw :: Monad m => String -> HtmlT m () Source #
ToHtml ByteString | This instance requires the ByteString to contain UTF-8 encoded text, for the `toHtml` method. The `toHtmlRaw` method doesn't care, but the overall HTML rendering methods in this module assume UTF-8. Since: lucid-2.9.5
Instance details Defined in Lucid.Base Methods toHtml :: Monad m => ByteString -> HtmlT m () Source # toHtmlRaw :: Monad m => ByteString -> HtmlT m () Source #
ToHtml ByteString | This instance requires the ByteString to contain UTF-8 encoded text, for the `toHtml` method. The `toHtmlRaw` method doesn't care, but the overall HTML rendering methods in this module assume UTF-8. Since: lucid-2.9.5
Instance details Defined in Lucid.Base Methods toHtml :: Monad m => ByteString -> HtmlT m () Source # toHtmlRaw :: Monad m => ByteString -> HtmlT m () Source #
ToHtml Text |
Instance details Defined in Lucid.Base Methods toHtml :: Monad m => Text -> HtmlT m () Source # toHtmlRaw :: Monad m => Text -> HtmlT m () Source #
ToHtml Text |
Instance details Defined in Lucid.Base Methods toHtml :: Monad m => Text -> HtmlT m () Source # toHtmlRaw :: Monad m => Text -> HtmlT m () Source #
(a ~ (), m ~ Identity) => ToHtml (HtmlT m a) | Since: lucid-2.9.8
Instance details Defined in Lucid.Base Methods toHtml :: Monad m0 => HtmlT m a -> HtmlT m0 () Source # toHtmlRaw :: Monad m0 => HtmlT m a -> HtmlT m0 () Source #

class With a where Source #

With an element use these attributes. An overloaded way of adding attributes either to an element accepting attributes-and-children or one that just accepts attributes. See the two instances.

Methods

with Source #

Arguments

:: a | Some element, either `Html a` or `Html a -> Html a`.
-> [Attribute] |
-> a |

With the given element(s), use the given attributes.

Instances

Functor m => With (HtmlT m a -> HtmlT m a) | For the contentful elements: `div_`
Instance details Defined in Lucid.Base Methods with :: (HtmlT m a -> HtmlT m a) -> [Attribute] -> HtmlT m a -> HtmlT m a Source #
Functor m => With (HtmlT m a) | For the contentless elements: `br_`
Instance details Defined in Lucid.Base Methods with :: HtmlT m a -> [Attribute] -> HtmlT m a Source #