extra checks on markdown links
This commit is contained in:
parent
e603cbc94b
commit
50aac161c4
@ -20,7 +20,7 @@
|
||||
|
||||
<dfn class="not-italic" title="Internal link">
|
||||
<span class="underline cursor-not-allowed inline-flex items-center">
|
||||
<span class="text-[#705dcf] opacity-50">
|
||||
<span class="internal-link text-[#705dcf] opacity-50">
|
||||
{#if useSlot}
|
||||
<slot />
|
||||
{:else}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
{#if isWebLink}
|
||||
<span class="underline cursor-not-allowed inline-flex items-center font-normal">
|
||||
<a {href} {title} class="text-[#705dcf]"><slot /></a>
|
||||
<a {href} {title} class="external-link text-[#705dcf]"><slot /></a>
|
||||
<span class="h-3 mb-2 text-zinc-400 ml-0.5"><LinkIcon /></span>
|
||||
</span>
|
||||
{:else}
|
||||
|
@ -10,35 +10,41 @@ describe('rendering [[internal]] links', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Normal internal link$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders [[links|with alias]] correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Link with alias$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders [[links#heading]] correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Page with headings > heading A$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders [[links#heading|with alias]] correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Link with heading alias$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders [[links#heading|with alias#fakeheading]] correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Link with heading alias#false heading$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Does not render [[]] empty links', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const textEl = await screen.findByText('[[]]', { exact: false });
|
||||
expect(textEl).toBeInTheDocument();
|
||||
expect(textEl).not.toHaveClass('internal-link');
|
||||
});
|
||||
});
|
||||
|
@ -9,23 +9,27 @@ describe('rendering [md style](links)', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Classic internal link \(URL encoded\)$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders URL-encoded internal links correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Classic internal link \(tag format\)$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('internal-link');
|
||||
});
|
||||
|
||||
it('Renders http links correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/^Wikipedia \(http\)$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('external-link');
|
||||
});
|
||||
|
||||
it('Renders https links correctly', async () => {
|
||||
render(MarkdownRenderer, { plaintext: plaintext });
|
||||
const linkEl = await screen.findByText(/Wikipedia \(https\)$/);
|
||||
expect(linkEl).toBeInTheDocument();
|
||||
expect(linkEl).toHaveClass('external-link');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user