(symmetric to video) so the round-trip md -> html ->
+// json restores the caption via the image extension's parseHTML.
+test("image without a caption emits plain ", () => {
+ const input = doc({
+ type: "image",
+ attrs: { src: "/files/a.png", alt: "cat" },
+ });
+ assert.equal(convertProseMirrorToMarkdown(input), "");
+});
+
+test("image with a caption emits a raw
![]()
in a block div", () => {
+ const input = doc({
+ type: "image",
+ attrs: { src: "/files/a.png", alt: "cat", caption: "A grey cat" },
+ });
+ assert.equal(
+ convertProseMirrorToMarkdown(input),
+ '
',
+ );
+});
+
+test("image caption escapes & and \" in the data-caption attribute", () => {
+ const input = doc({
+ type: "image",
+ attrs: { src: "/files/a.png", caption: 'Tom & "Jerry"' },
+ });
+ assert.equal(
+ convertProseMirrorToMarkdown(input),
+ '
',
+ );
+});