A mark definition describes how to encode and decode a mark.
Defines a mark. The arguments are as follows:
name - The unique name for this mark. This should be something like 'bold' or 'link'.
toHtmlNode - The function that converts the mark to html. This is used in rendering,
DOM validation, and path translation.
fromHtmlNode - The function that converts html to marks. This is used in things
like paste to determine the editor nodes from html.
code : MarkDefinition
code =
markDefinition {name="code", toHtmlNode=codeToHtmlNode, fromHtmlNode=htmlNodeToCode}Type alias for a mark encoding function
codeToHtmlNode : MarkToHtml
codeToHtmlNode _ children =
ElementNode "code" [] childrenType alias for a mark decoding function
htmlNodeToCode : HtmlToMark
htmlNodeToCode definition node =
case node of
ElementNode name _ children ->
if name == 'code' then
Just ( mark def [], children )
else
Nothing
_ ->
NothingName of the mark this mark definition defines.
name code
--> "code"Function which encodes a mark to Html
Function which decodes a mark from Html
Creates a mark definition which assumes the name of the mark is the same as the name of the html node.
defaultMarkDefinition "b"
--> definition which encodes to <b>...</b> and decodes from "<b>...</b>"Creates an MarkToHtml function that will encode a mark to html with the same name as the mark.
defaultMarkToHtml "b"
--> returns a function which encodes to "<b>...</b>"Creates an HtmlToMark function that will decode a mark from the tag name specified.
defaultHtmlToMark "b"
--> returns a function which decodes from "<b>...</b>"
A mark definition defines how a mark is encoded an decoded.