fix: render task notes with standard markdown
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 6m20s

This commit is contained in:
2026-09-15 13:56:44 +08:00
parent ebabb87780
commit 9e1847329b
7 changed files with 117 additions and 93 deletions
+10 -6
View File
@@ -86,16 +86,20 @@ describe('task utilities', () => {
expect(buildTaskRecurrencePayload('none', { afterCompletionDays: '1' })).toEqual({})
})
it('renders safe practical markdown and strips unsafe html', () => {
const html = renderMarkdown('# Plan\n> Note\n1. first\n- [x] done\n\n```js\nconst x = 1\n```\n**bold** [link](https://example.com)\n<script>alert(1)</script>')
it('renders safe standard markdown with paragraphs, nesting, tasks, and fenced code', () => {
const html = renderMarkdown('# Plan\n\nFirst line\nsecond line\n\n- parent\n - child\n\n- [x] done\n\n```js\nconst x = 1\n```\n\n**bold** [link](https://example.com)\n<script>alert(1)</script>')
expect(html).toContain('<h1>Plan</h1>')
expect(html).toContain('<blockquote>Note</blockquote>')
expect(html).toContain('<ol><li>first</li></ol>')
expect(html).toContain('type="checkbox" disabled checked')
expect(html).toContain('<pre><code class="language-js">const x = 1</code></pre>')
expect(html).toContain('<p>First line<br>\nsecond line</p>')
expect(html).toMatch(/<li>\s*<p>parent<\/p>\s*<ul>\s*<li>child<\/li>\s*<\/ul>\s*<\/li>/)
expect(html).toContain('class="task-list-item')
expect(html).toContain('type="checkbox"')
expect(html).toContain('checked=""')
expect(html).toContain('<pre><code class="language-js">const x = 1\n</code></pre>')
expect(html).toContain('<strong>bold</strong>')
expect(html).toContain('target="_blank"')
expect(html).toContain('rel="noopener noreferrer"')
expect(html).not.toContain('<script>')
expect(html).toContain('&lt;script&gt;alert(1)&lt;/script&gt;')
})
it('inserts markdown around selections and prefixes selected lines', () => {