This is a link!
\n"') +}) + +test('removes links with invalid URL', () => { + const rendered = useMarkdown('This is [a link](ftp://example.com)!') + expect(rendered.value).toMatchInlineSnapshot('"This is !
\n"') +}) + +test('renders images', () => { + const rendered = useMarkdown('') + expect(rendered.value).toMatchInlineSnapshot('"alt text
\n"') +}) + +test('renders images with title', () => { + const rendered = useMarkdown('') + expect(rendered.value).toMatchInlineSnapshot('"Title
\n"') +}) + +test('renders images with alt text and title', () => { + const rendered = useMarkdown('') + expect(rendered.value).toMatchInlineSnapshot(` + "alt text
\n" + `) +}) + +test('renders block quotes', () => { + const rendered = useMarkdown('> This is a block quote') + expect(rendered.value).toMatchInlineSnapshot('"This is a block quote"') +}) + +test('renders headings', () => { + const rendered = useMarkdown('# level 1\n## level 2\n### level 3\n#### level 4\n##### level 5\n###### level 6\n') + expect(rendered.value).toMatchInlineSnapshot('"
${text}` +} + +/** + * Get a custom heading renderer that clamps heading levels + * + * @param minHeading - The heading to clamp to + */ +function getMarkedHeading(minHeading: number) { + /** + * Custom heading renderer that adjusts heading levels + * + * @param ctx - The render context + * @param ctx.text - The heading text + * @param ctx.depth - The heading depth + */ + return ({ text, depth }: Tokens.Heading): string => { + depth = Math.min(6, depth + (minHeading - 1)) + return `