Readthedocs.org: Cleanup whitespace in html templates

Created on 21 Dec 2017  ·  16Comments  ·  Source: readthedocs/readthedocs.org

Most of the files in https://github.com/rtfd/readthedocs.org/tree/master/readthedocs/templates have a lot of whitespaces this should be cleaned up.

See http://jinja.pocoo.org/docs/2.10/templates/#whitespace-control

Accepted Improvement

Most helpful comment

I think I misunderstood the solution here. @Blendify said to add - and + to the tags, but that syntax is Jinja and we are using Django templates. So, not sure what's the proposed solution on this one.

I think he is the right person to help you on this one.

All 16 comments

I can easily do this if it is an agreed change. I will likely do this in a couple of files at a time to avoid merge conflicts.

@ericholscher @agjohnson @humitos

I'm 👍 on removing the whitespaces.

To avoid a possible misunderstanding from my side, do you want to add - and + to the blocks to remove other spaces also? I think it's "No" the answer.

I'm using "two whitespaces" as indent in js and html and there many files where my editor complains about. So, I'd love to have all of them standarized to 2, 4 or whatever, but all the same :)

Yes, by adding - and + but some also have an excessive spacing which could be cut down to one line.

I think the issue of different tab sizes/ space count is a separate issue.

Hi @humitos, may I take this up!

I think I misunderstood the solution here. @Blendify said to add - and + to the tags, but that syntax is Jinja and we are using Django templates. So, not sure what's the proposed solution on this one.

I think he is the right person to help you on this one.

Go for it

On Tue, Feb 27, 2018 at 9:23 AM, Nitish Bansal notifications@github.com
wrote:

Hi @humitos https://github.com/humitos, may I take this up!


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
https://github.com/rtfd/readthedocs.org/issues/3434#issuecomment-368893863,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOeua3ltm6D0uVZ2uvkwATO6Hj9ZITCPks5tZA_TgaJpZM4RKR2T
.

--
Aaron Carlisle

Picture taker | Bit cruncher | Pixel pusher | Document writer |
Project administrator for the Blender 3D Documentation Project

Oh, not sure on Django, I will need to see if they use the same format.

On Tue, Feb 27, 2018 at 10:06 AM, Manuel Kaufmann notifications@github.com
wrote:

I think I misunderstood the solution here. @Blendify
https://github.com/blendify said to add - and + to the tags, but that
syntax is Jinja and we are using Django templates. So, not sure what's the
proposed solution on this one.

I think he is the right person to help you on this one.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rtfd/readthedocs.org/issues/3434#issuecomment-368908432,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOeua3FE-bAW7N6jmWwbQ6eKhwzGbsgsks5tZBn7gaJpZM4RKR2T
.

--
Aaron Carlisle

Picture taker | Bit cruncher | Pixel pusher | Document writer |
Project administrator for the Blender 3D Documentation Project

@Blendify I time ago I was looking for something similar, I didn't find it (are some solutions, but is too hacky or change too much the template), that's why I ended putting this in one line https://github.com/rtfd/readthedocs.org/pull/3585/files#diff-5b005b96cd9cbaa4d9fd9549faf0cfabR7

@Blendify @stsewd I searched for this, can we use the spaceless tag or define a custom one like this: https://gist.github.com/jimmydo/842713.
Shall I give this a try?

@bansalnitish this is what the documentation says about spaceless (I tried that tag, but still it didn't help too much)

Only space between tags is removed – not space between tags and text

And I'm not sure about that gist.

Not sure if this is worth focusing on currently. There is a lot of other cleanup that I would prioritize more than cleaning up HTML whitespace :)

I agree, we can close this if needed.

On Wed, Feb 28, 2018 at 12:06 AM, Eric Holscher notifications@github.com
wrote:

Not sure if this is worth focusing on currently. There is a lot of other
cleanup that I would prioritize more than cleaning up HTML whitespace :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rtfd/readthedocs.org/issues/3434#issuecomment-369123035,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOeua6jBFHzGdWIPRA_AfJZMineectFkks5tZN7ogaJpZM4RKR2T
.

--
Aaron Carlisle

Picture taker | Bit cruncher | Pixel pusher | Document writer |
Project administrator for the Blender 3D Documentation Project

Maybe we can leave the issue open so that work can be done later and mark it as a low priority one!

While none of this is really high priority here's a few thoughts:

  • The spaceless template tag (correctly) only removes spaces between tags. This means that spaces in <p> <span>text</span> </p> are stripped but spaces in <span>\n text\n </span> are not. Generally this is easily worked around by wrapping text in a span.
  • For standardizing spacing in templates and JS files (2 vs 4 vs tabs) we should consider something like editorconfig and/or automated tests to ensure it happens.

Putting this on cleanup, but :+1: on keeping this low priority. Cleanup is already a low priority milestone, there are some higher priority cleanup tasks when we get to it.

Just to be clear, the only path forward I see for this is to change to use jinja instead of django templates. And I don't think we are going to do that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamjstewart picture adamjstewart  ·  4Comments

pllim picture pllim  ·  3Comments

davidfischer picture davidfischer  ·  4Comments

PowerKiKi picture PowerKiKi  ·  4Comments

goerz picture goerz  ·  4Comments