diff options
author | 2021-08-20 18:01:42 +0000 | |
---|---|---|
committer | 2021-08-20 11:01:42 -0700 | |
commit | 1e0e2f41cd5fa146917afada10cc894e80fd3787 (patch) | |
tree | e176af996361d382ca9944f877ea85d3b814e35a | |
parent | aaef6aefefeaf4b6b01bf826a08ab2b71ea6d85c (diff) | |
download | astro-1e0e2f41cd5fa146917afada10cc894e80fd3787.tar.gz astro-1e0e2f41cd5fa146917afada10cc894e80fd3787.tar.zst astro-1e0e2f41cd5fa146917afada10cc894e80fd3787.zip |
including the `language-` class on Prism's `<pre>` element (#1180)
* including the `language-` class on Prism's `<pre>` element
* adding changeset
Co-authored-by: Tony Sullivan <tony.f.sullivan@gmail.com>
-rw-r--r-- | .changeset/great-poets-pull.md | 5 | ||||
-rw-r--r-- | packages/astro/components/Prism.astro | 2 | ||||
-rw-r--r-- | packages/astro/test/astro-markdown.test.js | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/great-poets-pull.md b/.changeset/great-poets-pull.md new file mode 100644 index 000000000..5915b676a --- /dev/null +++ b/.changeset/great-poets-pull.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Including Prism's `language-` class on code block `<pre>` tags diff --git a/packages/astro/components/Prism.astro b/packages/astro/components/Prism.astro index b96f4c358..6aaffbe74 100644 --- a/packages/astro/components/Prism.astro +++ b/packages/astro/components/Prism.astro @@ -42,4 +42,4 @@ if (grammar) { --- -<pre class={className}><code class={classLanguage}>{html}</code></pre> +<pre class={[className, classLanguage].join(' ')}><code class={classLanguage}>{html}</code></pre> diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index baf39fb3e..b0a1dba4d 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -41,6 +41,7 @@ Markdown('Scoped styles should not break syntax highlight', async ({ runtime }) const $ = doc(result.contents); assert.ok($('pre').is('[class]'), 'Pre tag has scopedStyle class passed down'); + assert.ok($('pre').hasClass('language-js'), 'Pre tag has correct language'); assert.ok($('code').hasClass('language-js'), 'Code tag has correct language'); assert.ok($('code span').length > 0, 'There are child spans in code blocks'); }); |