Comments (5)
I have another case which is a bit annoying. I have the following:
Input:
<span><span>in </span><span class="dynamic"></span></span>
Output:
<span><span>in</span><span class="dynamic"></span></span>
I populate the dynamic span
with javascript on user action, but as there is no html when htmlclean runs, the whitespace after in
is removed.
What would you advice for that use case?
Another info, if I have php code between <?php ... ?>
tags. After the php tag, the indentation is preserved (i.e. if I had the <?php tag indented by 8 tabs, all the compressed html after the php tag is indented with 8 tabs too).
from htmlclean.
Hi @trompx, thank you for the comment.
That seems correct behavior because htmlclean should remove unneeded whitespaces.
Web browsers ignore whitespaces between block elements such as <div>
, and htmlclean removes those correctly.
See: https://github.com/anseki/htmlclean
If you replace the nested <div>
with <span>
, the whitespaces are kept.
And also, your HTML is incorrect (elements are not closed correctly), htmlclean and other programs such as web browsers may not be able to parse those.
See: https://github.com/anseki/htmlclean#malformed-nested-tags-and-close-tags-in-script
htmlclean tries to remove unneeded whitespaces. Therefore, the space is removed correctly if <span class="dynamic">
is empty when the source was given to htmlclean.
Insert something in <span class="dynamic">
like <span class="dynamic">|</span>
to indicate that it is not empty.
from htmlclean.
Hey @anseki,
Thanks for the answer, I would not rather put any character until user input.
My bad I forgot to add the closing div but they are well present in my code.
Looks like I will have to add css margin to overcome this.
from htmlclean.
You can specify protect
option for your special rule.
from htmlclean.
Unfortunately, no reply came, and I close this issue.
from htmlclean.
Related Issues (11)
- Remove commented out code? HOT 1
- Dangerous tampering of attribute value when it contains `>` sign HOT 7
- question(comparison): why htmlclean better, than alternatives? HOT 2
- 'Module not found' error when using in angular app HOT 10
- Add in a param to leave SVGs alone, as compression breaks already optimised SVGs HOT 4
- New lines are not removed {\n} HOT 8
- IE conditional directives from html5 boilerplate cause invalid output HOT 4
- Support the inline SVG HOT 1
- Recreate directory tree HOT 12
- extra space inserted after <div> followed by new line HOT 7
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 htmlclean.