Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#8123 closed (wontfix)

Spaceless tag should pay attention to specific tags

Reported by: julianb Owned by: julianb
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Currently, the spaceless tag erases all whitespace between HTML tags.

That gets you in trouble, because whitespace between some specific tags carries semantic meaning.

Example:

<div>
<h1>Hello</h1>
<p>That is an <strong>important</strong> <a href="">question</a>  </p> <p> <em>Bla</em> bla</p>
</div>

Currently produces:

<div><h1>Hello</h1><p>That is an <strong>important</strong><a href="">question</a></p><p><em>Bla</em> bla</p></div>

and gets you "...importantquestion..." when it really should be:

<div><h1>Hello</h1><p>That is an <strong>important</strong> <a href="">question</a></p><p><em>Bla</em> bla</p></div>

The difference here is that whitespace between strong and a would be preserved, but it still deletes space between p and em for example.

Attachments (1)

utils-spaceless.diff (658 bytes) - added by julianb 7 years ago.
First patch proposal

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by julianb

First patch proposal

comment:1 follow-up: Changed 7 years ago by mattmcc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

I'm betting there are more tags that this is an issue for than just strong, a, and em..

comment:2 in reply to: ↑ 1 Changed 7 years ago by julianb

  • Status changed from new to assigned

Replying to mattmcc:

I'm betting there are more tags that this is an issue for than just strong, a, and em..

Sure, should I update the patch with all HTML inline elements and other stuff I can think of? I thought I better get some feedback first, if the regex is okay and not ineffective, before stuffing dozens of tags in there.

comment:3 Changed 7 years ago by mtredinnick

  • milestone changed from 1.0 to 1.0 maybe
  • Triage Stage changed from Accepted to Design decision needed

-1 from me, but I'll get another opinion before nuking this. I think this is a case of "don't do that". If it's not going to be safe to remove spaces like that, then don't use the spaceless tag. It's primarily a costmetic thing, after all.

comment:4 follow-up: Changed 7 years ago by julien

Maybe a trade-off would be to remove all but one space character, for those tags. It's only the first space character that carries meaning, all the others can be stripped out.

comment:5 in reply to: ↑ 4 Changed 7 years ago by julianb

Replying to julien:

Maybe a trade-off would be to remove all but one space character, for those tags. It's only the first space character that carries meaning, all the others can be stripped out.

That is what the patch does at the moment.

comment:6 Changed 7 years ago by jacob

  • Resolution set to wontfix
  • Status changed from assigned to closed

Since Malcolm's already given his -1 and I agree with him, I'm marking this wontfix.

comment:7 Changed 7 years ago by anonymous

  • milestone 1.0 maybe deleted

Milestone 1.0 maybe deleted

Note: See TracTickets for help on using tickets.
Back to Top