Skip to content

Commit

Permalink
fix: don't throw when Shiki doesn't recognize a language (withastro#3911
Browse files Browse the repository at this point in the history
)

* Don't throw when Shiki doesn't recognise a language

* Changeset
  • Loading branch information
JuanM04 authored Jul 13, 2022
1 parent 0a84148 commit d1ab93d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/astro-markdown-shiki.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ describe('Astro Markdown Shiki', () => {
expect(segments[0].attribs.style).to.be.equal('color: #C9D1D9');
expect(segments[1].attribs.style).to.be.equal('color: #79C0FF');
expect(segments[2].attribs.style).to.be.equal('color: #C9D1D9');

const unknownLang = $('.line').last().html();
expect(unknownLang).to.be.equal('<span style="color: #c9d1d9">This language does not exist</span>')
});

it('<Markdown /> component', async () => {
Expand All @@ -129,6 +132,9 @@ describe('Astro Markdown Shiki', () => {
expect(segments).to.have.lengthOf(3);
expect(segments[0].attribs.style).to.be.equal('color: #C9D1D9');
expect(segments[1].attribs.style).to.be.equal('color: #79C0FF');

const unknownLang = $('.line').last().html();
expect(unknownLang).to.be.equal('<span style="color: #c9d1d9">This language does not exist</span>')
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ import Layout from '../layouts/content.astro';
Iniciar(Rinfo, 1, 1)
fin
```

```unknown
This language does not exist
```
</Markdown>
</Layout>
4 changes: 4 additions & 0 deletions test/fixtures/astro-markdown-shiki/langs/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ comenzar
Iniciar(Rinfo, 1, 1)
fin
```

```unknown
This language does not exist
```

0 comments on commit d1ab93d

Please sign in to comment.