diff --git a/src/adf/document.ts b/src/adf/document.ts index c91858e..6d88590 100644 --- a/src/adf/document.ts +++ b/src/adf/document.ts @@ -157,11 +157,7 @@ function refusedShape(content: readonly AdfNode[]): Result | undefined { for (let up: Step | undefined = step; up !== undefined; up = up.parent) path.unshift('content', up.index) return failure('unsupported-node-shape', 'an inlineCard takes no link mark: this one holds one', path) } - const children = nodeContent(step.node) - for (let index = children.length - 1; index >= 0; index -= 1) { - const node = children[index] - if (node !== undefined) pending.push({ index, node, parent: step }) - } + for (const child of nodeContent(step.node).map((node, index) => ({ index, node, parent: step })).reverse()) pending.push(child) } return undefined } diff --git a/src/conformance/property-harness.ts b/src/conformance/property-harness.ts index fe67091..ac1960d 100644 --- a/src/conformance/property-harness.ts +++ b/src/conformance/property-harness.ts @@ -123,8 +123,11 @@ const autolinkTextNode = fc .record({ href: fc.tuple(fc.constantFrom('ab:', 'http://'), textOf(0)).map(([scheme, rest]) => `${scheme}${rest}`), marks }) .map(({ href, marks: held }): AdfNode => ({ marks: [...held.filter((outer) => outer.type !== 'link'), { attrs: { href }, type: 'link' }], text: href, type: 'text' })) +// Atlassian's schema gives a card no link mark, which every writer refuses. +const cardMarks = marks.map((held) => held.filter(({ type }) => type !== 'link')) + const inlineArbitraries = Object.entries(inlineNodes).map(([type, model]) => - occasionallyEmpty(fc.record({ attrs: attributes(model.attributes), marks }).map((held): AdfNode => ({ ...held, type }))), + occasionallyEmpty(fc.record({ attrs: attributes(model.attributes), marks: type === 'inlineCard' ? cardMarks : marks }).map((held): AdfNode => ({ ...held, type }))), ) function weighted(arbitraries: readonly Arbitrary[], weight: number): { arbitrary: Arbitrary; weight: number }[] {