blob: cf84bb21fd14ff6d491dfb6ee1878fa3c1a332a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import * as md from './markdown.js';
import { expect, describe, it } from 'vitest';
describe('render', async () => {
it('renders inline links', async () => {
const markdown = `[a link](https://example.com?foo=bar)`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a target="_blank" rel="noreferrer" href="https://example.com?foo=bar">a link</a></p>
`,
);
});
it('renders inline links with titles', async () => {
const markdown = `[a link](https://example.com?foo=bar "what title")`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a target="_blank" rel="noreferrer" title="what title" href="https://example.com?foo=bar">a link</a></p>
`,
);
});
it('renders footnote links', async () => {
const markdown = `
[a link]
[a link]: https://example.com?foo=bar`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a target="_blank" rel="noreferrer" href="https://example.com?foo=bar">a link</a></p>
`,
);
});
it('renders footnote links with titles', async () => {
const markdown = `
[a link]
[a link]: https://example.com?foo=bar "what title"`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a target="_blank" rel="noreferrer" title="what title" href="https://example.com?foo=bar">a link</a></p>
`,
);
});
it('renders links with embedded markup', async () => {
const markdown = `[a _link_](https://example.com?foo=bar)`;
const html = md.render(markdown);
expect(html).toStrictEqual(
`<p><a target="_blank" rel="noreferrer" href="https://example.com?foo=bar">a <em>link</em></a></p>
`,
);
});
});
|