fix: 修复嵌套 markdown fence 导致的渲染截断 (#222)

* fix: keep nested markdown fences rendered

* fix: prevent thinking placeholder leaks

* fix: normalize nested markdown example fences
This commit is contained in:
Zhicheng Han
2026-04-26 03:39:49 +02:00
committed by GitHub
parent d2ab2bca08
commit d0bd09ae57
5 changed files with 400 additions and 6 deletions
+18
View File
@@ -92,6 +92,24 @@ describe('parseThinking', () => {
expect(r.body).toBe('text\n```\n<think>fake</think>\n```')
})
it('does not leak code-protection placeholders for inline mentions of markdown fences', () => {
const src = [
'Previous fix kept the outer ` ```md ` block as code.',
'',
'````md',
'下面是可直接手动编辑的 PR draft。',
'```md',
'标题',
'```',
'````',
].join('\n')
const r = parseThinking(src, { streaming: false })
expect(r.hasThinking).toBe(false)
expect(r.body).toBe(src)
expect(r.body).not.toContain('THKCODE')
expect(r.body).not.toContain('\u0000')
})
it('same-name nesting: inner tag absorbed into first segment (documented limitation)', () => {
const r = parseThinking('<think>a<think>b</think>c</think>', { streaming: false })
expect(r.segments).toEqual(['a<think>b'])