Comments (5)
Yeah this is a tricky one, consider the following: <strong>hello</strong> world
and/or <a href=#>hello</a> world
.
Currently the logic is if inline element and followed by text than remove additional spaces but keep one. The only thing I can think of to fix this is using the original input as reference. If text was originally concatenated then do not add a space, depends on references htmparser2 keeps though. If you have another way of fixing this, I'd like to hear it :)
from minimize.
Could the whitespace reduction not be ran until the (next to) last step? Then the whitespace routine will remove only adjacent whitespaces but still keep one inside block-level elements?
from minimize.
You might be on to something there, hopefully that information still resides in htmparser output somewhere. I'll check asap.
from minimize.
Well, htmlparser2 was updated between versions 3.3.0 and 3.4.0 such that text elements now have next and prev properties. Here's what I came up with: https://github.com/DSKrepps/minimize/commit/75ba00e0c1c43237b1340b3952290ee6dc95d02e
I've changed the behavior so now, instead of trimming all whitespace before adding it in certain cases, it checks for inline elements and collapses whitespace down to a space next to them. The text and tag functions were simplified. A few tests were updated, removed, and added to reflect the new behavior.
As far as I can tell, no changes in whitespace visible in the browser occur with this update, except Hello<a> <i>Erroneous</i> </a>World
comes out as one word. This was present beforehand also.
Hope this helps.
from minimize.
Hello<a> <i>Erroneous</i> </a>World
messes with my OCD anyways, the workaround is easy ofc ;)
from minimize.
Related Issues (20)
- An in-range update of cli-color is breaking the build 🚨 HOT 1
- An in-range update of uuid is breaking the build 🚨 HOT 1
- HTML Attribute Contenteditable Removed By Minimize
- HTML minification eats up spaces between inline elements HOT 3
- Maximum call stack size exceeded HOT 1
- Empty attributes are assigned blank values HOT 4
- This is beyond the scope of this project. NO, IT'S NOT HOT 3
- Django templates error HOT 8
- html tags are autoclosed within a single html file HOT 2
- Keep case HOT 1
- Empty space in attribute HOT 1
- Stripping off extra HTML tags HOT 4
- Minify inline JS - Package link broken? HOT 7
- minifying all HTML files recursively in folder HOT 1
- SSI only supports #includes
- Attribut draggable is no redundant attribute HOT 1
- Feat: remove development code
- Track elements are not considered void elements
- Version 10 of node.js has been released
- An in-range update of htmlparser2 is breaking the build 🚨 HOT 2
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 minimize.