Commit a7540793 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'himkp-fix-markdown-serialization' into 'master'

Fix markdown serialization in content editor

See merge request gitlab-org/gitlab!81849
parents 15ed788c b9713c00
...@@ -259,11 +259,16 @@ export function renderContent(state, node, forceRenderInline) { ...@@ -259,11 +259,16 @@ export function renderContent(state, node, forceRenderInline) {
} }
} }
export function renderHTMLNode(tagName, forceRenderInline = false) { export function renderHTMLNode(tagName, forceRenderContentInline = false) {
return (state, node) => { return (state, node) => {
renderTagOpen(state, tagName, node.attrs); renderTagOpen(state, tagName, node.attrs);
renderContent(state, node, forceRenderInline); renderContent(state, node, forceRenderContentInline);
renderTagClose(state, tagName, false); renderTagClose(state, tagName, false);
if (forceRenderContentInline) {
state.closeBlock(node);
state.flushClose();
}
}; };
} }
......
...@@ -55,7 +55,7 @@ const testSerializesHtmlToMarkdownForElement = async ({ markdown, html }) => { ...@@ -55,7 +55,7 @@ const testSerializesHtmlToMarkdownForElement = async ({ markdown, html }) => {
// Assert that the markdown we ended up with after sending it through all the ContentEditor // Assert that the markdown we ended up with after sending it through all the ContentEditor
// plumbing matches the original markdown from the YAML. // plumbing matches the original markdown from the YAML.
expect(serializedContent).toBe(markdown); expect(serializedContent.trim()).toBe(markdown.trim());
}; };
// describeMarkdownProcesssing // describeMarkdownProcesssing
......
...@@ -597,6 +597,7 @@ this is not really json but just trying out whether this case works or not ...@@ -597,6 +597,7 @@ this is not really json but just trying out whether this case works or not
paragraph('A giant ', italic('owl-like'), ' creature.'), paragraph('A giant ', italic('owl-like'), ' creature.'),
), ),
), ),
heading('this is a heading'),
), ),
).toBe( ).toBe(
` `
...@@ -612,6 +613,8 @@ A giant _owl-like_ creature. ...@@ -612,6 +613,8 @@ A giant _owl-like_ creature.
</dd> </dd>
</dl> </dl>
# this is a heading
`.trim(), `.trim(),
); );
}); });
...@@ -623,6 +626,7 @@ A giant _owl-like_ creature. ...@@ -623,6 +626,7 @@ A giant _owl-like_ creature.
detailsContent(paragraph('this is the summary')), detailsContent(paragraph('this is the summary')),
detailsContent(paragraph('this content will be hidden')), detailsContent(paragraph('this content will be hidden')),
), ),
heading('this is a heading'),
), ),
).toBe( ).toBe(
` `
...@@ -630,6 +634,8 @@ A giant _owl-like_ creature. ...@@ -630,6 +634,8 @@ A giant _owl-like_ creature.
<summary>this is the summary</summary> <summary>this is the summary</summary>
this content will be hidden this content will be hidden
</details> </details>
# this is a heading
`.trim(), `.trim(),
); );
}); });
...@@ -648,7 +654,7 @@ this content will be hidden ...@@ -648,7 +654,7 @@ this content will be hidden
detailsContent(paragraph('this content will be ', italic('hidden'))), detailsContent(paragraph('this content will be ', italic('hidden'))),
), ),
details(detailsContent(paragraph('summary 2')), detailsContent(paragraph('content 2'))), details(detailsContent(paragraph('summary 2')), detailsContent(paragraph('content 2'))),
), ).trim(),
).toBe( ).toBe(
` `
<details> <details>
...@@ -669,6 +675,7 @@ console.log(c); ...@@ -669,6 +675,7 @@ console.log(c);
this content will be _hidden_ this content will be _hidden_
</details> </details>
<details> <details>
<summary>summary 2</summary> <summary>summary 2</summary>
content 2 content 2
...@@ -694,7 +701,7 @@ content 2 ...@@ -694,7 +701,7 @@ content 2
), ),
), ),
), ),
), ).trim(),
).toBe( ).toBe(
` `
<details> <details>
...@@ -709,7 +716,9 @@ content 2 ...@@ -709,7 +716,9 @@ content 2
_inception_ _inception_
</details> </details>
</details> </details>
</details> </details>
`.trim(), `.trim(),
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment