shows relative images in markdown
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
2026-09-14 11:27:10 +02:00
parent f6a551d7c4
commit a2d1c5df83
6 changed files with 230 additions and 29 deletions

View File

@@ -70,4 +70,31 @@ describe('renderMarkdown', () => {
expect(html).not.toContain('<table')
expect(html).toContain('<p>a | b not a table</p>')
})
it('resolves a relative image against the document folder', () => {
const html = renderMarkdown('![Forge](forge-app-config.png)', 'docs/how-to')
expect(html).toContain('data-src="docs/how-to/forge-app-config.png"')
expect(html).not.toContain(' src=')
})
it('keeps the image title out of the path and walks up a parent folder', () => {
const html = renderMarkdown('![c](../img/a%20b.png "A title")', 'docs/how-to')
expect(html).toContain('data-src="docs/img/a b.png"')
expect(html).toContain('title="A title"')
})
it('reads a leading slash as the project root', () => {
expect(renderMarkdown('![c](/img/a.png)', 'docs/how-to')).toContain('data-src="img/a.png"')
})
it('leaves a remote image on src', () => {
const html = renderMarkdown('![c](https://x.com/a.png)', 'docs')
expect(html).toContain('src="https://x.com/a.png"')
expect(html).not.toContain('data-src')
})
it('keeps a link title out of the href', () => {
const html = renderMarkdown('[a](https://x.com "Home")')
expect(html).toContain('href="https://x.com"')
expect(html).toContain('title="Home"')
})
})