mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 22:55:44 +01:00
Read adfToHtml's HTML in htmlToAdf as a browser serializes it too
This commit is contained in:
+15
-5
@@ -119,14 +119,24 @@ later release writes it as its own element.
|
||||
|
||||
## Reading
|
||||
|
||||
`htmlToAdf` reads exactly the HTML above, so `htmlToAdf(adfToHtml(doc))` deep-equals `doc`. It
|
||||
reads a carry element's node from its `data-adf`, and what the element shows, through its closing
|
||||
tag, must be what `adfToHtml` shows for that node: an edit there would be lost, so it is
|
||||
`htmlToAdf` reads exactly the HTML above, so `htmlToAdf(adfToHtml(doc))` deep-equals `doc`. It also
|
||||
reads the HTML above as a browser serializes it (WHATWG HTML §13.3) and as a form post sends it,
|
||||
anywhere the HTML above has the character, a carry element's `data-adf` and what it shows included:
|
||||
|
||||
| The HTML above writes | Also read |
|
||||
| --- | --- |
|
||||
| `"` in text | a raw `"` |
|
||||
| a no-break space | ` ` |
|
||||
| `<` and `>` in an attribute value | a raw `<` and `>`, as older browsers write them |
|
||||
| a line feed | `\r\n`; a refusal's position counts the HTML as handed in |
|
||||
|
||||
It reads a carry element's node from its `data-adf`, and what the element shows, through its
|
||||
closing tag, must be what `adfToHtml` shows for that node: an edit there would be lost, so it is
|
||||
`unmappable-html`.
|
||||
|
||||
- Any other HTML is `unmappable-html`: another element, attribute or escape, attributes in another
|
||||
order, a block on the line of another, a carriage return anywhere, or non-empty HTML not ending
|
||||
in a line feed.
|
||||
order, a block on the line of another, a carriage return not followed by a line feed, or
|
||||
non-empty HTML not ending in a line feed.
|
||||
- A `data-*` attribute that its element does not take, such as `data-level` on `<h1>`, or that holds
|
||||
a value outside its attribute's kind or not written as compact JSON, is `unsupported-node-shape`.
|
||||
- A carry element's `data-adf` holding invalid JSON is `unmappable-html`. JSON that is no ADF node,
|
||||
|
||||
Reference in New Issue
Block a user