Comments (5)
Thank you for reporting this!
I ran the test you provided (btw, thank you for writing a failing test case!):
failures:
---- do_not_remove_conditional_comments stdout ----
thread 'do_not_remove_conditional_comments' panicked at 'assertion failed: `(left == right)`
left: `"<html><head></head><!--[if mso]>Hello outlook<![endif]--><!--[if !mso]><!--><body><h1>Hello not outlook</h1><!--<![endif]--></body></html>"`,
right: `"<html><head></head><!--[if mso]>Hello outlook<![endif]--><!--[if !mso]><!--><h1>Hello not outlook</h1><!--<![endif]--></html>"`', tests/test_inlining.rs:136:5
So, the only difference here is the "body" tag, the conditional tags in the input example are children of the "html" element and are preserved. However, the body start/end tags are unconditionally added to the tree and it mangles the original tree structure. I assume that the html5ever
crate (which is used under the hood in kuchiki
) considers this case as an invalid tree and add "body" start/end tags to the tree during serialization or during the initial parsing.
I don't remember exactly, but I observed similar behavior in Python's lxml
library and it might come from some part of the HTML spec, e.g. in this example there are no "html" or "body" tags, but the parsing result appears to have them anyway, I'll dig some more into this direction, but my current assumption is that this is the default parser behavior, which is probably described somewhere here
Also, if there is a body tag, then the final output stays the same (please, correct me if it is a valid case at all):
<html>
<head></head>
<body>
<!--[if mso]>Hello outlook<![endif]--><!--[if !mso]><!-->
<h1>Hello not outlook</h1>
<!--<![endif]-->
</body>
</html>
Let me know what do you think :) Is it common to have these comments as children of the "html" element? Or is it more likely to have them inside head / body?
from css-inline.
oops! yes you're right my test was flawed
I was experimenting with swapping out juice with css-inline-wasm and found quite a few sections in the file i was testing with were being removed, I thought the conditional comments were the culprit but you're right that definitely isn't why
I'll see if I can isolate what is causing the issue then :)
from css-inline.
I'd be happy to know if css-inline-wasm
fits your needs and if we can improve it :)
I'll see if I can isolate what is causing the issue then :)
Let me know if I can help you with that somehow :)
from css-inline.
Was pure user error 😅
In part of my attempt to swap out juice with css-inline-wasm, I accidentally removed mjml's default skeleton wrapper (html/head/body stuff)
Since kuchiki (unbeknownst to me at the time) added the necessary html/head/body tags to make the html valid again, I didn't realize that error and mistook this as css-inliner or kuchiki stripping things out
Adding back the default skeleton fixed everything!
Apologies again and thanks as always for your patient guidance 🙇
(also btw it looks like removing the http feature/dependency cuts the wasm file down to 850447 bytes (down from 1491585) which is fairly significant)
from css-inline.
Thank you for the details! :)
Apologies again and thanks as always for your patient guidance
You are very welcome! :)
(also btw it looks like removing the http feature/dependency cuts the wasm file down to 850447 bytes (down from 1491585) which is fairly significant)
I created #66 to track options for size reduction. I am not sure about the performance cost though, we can continue the discussion there - I am keen to know how much performance those tricks will cost and what we can actually tune more
from css-inline.
Related Issues (20)
- Non-blocking stylesheet resolving
- Some Windows 2022 builds are broken HOT 1
- What to use instead of inline_style_tags? HOT 6
- MJS export for npm module HOT 12
- WASM/nodejs throws "Io Error: operation not supported on this platform" if HTML has link to google fonts api HOT 5
- Keep `@media` query CSS for responsive HOT 4
- Styles not extracted correctly in Nuxt > 3.8.0 HOT 5
- Release C bindings HOT 3
- Option to cache resolved stylesheets
- Does take classes in consideration or just depends on selectors of tag types? HOT 1
- Add support for :nth-child selector HOT 5
- Support `data-css-inline="keep"` to enforce keeping the style tag
- WASM Exception Thrown In 0.13.0 HOT 3
- Double quotes in font-family name break generated style attribute HOT 5
- Option to keep raw HTML tags structure HOT 3
- Error: Cannot resolve "./css-inline.android-arm-eabi.node" HOT 3
- Support for `@layer`? HOT 2
- JavaScript WASM broken Since 0.13.0 HOT 3
- Keep npm published versions up to date HOT 3
- Padding, marging has incorrect order while merging with inline HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-inline.