Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML entities in <style> tags are being encoded #208

Open
d3v1an7 opened this issue Jun 17, 2024 · 0 comments
Open

HTML entities in <style> tags are being encoded #208

d3v1an7 opened this issue Jun 17, 2024 · 0 comments

Comments

@d3v1an7
Copy link

d3v1an7 commented Jun 17, 2024

Hi there! Sorry, I'm not sure if this is for eleventy-plugin-bundle or here!

test.webc

<script webc:setup>
  const cssString = "article > h1 { background: red; }";
</script>
<style webc:keep @text="cssString"></style>
<style webc:keep @raw="cssString"></style>
<style webc:keep @html="cssString"></style>

output

<style>article &amp;gt; h1 { background: red; }</style>
<style>article &gt; h1 { background: red; }</style>
<style>article &gt; h1 { background: red; }</style>

Does not seem to be an issue with other tags:

<div webc:keep @html="cssString"></div>
<div>article > h1 { background: red; }</div>

Workarounds I've found so far:

Add style attribute to body

<html webc:keep :style="cssString"></html>

Tiny transform in 11ty config (for html stuff only)

eleventyConfig.addTransform('fixInlineStyle', async function (content) {
  return this.outputPath.split('.').pop() === 'html' ? content.replace(/&gt;/g, '>') : content;
});

Am using:

"@11ty/eleventy": "3.0.0-alpha.13",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant