Skip to content

Commit a457fa8

Browse files
authored
Merge pull request #8718 from nextcloud/fix/math_close_div
fix(math): fix lost content after math node
2 parents 918b492 + 58b8b46 commit a457fa8

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/markdownit/mathematics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const escapeHtml = (unsafe: string) =>
2121
.replace(/'/g, ''')
2222

2323
const renderBlock = (content: string) =>
24-
`<div data-type="block-math" data-latex="${escapeHtml(content)}" />`
24+
`<div data-type="block-math" data-latex="${escapeHtml(content)}"></div>`
2525

2626
const renderInline = (content: string) =>
2727
`<span data-type="inline-math" data-latex="${escapeHtml(content)}">${escapeHtml(content)}</span>`

src/tests/markdown.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ describe('Markdown serializer from html', () => {
346346
'<details>\n<summary>**summary**</summary>\n```\ncode\n```\n\n</details>\n',
347347
)
348348
})
349+
350+
test('math (content following math stays, #8654)', () => {
351+
const test =
352+
'Content above\n\n$$\n\\sum_{i=1}^n i = \\frac{n(n+1)}{2}\n$$\n\nContent below'
353+
expect(markdownThroughEditor(test)).toBe(test)
354+
})
349355
})
350356

351357
describe('Trailing nodes', () => {

src/tests/markdownit/mathematics.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $$
3030
expect(stripIndent(rendered)).toBe(
3131
stripIndent(`
3232
<p>Here is some more math:</p>
33-
<div data-type="block-math" data-latex="1 + 1 + 1 = 3" />
33+
<div data-type="block-math" data-latex="1 + 1 + 1 = 3"></div>
3434
<p>.</p>`),
3535
)
3636
})

0 commit comments

Comments
 (0)