Martin Middel
FontoXML
Most are 'like HTML', but different names
<p />
<para />
Or different attributes:
<emphasis bold="true" />
<emphasis type="bold" />
Or other structures
Martin is going to XML
Prague
Correct!
London
Incorrect
Amsterdam
Is that even a thing anymore?
to present why Fonto works like it works.
Use schema knowledge to compute actions
Insert an image, somewhere 'here'
- A piece of| Text
- A piece of<img src="..."/>| Text
- A piece
|
- of Text
- A piece
<img src="..." />|
- of Text
- A piece
|
- of Text
- A piece
<img src="..." />|
- of Text
'Try' out these changes, and revert them if they were bad
const blueprint = new Blueprint();
const newElement = document.createElement('newElement');
blueprint.appendChild(newParent, newElement);
const newParent = blueprint.getParentNode(newElement);
// newParent is now set the documentElement node.
const isValid = validator.isValidNode(blueprint, newParent);
// The validator is passed the blueprint so it can see
// whether the new structure is valid
if (isValid) {
// We know it's valid, so we can safely apply these changes to the DOM
blueprint.realize();
}
What if the node we split has required children?
<section>
<title></title>
<p>before split</p>
</section>
<section>
<title></title> <--
<p>after split</p>
</section>
{
"insert-image": {
"steps": [
{ "type": "modal/open-image-browser" },
{
"type": "command/insert-node",
"data": {
"childNodeStructure": [
"img", { "src": "{{href}}" ]
]
}
}
]
}
}
matchNodeName("emphasis").withAttribute("type", "bold")
[
"figure",
[
"title",
[{
"bindTo": "titleGap",
"multiple": true,
"required": false
}]
],
["img", { "href": { "bindTo": "hrefGap"}}]
]
matchNodeName("emphasis")
.withAttribute("type", "bold")
.requireNodePredicate(
(node, blueprint) =>
matchNodeName("someElement")
.matches(
blueprint.getParentNode(node),
blueprint)
Selectors -> XPath
self::emphasis[@type="bold" and parent::someElement]
<figure>
<title>{&data("title")}</title>
<img @href="{href}" />
</figure>