diff --git a/src/html/parse/html-to-adf.test.ts b/src/html/parse/html-to-adf.test.ts index 4e50335..2bf58f6 100644 --- a/src/html/parse/html-to-adf.test.ts +++ b/src/html/parse/html-to-adf.test.ts @@ -279,7 +279,13 @@ const messages: readonly (readonly [string, string])[] = [ ['

a

\n', ' holds its attributes as name="value", each value escaped as text is, then >: found "b\\">a

\\n"'], ['

a \u00a0

\n', 'text escapes &, <, > and " as &, <, > and ", and holds no character HTML cannot hold: found " \\u00a0

\\n"'], ['
a
: found "\n
  • a\n', 'an item\'s line ends at
  • , or at a line feed before the item\'s next block: found "\\n"'], + ['
    x
    \n', ' as written here is no code element of the dialect, which writes or : found "\n
  • a\n', 'an item\'s line ends at
  • , or at a line feed before the item\'s next block, and its text spells < as <: found "\\n"'], + ['
      \n
    • ab
    • \n
    \n', ' as written here is no inline element of the dialect: found "b\\n\\n"'], + ['
      \n
    • if a < b
    • \n
    \n', 'an item\'s line ends at , or at a line feed before the item\'s next block, and its text spells < as <: found "< b\\n\\n"'], + ['
      \n
    • see x
    • \n
    \n', ' holds its attributes as name="value", each value escaped as text is, then >: found "&b=2\\">x\\n\\n"'], + ['

    x

    \n', ' as written here is no mark element of the dialect: found "x

    \\n"'], + ['

    x

    \n', ' holds its attributes as name="value", each value escaped as text is, then >: found "&b=2\\">x

    "…'], [`

    a

    \n${carry('div', panel, '

    Check the collation.

    ')}\n`, 'a carry element shows its node\'s text as adfToHtml writes it, then ends at ; an edit to it is no edit to the node: found "collation.

    holds , or naming the language', 'neither') + const stop = misread(html, tag.end, '
     holds , or  naming the language', 'no code element of the dialect, which writes  or ')
         return refused('unmappable-html', stop.message, html, stop.at, place)
       }
       const next = html.indexOf('<', code.end)
    @@ -248,7 +248,8 @@ function readItemLine(html: string, index: number, open: Open): Result', end) && !html.startsWith('\n', end)) {
    -    return refused('unmappable-html', `an item's line ends at , or at a line feed before the item's next block: ${foundAt(html, end)}`, html, end, open.place)
    +    const stop = misread(html, end, "an item's line ends at , or at a line feed before the item's next block, and its text spells < as <", 'no inline element of the dialect')
    +    return refused('unmappable-html', stop.message, html, stop.at, open.place)
       }
       const paragraph = asFirstParagraph({ end, node }, line.value.form, html, index, place)
       if (!paragraph.ok) return paragraph
    diff --git a/src/html/parse/inline.ts b/src/html/parse/inline.ts
    index 7829148..31c65ad 100644
    --- a/src/html/parse/inline.ts
    +++ b/src/html/parse/inline.ts
    @@ -1,6 +1,6 @@
     import type { AdfMark, AdfNode } from '../../adf/document.ts'
     import type { ParseError, Result } from '../../result.ts'
    -import { foundAt, readStartTag, refused, type Place, type ReadNode, type StartTag } from './source.ts'
    +import { foundAt, misread, readStartTag, refused, type Place, type ReadNode, type StartTag } from './source.ts'
     import { largestNesting } from '../../nesting.ts'
     import { linkMarkFrom } from '../../adf/mark-attributes.ts'
     import { markOfElement } from '../mark-elements.ts'
    @@ -46,7 +46,10 @@ function readMarked(html: string, index: number, place: Place): ReadNode {
         closers.unshift(``)
         at = tag.end
       }
    -  if (at === html.length || html.startsWith('<', at)) return refused('unmappable-html', `a mark element holds one text, or one mark element holding it: ${foundAt(html, at)}`, html, at, place)
    +  if (at === html.length || html.startsWith('<', at)) {
    +    const stop = misread(html, at, 'a mark element holds one text, or one mark element holding it', 'no mark element of the dialect')
    +    return refused('unmappable-html', stop.message, html, stop.at, place)
    +  }
       const text = readText(html, at, marks, place)
       if (!text.ok) return text
       at = text.value.end