Copyright | (c) 2015 Jeffrey Rosenbluth |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | jeffrey.rosenbluth@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
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
- 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 #
Re-exports
module Lucid.Svg.Path
module Lucid.Svg.Elements
accent_height_ :: Text -> Attribute #
The accentHeight
attribute.
accumulate_ :: Text -> Attribute #
The accumulate
attribute.
alignment_baseline_ :: Text -> Attribute #
The alignmentBaseline
attribute.
alphabetic_ :: Text -> Attribute #
The alphabetic
attribute.
amplitude_ :: Text -> Attribute #
The amplitude
attribute.
arabic_form_ :: Text -> Attribute #
The arabicForm
attribute.
attributeName_ :: Text -> Attribute #
The attributename
attribute.
attributeType_ :: Text -> Attribute #
The attributetype
attribute.
baseFrequency_ :: Text -> Attribute #
The basefrequency
attribute.
baseprofile_ :: Text -> Attribute #
The baseprofile
attribute.
baseline_shift_ :: Text -> Attribute #
The baselineShift
attribute.
cap_height_ :: Text -> Attribute #
The capHeight
attribute.
clip_path_ :: Text -> Attribute #
The clip-path
attribute.
clip_rule_ :: Text -> Attribute #
The clipRule
attribute.
clipPathUnits_ :: Text -> Attribute #
The clippathunits
attribute.
color_interpolation_ :: Text -> Attribute #
The colorInterpolation
attribute.
color_interpolation_filters_ :: Text -> Attribute #
The colorInterpolationFilters
attribute.
color_profile_ :: Text -> Attribute #
The colorProfile
attribute.
color_rendering_ :: Text -> Attribute #
The colorRendering
attribute.
contentScriptType_ :: Text -> Attribute #
The contentscripttype
attribute.
contentStyleType_ :: Text -> Attribute #
The contentstyletype
attribute.
diffuseConstant_ :: Text -> Attribute #
The diffuseconstant
attribute.
direction_ :: Text -> Attribute #
The direction
attribute.
dominant_baseline_ :: Text -> Attribute #
The dominantBaseline
attribute.
elevation_ :: Text -> Attribute #
The elevation
attribute.
enable_background_ :: Text -> Attribute #
The enableBackground
attribute.
externalResourcesRequired_ :: Text -> Attribute #
The externalresourcesrequired
attribute.
fill_opacity_ :: Text -> Attribute #
The fillOpacity
attribute.
fill_rule_ :: Text -> Attribute #
The fillRule
attribute.
filterRes_ :: Text -> Attribute #
The filterres
attribute.
filterUnits_ :: Text -> Attribute #
The filterunits
attribute.
flood_color_ :: Text -> Attribute #
The floodColor
attribute.
flood_opacity_ :: Text -> Attribute #
The floodOpacity
attribute.
font_family_ :: Text -> Attribute #
The fontFamily
attribute.
font_size_ :: Text -> Attribute #
The fontSize
attribute.
font_size_adjust_ :: Text -> Attribute #
The fontSizeAdjust
attribute.
font_stretch_ :: Text -> Attribute #
The fontStretch
attribute.
font_style_ :: Text -> Attribute #
The fontStyle
attribute.
font_variant_ :: Text -> Attribute #
The fontVariant
attribute.
font_weight_ :: Text -> Attribute #
The fontWeight
attribute.
glyph_name_ :: Text -> Attribute #
The glyphName
attribute.
glyph_orientation_horizontal_ :: Text -> Attribute #
The glyphOrientationHorizontal
attribute.
glyph_orientation_vertical_ :: Text -> Attribute #
The glyphOrientationVertical
attribute.
gradientTransform_ :: Text -> Attribute #
The -- | The
gradienttransform@ attribute.
gradientUnits_ :: Text -> Attribute #
The gradientunits
attribute.
horiz_adv_x_ :: Text -> Attribute #
The horizAdvX
attribute.
horiz_origin_x_ :: Text -> Attribute #
The horizOriginX
attribute.
horiz_origin_y_ :: Text -> Attribute #
The horizOriginY
attribute.
ideographic_ :: Text -> Attribute #
The ideographic
attribute.
image_rendering_ :: Text -> Attribute #
The imageRendering
attribute.
intercept_ :: Text -> Attribute #
The intercept
attribute.
kernelMatrix_ :: Text -> Attribute #
The kernelmatrix
attribute.
kernelUnitLength_ :: Text -> Attribute #
The kernelunitlength
attribute.
keyPoints_ :: Text -> Attribute #
The keypoints
attribute.
keySplines_ :: Text -> Attribute #
The keysplines
attribute.
lengthAdjust_ :: Text -> Attribute #
The lengthadjust
attribute.
letter_spacing_ :: Text -> Attribute #
The letterSpacing
attribute.
lighting_color_ :: Text -> Attribute #
The lightingColor
attribute.
limitingConeAngle_ :: Text -> Attribute #
The limitingconeangle
attribute.
marker_end_ :: Text -> Attribute #
The markerEnd
attribute.
marker_mid_ :: Text -> Attribute #
The markerMid
attribute.
marker_start_ :: Text -> Attribute #
The markerStart
attribute.
markerHeight_ :: Text -> Attribute #
The markerheight
attribute.
markerUnits_ :: Text -> Attribute #
The markerunits
attribute.
markerWidth_ :: Text -> Attribute #
The markerwidth
attribute.
maskContentUnits_ :: Text -> Attribute #
The maskcontentunits
attribute.
maskUnits_ :: Text -> Attribute #
The maskunits
attribute.
mathematical_ :: Text -> Attribute #
The mathematical
attribute.
numOctaves_ :: Text -> Attribute #
The numoctaves
attribute.
onactivate_ :: Text -> Attribute #
The onactivate
attribute.
onfocusin_ :: Text -> Attribute #
The onfocusin
attribute.
onfocusout_ :: Text -> Attribute #
The onfocusout
attribute.
onmousedown_ :: Text -> Attribute #
The onmousedown
attribute.
onmousemove_ :: Text -> Attribute #
The onmousemove
attribute.
onmouseout_ :: Text -> Attribute #
The onmouseout
attribute.
onmouseover_ :: Text -> Attribute #
The onmouseover
attribute.
onmouseup_ :: Text -> Attribute #
The onmouseup
attribute.
orientation_ :: Text -> Attribute #
The orientation
attribute.
overline_position_ :: Text -> Attribute #
The overlinePosition
attribute.
overline_thickness_ :: Text -> Attribute #
The overlineThickness
attribute.
paint_order_ :: Text -> Attribute #
The paint-order
attribute.
pathLength_ :: Text -> Attribute #
The pathlength
attribute.
patternContentUnits_ :: Text -> Attribute #
The patterncontentunits
attribute.
patternTransform_ :: Text -> Attribute #
The patterntransform
attribute.
patternUnits_ :: Text -> Attribute #
The patternunits
attribute.
pointer_events_ :: Text -> Attribute #
The pointerEvents
attribute.
pointsAtX_ :: Text -> Attribute #
The pointsatx
attribute.
pointsAtY_ :: Text -> Attribute #
The pointsaty
attribute.
pointsAtZ_ :: Text -> Attribute #
The pointsatz
attribute.
preserveAlpha_ :: Text -> Attribute #
The preservealpha
attribute.
preserveAspectRatio_ :: Text -> Attribute #
The preserveaspectratio
attribute.
primitiveUnits_ :: Text -> Attribute #
The primitiveunits
attribute.
rendering_intent_ :: Text -> Attribute #
The renderingIntent
attribute.
repeatCount_ :: Text -> Attribute #
The repeatcount
attribute.
repeatDur_ :: Text -> Attribute #
The repeatdur
attribute.
requiredExtensions_ :: Text -> Attribute #
The requiredextensions
attribute.
requiredFeatures_ :: Text -> Attribute #
The requiredfeatures
attribute.
shape_rendering_ :: Text -> Attribute #
The shapeRendering
attribute.
specularConstant_ :: Text -> Attribute #
The specularconstant
attribute.
specularExponent_ :: Text -> Attribute #
The specularexponent
attribute.
spreadMethod_ :: Text -> Attribute #
The spreadmethod
attribute.
startOffset_ :: Text -> Attribute #
The startoffset
attribute.
stdDeviation_ :: Text -> Attribute #
The stddeviation
attribute.
stitchTiles_ :: Text -> Attribute #
The stitchtiles
attribute.
stop_color_ :: Text -> Attribute #
The stopColor
attribute.
stop_opacity_ :: Text -> Attribute #
The stopOpacity
attribute.
strikethrough_position_ :: Text -> Attribute #
The strikethroughPosition
attribute.
strikethrough_thickness_ :: Text -> Attribute #
The strikethroughThickness
attribute.
stroke_dasharray_ :: Text -> Attribute #
The strokeDasharray
attribute.
stroke_dashoffset_ :: Text -> Attribute #
The strokeDashoffset
attribute.
stroke_linecap_ :: Text -> Attribute #
The strokeLinecap
attribute.
stroke_linejoin_ :: Text -> Attribute #
The strokeLinejoin
attribute.
stroke_miterlimit_ :: Text -> Attribute #
The strokeMiterlimit
attribute.
stroke_opacity_ :: Text -> Attribute #
The strokeOpacity
attribute.
stroke_width_ :: Text -> Attribute #
The strokeWidth
attribute.
surfaceScale_ :: Text -> Attribute #
The surfacescale
attribute.
systemLanguage_ :: Text -> Attribute #
The systemlanguage
attribute.
tableValues_ :: Text -> Attribute #
The tablevalues
attribute.
text_anchor_ :: Text -> Attribute #
The textAnchor
attribute.
text_decoration_ :: Text -> Attribute #
The textDecoration
attribute.
text_rendering_ :: Text -> Attribute #
The textRendering
attribute.
textLength_ :: Text -> Attribute #
The textlength
attribute.
transform_ :: Text -> Attribute #
The transform
attribute.
underline_position_ :: Text -> Attribute #
The underlinePosition
attribute.
underline_thickness_ :: Text -> Attribute #
The underlineThickness
attribute.
unicode_bidi_ :: Text -> Attribute #
The unicodeBidi
attribute.
unicode_range_ :: Text -> Attribute #
The unicodeRange
attribute.
units_per_em_ :: Text -> Attribute #
The unitsPerEm
attribute.
v_alphabetic_ :: Text -> Attribute #
The vAlphabetic
attribute.
v_hanging_ :: Text -> Attribute #
The vHanging
attribute.
v_ideographic_ :: Text -> Attribute #
The vIdeographic
attribute.
v_mathematical_ :: Text -> Attribute #
The vMathematical
attribute.
vert_adv_y_ :: Text -> Attribute #
The vertAdvY
attribute.
vert_origin_x_ :: Text -> Attribute #
The vertOriginX
attribute.
vert_origin_y_ :: Text -> Attribute #
The vertOriginY
attribute.
viewTarget_ :: Text -> Attribute #
The viewtarget
attribute.
visibility_ :: Text -> Attribute #
The visibility
attribute.
word_spacing_ :: Text -> Attribute #
The wordSpacing
attribute.
writing_mode_ :: Text -> Attribute #
The writingMode
attribute.
xChannelSelector_ :: Text -> Attribute #
The xchannelselector
attribute.
xlinkActuate_ :: Text -> Attribute #
The xlinkActuate
attribute.
xlinkArcrole_ :: Text -> Attribute #
The xlinkArcrole
attribute.
xlinkHref_ :: Text -> Attribute #
The xlinkHref
attribute.
xlinkRole_ :: Text -> Attribute #
The xlinkRole
attribute.
xlinkShow_ :: Text -> Attribute #
The xlinkShow
attribute.
xlinkTitle_ :: Text -> Attribute #
The xlinkTitle
attribute.
xlinkType_ :: Text -> Attribute #
The xlinkType
attribute.
yChannelselector_ :: Text -> Attribute #
The ychannelselector
attribute.
zoomAndPan_ :: Text -> Attribute #
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
.
:: 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
.
Instances
Eq Attribute | |
Show 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
arg
of[(Text,Text)]
which will return a function that wants children. - The second is an
arg
which 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.
:: 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_
.
:: 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.
toHtml :: Monad m => a -> HtmlT m () #
Convert to HTML, doing HTML escaping.
toHtmlRaw :: Monad m => a -> HtmlT m () #
Convert to HTML without any escaping.
Instances
ToHtml String | |
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 :: Monad m => ByteString -> HtmlT m () # toHtmlRaw :: Monad m => ByteString -> HtmlT m () # | |
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 :: Monad m => ByteString -> HtmlT m () # toHtmlRaw :: Monad m => ByteString -> HtmlT m () # | |
ToHtml Text | |
ToHtml Text | |
(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.
:: a | Some element, either |
-> [Attribute] | |
-> a |
With the given element(s), use the given attributes.