Files
BoosAPI/desktop/libs/markstream-vue/test/custom-html-close-inline-context-regression.test.ts
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

61 lines
2.3 KiB
TypeScript

import { getMarkdown, parseMarkdownToStructure } from 'stream-markdown-parser'
import { describe, expect, it } from 'vitest'
describe('custom html close same-line markers in inline contexts', () => {
const tags = ['my_component']
const md = getMarkdown('custom-html-close-inline-context-regression', { customHtmlTags: tags })
const markerCases = [
{ label: 'heading marker', suffix: '## h' },
{ label: 'bullet marker', suffix: '- item' },
{ label: 'ordered marker', suffix: '1. item' },
{ label: 'blockquote marker', suffix: '> quote' },
{ label: 'admonition marker', suffix: '::: tip' },
{ label: 'math marker', suffix: '$$x' },
] as const
it.each(markerCases)(
'does not split paragraph when custom tag is inline and followed by $label',
({ suffix }) => {
const markdown = `Text <my_component label="x"></my_component>${suffix}`
const nodes = parseMarkdownToStructure(markdown, md, { customHtmlTags: tags, final: true }) as any[]
expect(nodes).toHaveLength(1)
expect(nodes[0]?.type).toBe('paragraph')
},
)
it.each(markerCases)(
'does not split list item when custom tag is inline and followed by $label',
({ suffix }) => {
const markdown = `- Text <my_component label="x"></my_component>${suffix}`
const nodes = parseMarkdownToStructure(markdown, md, { customHtmlTags: tags, final: true }) as any[]
expect(nodes).toHaveLength(1)
expect(nodes[0]?.type).toBe('list')
expect(nodes[0]?.items).toHaveLength(1)
},
)
it.each(markerCases)(
'does not split blockquote line when custom tag is inline and followed by $label',
({ suffix }) => {
const markdown = `> Text <my_component label="x"></my_component>${suffix}`
const nodes = parseMarkdownToStructure(markdown, md, { customHtmlTags: tags, final: true }) as any[]
expect(nodes).toHaveLength(1)
expect(nodes[0]?.type).toBe('blockquote')
const inner = nodes[0]?.children ?? []
expect(inner).toHaveLength(1)
expect(inner[0]?.type).toBe('paragraph')
},
)
it('still splits when custom block starts at line start', () => {
const markdown = '<my_component>t</my_component>## h'
const nodes = parseMarkdownToStructure(markdown, md, { customHtmlTags: tags, final: true }) as any[]
expect(nodes.map(n => n.type)).toEqual(['paragraph', 'heading'])
})
})