mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-18 06:05:43 +01:00
Kill the surviving mutants of the indentation and opened-details reads
This commit is contained in:
@@ -739,6 +739,8 @@ const pinnedRefusals: readonly (readonly [string, string])[] = [
|
||||
['<div class="adf-media-group"><span class="adf-file" data-id="a" data-type="file"></span>x</div>\n', 'unmappable-html at /content/0: <div> holds its <span class="adf-file"> files, then </div>: found "x</div>\\n"'],
|
||||
['<p style="color:red">a</p>\n', 'unmappable-html at /content/0: style on <p> holds text-align:center or text-align:right'],
|
||||
['<h1 style="text-align:left">a</h1>\n', 'unmappable-html at /content/0: style on <h1> holds text-align:center or text-align:right'],
|
||||
['<p data-indent-level="7">a</p>\n', 'unmappable-html at /content/0: data-indent-level on <p> holds a whole number from 1 to 6'],
|
||||
['<h3 data-indent-level="">a</h3>\n', 'unmappable-html at /content/0: data-indent-level on <h3> holds a whole number from 1 to 6'],
|
||||
['<p>a <span title="color:red">b</span></p>\n', 'unmappable-html at /content/0/content/1: a <span> of the dialect is a carry element, holding class="adf-carry" and then data-adf alone, or opens with class="adf-emoji", "adf-mention" or "adf-status": found "<span title=\\"color:red\\">"…'],
|
||||
['<blockquote><p>a</p></blockquote>\n', 'unmappable-html at /content/0: <blockquote> holds </blockquote> straight after it, or a line feed and its first block: found "<p>a</p></blockquote>\\n"'],
|
||||
['<ul><li>a</li></ul>\n', 'unmappable-html at /content/0: <ul> holds </ul> straight after it, or a line feed and its first item: found "<li>a</li></ul>\\n"'],
|
||||
|
||||
@@ -242,7 +242,8 @@ function readDetails(html: string, tag: StartTag, place: Place, open: Open): Res
|
||||
const [first, ...pairs] = tag.attributes
|
||||
const type = first?.[0] === 'class' ? expandOfClass(first[1]) : undefined
|
||||
if (type === undefined) return refused('unmappable-html', `<details> starts with class="${expandClasses.expand}" or class="${expandClasses.nestedExpand}": ${foundAt(html, tag.start)}`, html, tag.start, place)
|
||||
const opened = pairs.at(-1)?.[0] === 'open' && pairs.at(-1)?.[1] === ''
|
||||
const last = pairs.at(-1)
|
||||
const opened = last?.[0] === 'open' && last[1] === ''
|
||||
const data = readDataAttributes(opened ? pairs.slice(0, -1) : pairs, tag.name, blockNodes[type].attributes, ['title'])
|
||||
if (data.fault !== undefined) return refused(data.fault.code, data.fault.message, html, tag.start, place)
|
||||
const summary = html.startsWith('\n<summary>', tag.end) ? readSummary(html, tag.end + 1, place) : undefined
|
||||
|
||||
@@ -30,7 +30,8 @@ function markAttribute(mark: AdfMark): string | undefined {
|
||||
const attrs = nodeAttrs(mark)
|
||||
if (Object.keys(attrs).length !== 1) return undefined
|
||||
const { align, level } = attrs
|
||||
if (mark.type === 'alignment' && typeof align === 'string') return alignments().has(align) ? ` style="text-align:${alignments().get(align)}"` : undefined
|
||||
const textAlign = [...alignments()].find(([name]) => name === align)?.[1]
|
||||
if (mark.type === 'alignment') return textAlign === undefined ? undefined : ` style="text-align:${textAlign}"`
|
||||
return mark.type === 'indentation' && typeof level === 'number' && indentLevels.includes(String(level)) ? ` ${indentAttribute}="${level}"` : undefined
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user