| Copyright | (c) 2015 Jeffrey Rosenbluth |
|---|---|
| License | BSD-style (see LICENSE) |
| Maintainer | jeffrey.rosenbluth@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Lucid.Svg
Description
DSL for creating SVG.
Synopsis
- type Svg = SvgT Identity
- prettyText :: Svg a -> Text
- module Lucid.Svg.Path
- module Lucid.Svg.Elements
- class_ :: Text -> Attribute
- height_ :: Text -> Attribute
- id_ :: Text -> Attribute
- lang_ :: Text -> Attribute
- max_ :: Text -> Attribute
- media_ :: Text -> Attribute
- method_ :: Text -> Attribute
- min_ :: Text -> Attribute
- name_ :: Text -> Attribute
- onclick_ :: Text -> Attribute
- onerror_ :: Text -> Attribute
- onload_ :: Text -> Attribute
- onmousedown_ :: Text -> Attribute
- onmousemove_ :: Text -> Attribute
- onmouseout_ :: Text -> Attribute
- onmouseover_ :: Text -> Attribute
- onmouseup_ :: Text -> Attribute
- onresize_ :: Text -> Attribute
- onscroll_ :: Text -> Attribute
- onunload_ :: Text -> Attribute
- target_ :: Text -> Attribute
- type_ :: Text -> Attribute
- width_ :: Text -> Attribute
- 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
- 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
- horiz_adv_x_ :: Text -> Attribute
- horiz_origin_x_ :: Text -> Attribute
- horiz_origin_y_ :: 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
- 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
- mode_ :: Text -> Attribute
- numOctaves_ :: Text -> Attribute
- offset_ :: Text -> Attribute
- onabort_ :: Text -> Attribute
- onactivate_ :: Text -> Attribute
- onbegin_ :: Text -> Attribute
- onend_ :: Text -> Attribute
- onfocusin_ :: Text -> Attribute
- onfocusout_ :: Text -> Attribute
- onrepeat_ :: 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
- 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
- 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
- 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 (Seq Attribute -> Builder, a)
- data Attribute = Attribute !Text !Text
- class Term arg result | result -> arg where
- class ToHtml a where
- class With a where
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

Rendering
prettyText :: Svg a -> Text Source #
Re-exports
module Lucid.Svg.Path
module Lucid.Svg.Elements
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.
accent_height_ :: Text -> Attribute Source #
The accentHeight attribute.
accumulate_ :: Text -> Attribute Source #
The accumulate 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.
attributeName_ :: Text -> Attribute Source #
The attributename attribute.
attributeType_ :: Text -> Attribute Source #
The attributetype attribute.
baseFrequency_ :: Text -> Attribute Source #
The basefrequency attribute.
baseprofile_ :: Text -> Attribute Source #
The baseprofile attribute.
baseline_shift_ :: Text -> Attribute Source #
The baselineShift attribute.
cap_height_ :: Text -> Attribute Source #
The capHeight 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_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.
diffuseConstant_ :: Text -> Attribute Source #
The diffuseconstant attribute.
direction_ :: Text -> Attribute Source #
The direction attribute.
dominant_baseline_ :: Text -> Attribute Source #
The dominantBaseline attribute.
elevation_ :: Text -> Attribute Source #
The elevation attribute.
enable_background_ :: Text -> Attribute Source #
The enableBackground attribute.
externalResourcesRequired_ :: Text -> Attribute Source #
The externalresourcesrequired 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.
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.
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.
ideographic_ :: Text -> Attribute Source #
The ideographic attribute.
image_rendering_ :: Text -> Attribute Source #
The imageRendering attribute.
intercept_ :: Text -> Attribute Source #
The intercept attribute.
kernelMatrix_ :: Text -> Attribute Source #
The kernelmatrix attribute.
kernelUnitLength_ :: Text -> Attribute Source #
The kernelunitlength attribute.
keyPoints_ :: Text -> Attribute Source #
The keypoints attribute.
keySplines_ :: Text -> Attribute Source #
The keysplines 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.
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.
numOctaves_ :: Text -> Attribute Source #
The numoctaves attribute.
onactivate_ :: Text -> Attribute Source #
The onactivate attribute.
onfocusin_ :: Text -> Attribute Source #
The onfocusin attribute.
onfocusout_ :: Text -> Attribute Source #
The onfocusout attribute.
orientation_ :: Text -> Attribute Source #
The orientation attribute.
overline_position_ :: Text -> Attribute Source #
The overlinePosition attribute.
overline_thickness_ :: Text -> Attribute Source #
The overlineThickness 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.
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.
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.
shape_rendering_ :: Text -> Attribute Source #
The shapeRendering 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.
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.
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.
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.
transform_ :: Text -> Attribute Source #
The transform attribute.
underline_position_ :: Text -> Attribute Source #
The underlinePosition attribute.
underline_thickness_ :: Text -> Attribute Source #
The underlineThickness 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.
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.
viewTarget_ :: Text -> Attribute Source #
The viewtarget attribute.
visibility_ :: Text -> Attribute Source #
The visibility attribute.
word_spacing_ :: Text -> Attribute Source #
The wordSpacing attribute.
writing_mode_ :: Text -> Attribute Source #
The writingMode 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.
yChannelselector_ :: Text -> Attribute Source #
The ychannelselector attribute.
zoomAndPan_ :: Text -> Attribute Source #
The zoomandpan attribute.
From Lucid.Base
renderText :: Html a -> Text #
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 #
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 #
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 #
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 () #
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
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.
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!"))()
Types
A simple attribute. Don't use the constructor, use
makeAttribute. Attributes are case sensitive, so if you want
attributes to be merged properly, use a single case representation.
Instances
| Show Attribute | |
| Eq Attribute | |
| Hashable Attribute | |
Defined in Lucid.Base | |
| Term Text Attribute | Some terms (like |
| TermRaw Text Attribute | Some termRaws (like |
| (Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input. |
| (Monad m, ToHtml f, a ~ ()) => TermRaw [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input. |
Classes
class Term arg result | result -> arg where #
Used to construct HTML terms.
Simplest use: p_ = term "p" yields p_.
Very overloaded for three cases:
- The first case is the basic
argof[(Text,Text)]which will return a function that wants children. - The second is an
argwhich isHtmlT 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_ortitle_. 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
Methods
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_.
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 |
| (Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a) | Given attributes, expect more child input. |
| Applicative m => Term (HtmlT m a) (HtmlT m a) | Given children immediately, just use that and expect no attributes. |
Can be converted to HTML.
Methods
toHtml :: forall (m :: Type -> Type). Monad m => a -> HtmlT m () #
Convert to HTML, doing HTML escaping.
toHtmlRaw :: forall (m :: Type -> Type). Monad m => a -> HtmlT m () #
Convert to HTML without any escaping.
Instances
| ToHtml ByteString | This instance requires the ByteString to contain UTF-8 encoded
text, for the Since: lucid-2.9.5 |
Defined in Lucid.Base | |
| ToHtml ByteString | This instance requires the ByteString to contain UTF-8 encoded
text, for the Since: lucid-2.9.5 |
Defined in Lucid.Base | |
| ToHtml Text | |
| ToHtml Text | |
| ToHtml String | |
| (a ~ (), m ~ Identity) => ToHtml (HtmlT m a) | Since: lucid-2.9.8 |
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
Arguments
| :: a | Some element, either |
| -> [Attribute] | |
| -> a |
With the given element(s), use the given attributes.