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