Module

Svg.Parser

Package
purescript-svg-parser
Repository
rnons/purescript-svg-parser

A module to Parse an SVG document String as SvgNode. If you are using purescript-halogen, Svg.Parser.Halogen is for you. If you are using other view libraries, you need to write an adapter to convert SvgNode to the HTML type you are using.

#SvgNode Source

data SvgNode

A SVG node can be one of the three: SvgElement, SvgText or SvgComment.

Constructors

Instances

#Element Source

type Element = { attributes :: List SvgAttribute, children :: List SvgNode, name :: String }

An Element consists of a tag name, a list of attributes, a list of children nodes.

<svg xmlns="http://www.w3.org/2000/svg"></svg>

will be parsed as

{ name: "svg"
, attributes: [ SvgAttribute "xmlns" "http://www.w3.org/2000/svg" ]
, children: []
}

#SvgAttribute Source

data SvgAttribute

An attribute consists of attribute name and value

Constructors

Instances

#parseToSvgNode Source

parseToSvgNode :: String -> Either ParseError SvgNode

Parse an SVG source String as SvgNode. You can then use SvgNode to construct the HTML type you are using.

NOTE: Everything before <svg and after </svg> are ignored.

Modules
Svg.Parser