mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-21 07:32:58 +01:00
Write strike as HTML in adfToHtml and read it back in htmlToAdf
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- `adfToHtml` writes a `strike` mark as `<del>`, where it wrote the carry element, and `htmlToAdf` reads
|
||||||
|
`<del>` as `strike`. A carry element written before still reads.
|
||||||
- `adfToPlainText` writes a document as text with no markup, for a search index, a notification or an
|
- `adfToPlainText` writes a document as text with no markup, for a search index, a notification or an
|
||||||
email: blocks a blank line apart; `• ` and `1.` list markers, `☑ ` and `☐ ` for a done and an open
|
email: blocks a blank line apart; `• ` and `1.` list markers, `☑ ` and `☐ ` for a done and an open
|
||||||
task, nesting indented; a link's address and title in parentheses after its text; a hard break as a
|
task, nesting indented; a link's address and title in parentheses after its text; a hard break as a
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ content. No stylesheet ships. The complete dialect:
|
|||||||
| `paragraph` | `<p>` |
|
| `paragraph` | `<p>` |
|
||||||
| `rule` | `<hr>` |
|
| `rule` | `<hr>` |
|
||||||
| `table`, `tableRow`, `tableCell`, `tableHeader` | `<table>`, `<thead>` for a first row of `tableHeader` cells alone, `<tbody>`, `<tr>`, `<td>` and `<th>`; a cell's first paragraph stands as an item's does, and `<td colspan="2" rowspan="2" style="background-color:#fffae6" data-colwidth="120,80">` writes its attributes |
|
| `table`, `tableRow`, `tableCell`, `tableHeader` | `<table>`, `<thead>` for a first row of `tableHeader` cells alone, `<tbody>`, `<tr>`, `<td>` and `<th>`; a cell's first paragraph stands as an item's does, and `<td colspan="2" rowspan="2" style="background-color:#fffae6" data-colwidth="120,80">` writes its attributes |
|
||||||
| `text` marked `code`, `em`, `strong` | `<code>`, `<em>`, `<strong>`, the first mark outermost |
|
| `text` marked `code`, `em`, `strike`, `strong` | `<code>`, `<em>`, `<del>`, `<strong>`, the first mark outermost |
|
||||||
| an attribute its type holds that its element does not write, such as `localId`, on a paragraph, heading, quote, list, list item, table, row, cell, code block, rule, emoji, mention, status, date or card | `data-*` named as HTML's `dataset` names it: `<p data-local-id="a1f3">` |
|
| an attribute its type holds that its element does not write, such as `localId`, on a paragraph, heading, quote, list, list item, table, row, cell, code block, rule, emoji, mention, status, date or card | `data-*` named as HTML's `dataset` names it: `<p data-local-id="a1f3">` |
|
||||||
| any other node, or a node holding what its element cannot, except a shape Atlassian's schema forbids, which is refused ([The errors](#the-errors)) | `<div class="adf-carry" data-adf="{…}"><p>its content</p></div>`, a `<span>` inline |
|
| any other node, or a node holding what its element cannot, except a shape Atlassian's schema forbids, which is refused ([The errors](#the-errors)) | `<div class="adf-carry" data-adf="{…}"><p>its content</p></div>`, a `<span>` inline |
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -489,6 +489,10 @@ A sixth panel (2026-11-05, three readers in the same roles) picked each of these
|
|||||||
- a cell's attributes as `<td colspan="2" rowspan="2" style="background-color:#fffae6" data-colwidth="120,80">`,
|
- a cell's attributes as `<td colspan="2" rowspan="2" style="background-color:#fffae6" data-colwidth="120,80">`,
|
||||||
over `data-*` for all four.
|
over `data-*` for all four.
|
||||||
|
|
||||||
|
A seventh panel (2026-11-14, three readers in the same roles, after a reader panel expected `<s>` or
|
||||||
|
`<del>`) picked `<del>old</del>` for a `strike` mark, 3 of 3, over `<s>` and over a `<span>` styled
|
||||||
|
`text-decoration:line-through`: its name says what the text is, and GFM's renderers write it for `~~`.
|
||||||
|
|
||||||
## `htmlToAdf` also reads the dialect as a browser serializes it
|
## `htmlToAdf` also reads the dialect as a browser serializes it
|
||||||
|
|
||||||
2026-10-28, the maintainer. Goal 6. Valid while a viewer/editor app may show `adfToHtml`'s HTML in a
|
2026-10-28, the maintainer. Goal 6. Valid while a viewer/editor app may show `adfToHtml`'s HTML in a
|
||||||
@@ -1289,9 +1293,10 @@ the copy is refused as `unmappable-html` rather than saved. They expected:
|
|||||||
`<li data-state="DONE" data-local-id="…"><input type="checkbox" checked disabled> Write the spec</li>`.
|
`<li data-state="DONE" data-local-id="…"><input type="checkbox" checked disabled> Write the spec</li>`.
|
||||||
A `blockTaskItem` is an `<li>` of two `<p>`, a nested list an inner `<ul>`, and an empty item
|
A `blockTaskItem` is an `<li>` of two `<p>`, a nested list an inner `<ul>`, and an empty item
|
||||||
an `<li data-state="TODO">`.
|
an `<li data-state="TODO">`.
|
||||||
- The `strike` mark in Emphasis and strikethrough as `<s>relay</s>` or `<del>relay</del>`.
|
- The `strike` mark in Emphasis and strikethrough as `<s>relay</s>` or `<del>relay</del>`, which
|
||||||
|
`adfToHtml` writes as `<del>` (§The HTML dialect).
|
||||||
|
|
||||||
`todo.md` items 134 and 141 will write these; their writer panels pick the spelling with these
|
`todo.md` item 134 will write the rest; its writer panel picks the spelling with these
|
||||||
expectations as input. The Date row drew 1 of 3 not reasonable, so four more readers (bot,
|
expectations as input. The Date row drew 1 of 3 not reasonable, so four more readers (bot,
|
||||||
reader of the markdown, export/indexing, viewer/editor) read it, and 5 of 7 found it reasonable.
|
reader of the markdown, export/indexing, viewer/editor) read it, and 5 of 7 found it reasonable.
|
||||||
`adfToLosslessMarkdown` keeps writing `!adf:date{timestamp=1756080000000}`. The two who rejected
|
`adfToLosslessMarkdown` keeps writing `!adf:date{timestamp=1756080000000}`. The two who rejected
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ An un*real*istic goal.
|
|||||||
`adfToHtml`, round-trip holds:
|
`adfToHtml`, round-trip holds:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<p>Read the <em>manual</em> before <strong>wiring</strong> the <span class="adf-carry" data-adf="{"marks":[{"type":"strike"}],"text":"relay","type":"text"}">relay</span>.</p>
|
<p>Read the <em>manual</em> before <strong>wiring</strong> the <del>relay</del>.</p>
|
||||||
<p>An un<em>real</em>istic goal.</p>
|
<p>An un<em>real</em>istic goal.</p>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1093,3 +1093,20 @@ Read most (opens and searches):
|
|||||||
- `src/html/emit/adf-to-html.ts` 3
|
- `src/html/emit/adf-to-html.ts` 3
|
||||||
- `src/index.ts` 3
|
- `src/index.ts` 3
|
||||||
- `CHANGELOG.md` 2
|
- `CHANGELOG.md` 2
|
||||||
|
|
||||||
|
## Reading cost, chunk 19fae36f9c33, finished 2026-11-14T22:07:18Z
|
||||||
|
|
||||||
|
317879 new input tokens before the first commit.
|
||||||
|
|
||||||
|
Read most (opens and searches):
|
||||||
|
|
||||||
|
- `src/plain-text/adf-to-plain-text.test.ts` 7
|
||||||
|
- `README.md` 5
|
||||||
|
- `docs/decisions.md` 5
|
||||||
|
- `todo.md` 4
|
||||||
|
- `ci.sh` 2
|
||||||
|
- `src/adf/shown-text.ts` 2
|
||||||
|
- `src/html/carry-content.ts` 2
|
||||||
|
- `src/plain-text/adf-to-plain-text.ts` 2
|
||||||
|
- `CHANGELOG.md` 1
|
||||||
|
- `docker-runner.sh` 1
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ block's `data-*` attributes stand on its `<pre>`.
|
|||||||
| ADF | HTML |
|
| ADF | HTML |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `date` | `<time class="adf-date" datetime="2025-08-25" data-timestamp="1756080000000">2025-08-25</time>`, the day in UTC |
|
| `date` | `<time class="adf-date" datetime="2025-08-25" data-timestamp="1756080000000">2025-08-25</time>`, the day in UTC |
|
||||||
| `em`, `strong`, `code` | `<em>`, `<strong>`, `<code>` around the text |
|
| `em`, `strike`, `strong`, `code` | `<em>`, `<del>`, `<strong>`, `<code>` around the text |
|
||||||
| `emoji` | `<span class="adf-emoji" data-id="1f389" data-short-name=":tada:">🎉</span>`, its `text` the content |
|
| `emoji` | `<span class="adf-emoji" data-id="1f389" data-short-name=":tada:">🎉</span>`, its `text` the content |
|
||||||
| `hardBreak` | `<br>` |
|
| `hardBreak` | `<br>` |
|
||||||
| `inlineCard`, holding a `url` | `<a class="adf-inline-card" href="https://example.com/spec">https://example.com/spec</a>` |
|
| `inlineCard`, holding a `url` | `<a class="adf-inline-card" href="https://example.com/spec">https://example.com/spec</a>` |
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ test('writes the marks CommonMark spells, the first mark outermost', () => {
|
|||||||
assert.equal(html(adfToHtml(document(paragraph(text('Line one'), { type: 'hardBreak' }, text('Line two'))))), '<p>Line one<br>Line two</p>\n')
|
assert.equal(html(adfToHtml(document(paragraph(text('Line one'), { type: 'hardBreak' }, text('Line two'))))), '<p>Line one<br>Line two</p>\n')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('writes a strike mark as <del>, a strike mark holding attributes as a carry element', () => {
|
||||||
|
assert.equal(html(adfToHtml(document(paragraph(text('old', { type: 'strike' }), text(' new', { type: 'strong' }, { type: 'strike' }))))), '<p><del>old</del><strong><del> new</del></strong></p>\n')
|
||||||
|
assert.match(html(adfToHtml(document(paragraph(text('old', { attrs: { x: 1 }, type: 'strike' }))))), /^<p><span class="adf-carry" data-adf=/)
|
||||||
|
})
|
||||||
|
|
||||||
test('escapes text, and keeps tabs, line feeds and form feeds', () => {
|
test('escapes text, and keeps tabs, line feeds and form feeds', () => {
|
||||||
assert.equal(html(adfToHtml(document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh'))))), '<p>a < b && c > "d" \'e\'\tf\ng\fh</p>\n')
|
assert.equal(html(adfToHtml(document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh'))))), '<p>a < b && c > "d" \'e\'\tf\ng\fh</p>\n')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
const markElements: ReadonlyMap<string, string> = new Map([
|
const markElements: ReadonlyMap<string, string> = new Map([
|
||||||
['code', 'code'],
|
['code', 'code'],
|
||||||
['em', 'em'],
|
['em', 'em'],
|
||||||
|
['strike', 'del'],
|
||||||
['strong', 'strong'],
|
['strong', 'strong'],
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ test('reads text\'s marks from its elements, the outermost first, and each run o
|
|||||||
assert.deepEqual(read(htmlToAdf('<p><a href="x" title="">y</a></p>\n')), document(paragraph(text('y', { attrs: { href: 'x', title: '' }, type: 'link' }))))
|
assert.deepEqual(read(htmlToAdf('<p><a href="x" title="">y</a></p>\n')), document(paragraph(text('y', { attrs: { href: 'x', title: '' }, type: 'link' }))))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('reads <del> as a strike mark', () => {
|
||||||
|
assert.deepEqual(read(htmlToAdf('<p><del>old</del><strong><del> new</del></strong></p>\n')), document(paragraph(text('old', { type: 'strike' }), text(' new', { type: 'strong' }, { type: 'strike' }))))
|
||||||
|
})
|
||||||
|
|
||||||
test('reads escaped text, and keeps tabs, line feeds and form feeds', () => {
|
test('reads escaped text, and keeps tabs, line feeds and form feeds', () => {
|
||||||
assert.deepEqual(read(htmlToAdf('<p>a < b && c > "d" \'e\'\tf\ng\fh &lt;</p>\n')), document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh <'))))
|
assert.deepEqual(read(htmlToAdf('<p>a < b && c > "d" \'e\'\tf\ng\fh &lt;</p>\n')), document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh <'))))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
| 141 | 0.4.0 | | decision | **Write `strike` as HTML in `adfToHtml` and read it back in `htmlToAdf`, in place of the carry element.** | 1 | 1 | 1 | 1 | 2 | 6 by 2 | 3.2 |
|
|
||||||
| 135 | 0.4.0 | | | **Write media, media groups and captions as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 4 | 6 by 2 | 1.6 |
|
| 135 | 0.4.0 | | | **Write media, media groups and captions as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 4 | 6 by 2 | 1.6 |
|
||||||
| 136 | 0.4.0 | | | **Write underline, text and background colours, subscript, superscript, alignment and indentation as HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 4 | 6 by 2 | 1.6 |
|
| 136 | 0.4.0 | | | **Write underline, text and background colours, subscript, superscript, alignment and indentation as HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 4 | 6 by 2 | 1.6 |
|
||||||
| 134 | 0.4.0 | | decision | **Write panels, expands, task lists and decision lists as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 5 | 6 by 3 | 1.5 |
|
| 134 | 0.4.0 | | decision | **Write panels, expands, task lists and decision lists as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.** | 2 | 2 | 2 | 4 | 5 | 6 by 3 | 1.5 |
|
||||||
@@ -49,12 +48,6 @@
|
|||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
### 141. Write `strike` as HTML in `adfToHtml` and read it back in `htmlToAdf`, in place of the carry element.
|
|
||||||
|
|
||||||
GFM spells `strike`, and no other HTML item writes it: `adfToHtml` writes only the marks CommonMark
|
|
||||||
spells. A writer panel picks `<s>` or `<del>`. A reader panel (`docs/decisions.md`, the
|
|
||||||
feature-table entry) expected `<s>` or `<del>`, and the writer panel takes that as input.
|
|
||||||
|
|
||||||
### 135. Write media, media groups and captions as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.
|
### 135. Write media, media groups and captions as semantic HTML in `adfToHtml` and read them back in `htmlToAdf`, in place of the carry element.
|
||||||
|
|
||||||
A writer panel picks the spellings; a plain external image already has one, `<p><img …></p>`.
|
A writer panel picks the spellings; a plain external image already has one, `<p><img …></p>`.
|
||||||
|
|||||||
Reference in New Issue
Block a user