-
Notifications
You must be signed in to change notification settings - Fork 356
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 are replaced with the actual symbols in the compiled css #1219
Comments
The UTF-8 character is semantically identical to the escape as long as the CSS file itself is being parsed as UTF-8, and as long as the |
Hi, I ran into the same problem, here the information: System Info
ReproduceCreate two files:
const nodeSass = require('node-sass');
const result1 = nodeSass.renderSync({file: "./test.scss"});
console.log('node-sass:\n', result1.css.toString());
const sass = require('sass');
const result2 = sass.renderSync({file: './test.scss'});
console.log('sass:\n', result2.css.toString());
.a-icon {
content: "\E91E";
} Then run The problem is the output of node-sass and sass is diffrentent, and I think the node-sass's output is right. Thank you for your time. |
When I view the output with the Hex Fiend tool, I found the different:
Sass converts the escape string ( |
As above, please provide an example of a browser version and web page where this is rendering incorrectly, because according to the CSS spec the two examples you provided have identical semantics. |
Here the little demo, view like the following screenshot. And I found that if I omit the |
If you're deleting the To be clear, we don't choose to emit real Unicode characters capriciously. We do so because it's considerably more compact than generating escapes and (more importantly) because otherwise anyone writing class names, comments, or content strings in non-ASCII-friendly languages would find their compiled stylesheets hopelessly illegible if they were just a bunch of escape codes. If you would prefer escapes, you can always postprocess the CSS with a tool like this one. |
Thank you so much for your reply. Is it better to keep the original content than to always emit Unicode characters? That is to say regardless of people use Unicode characters or the escape, always reserve it in the compiled file. I think the unchanged content is more friendly. It not only can keep Uncode characters in non-ASCII-friendly languages but also can keep the escape for icon-font used. |
Whether a character was written as an escape sequence or as a literal character is a detail of its parsing. There's no efficient way to preserve that information through to the point where that character gets serialized to CSS again. |
Really? Maybe you can introduce a flag about escaped or not of tokens when parsing, then you can use it to determine how to serialize. Another way maybe just to treat escape characters as ASCII characters and let the browser do escape parse. I found scss file: .a-icon {
content: "\E91E";
}
.a-iconb {
content: "你好"
} after compiling with @charset "UTF-8";
.a-icon {
content: "\E91E"; }
.a-iconb {
content: "你好"; } after compiling with @charset "UTF-8";
.a-icon {
content: "";
}
.a-iconb {
content: "你好";
} |
Hi there. I have the same problem
what I need to do to force compiling code correct??? MacBook Before "global" update I used Ruby Sass and all works fine. works next hack:
But it is very very very bad solution. |
I'm closing this as a duplicate of #568, since it looks like there there isn't a case where a browser is actually rendering the UTF-8 character incorrectly. I'll still address some of the outstanding questions here, though.
What do we do about a stylesheet that uses some escapes and some literal Unicode characters? What if we have a situation where a user is (incorrectly) relying on their stylesheet to be emitted as plain-ASCII, but then a dependency uses the word "naïve" in a comment and breaks them? Generally speaking, using heuristics like this just makes the behavior feel even more inconsistent and capricious than having a configurable option.
This would violate Sass's fundamental design principle of being a CSS superset. According to CSS, the token As I explained above, the Unicode character has the exact same semantics in CSS as the escape code. Even though it looks different if you inspect the generated CSS in a text editor, it won't cause the browser to render it any different. (Unless you mess with the If you want a workaround, I'll again recommend using a postprocessor like |
|
@nykoleks Can you check that the output file(CSS file) has |
Neither of these are technically feasible. Tracking the original state of each character in a string would require a considerable amount of memory and processing overhead for every string Sass manages, and trying to decode escapes on-the-fly in every string function would similarly add a massive overhead to those functions (including extremely unintuitive performance characteristics like |
According to your answer, I'm curious why
|
LibSass's string parsing is outdated and incorrect. It doesn't follow CSS semantics and won't behave correctly with string functions or equality. This is part of the reason that LibSass is deprecated. |
I am currently experiencing this issue as well. Even though the unicode character is there, many of the fonts used in my editor don't have that symbol, so I cannot tell what it is any longer. With the code, I could. This is an issue because I'd like to keep a tabulated list of what values are assigned to what class. Without being able to see that in the css, it becomes difficult to diagnose issues or edit code and refactor it within systems after the sass has been compiled. I also have issues actually using the code, because of the limited character set in several of the systems' databases that I use and only have front end or mid end access to. They simply will not accept the outputted code any longer due to the odd characters now emitted by the compiler. To me it's a major drawback for sass/scss to convert the characters to something different than what I intended and seems akin to changing color values like #fff to named colors or not respecting my chosen gender. I'd certainly hate to be given a different gender at birth and not get to go with what I choose. It's the same with writing the representation of a value vs converting it. This is too hands on for a compiler. The default action should be to leave it as is and only convert it when a special marker is in place. So to any of you magical coders out there doing the right thing and fixing issues, the calls of humanity are upon you and we are waiting on our knees for your kindness. |
I am having the same issue when trying to use Font Awesome unicodes in CSS |
@RYJASM I understand you might be frustrated, but let's keep this discussion centered on code. It's inappropriate to equate Sass's string parsing (which correctly follows CSS semantics and avoids bad performance) to the ongoing trauma and prejudice of gender issues. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This issue is getting a bit heated, so I'm going to lock it. Here's the final summary:
|
🐛 bug report
HTML entities are replaced with the actual symbols in the compiled css.
And thus, the symbols show up garbled.
For example: If I comple scss with a pseudo element with html entity like this:
Source SCSS:
Compiled css:
The html entity '\2713' is replaced with the actual symbol '✓' in the complied css,
and then, it's shown like this "e✓" on browsers.
The text was updated successfully, but these errors were encountered: