-
Notifications
You must be signed in to change notification settings - Fork 68
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
Need some way of not printing whitespace #19
Comments
The main problem is the leading and trailing whitespace. Why is the default to add it? I think the smartest thing to do would be to only add leading/trailing whitespace around block tags. |
I'm embarrassed to not have thought of that. |
I bumped into this with code of the form |
One thing to think about: if we want to be really correct, we'd have to also eliminate whitespace when a div has <span>A</span><span>B</span> <div style="display:inline;">A</div><div style="display:inline;">B</div> But unfortunately it's not possible to catch these cases in general because To take a step back: I think we're adding whitespace is because it makes the HTML more readable. As discussed this issue, we've assumed that adding whitespace has no visible effect for block elements, but it does have a visible effect for inline elements; therefore, it's OK to add whitespace for block elements, but not for inline elements. But we can't tell with 100% reliability whether an element is block vs. inline just based on the tag type, because the I'm not sure if this changes what we'll do, but it's worth keeping in mind. |
FWIW, haml handles this by letting you specify the whitespace behavior. http://haml.info/docs/yardoc/file.REFERENCE.html#whitespace_removal__and_ If we did something like this we could actually leave the default behavior alone, which would be so great from a backwards compatibility perspective. |
There might be a better way of doing this, but I ran into this problem when I tried to use htmlTemplate(text_="var a = \"{{toupper(a)}}\";", a="hello") Output:
In this case the extra whitespace is completely ruining my intended purpose. I realize this diverges somewhat from the intended use of htmlTemplate, but I'd rather not include a separate template package just for this. Adding a parameter to htmlTemplate to disable the added newlines would be great. |
It is now a year since the last activity on this issue. The whitespace on inline HTML tags is still appearing and this makes the |
There is still issue with |
@jcubic Do you mind filing a new issue about that? |
For example:
It would be good to be able to do something like one of the following:
The text was updated successfully, but these errors were encountered: