migcontrol / django-migcontrol

A Wagtail-based Django website for Migration Control
GNU General Public License v3.0
0 stars 5 forks source link

Add whitespace in overview of new article #253

Open teabag12 opened 8 months ago

teabag12 commented 8 months ago

homepage, where new articles are displayed in sliding menu: often there is whitespace missing (see screenshot). Editors can work around this by manually adding whitespace behind article's headers, but that's just a provisional solution. Probably the template just needs to be adjusted!?

Bsp 1
benjaoming commented 8 months ago

Ah yeah, good catch. The issue comes from the template code that generates the excerpt:

https://github.com/migcontrol/django-migcontrol/blob/08cc512387a21315417e691ed48094bf497d9b70/home/templates/home/blocks/carousel_blog.html#L12

Edit: To explain the code above, what happens is that the richtext field is converted to html, then the html tags are stripped, and then finally we truncate the text to be 30 words long. All of this is a bit sloppy and could need adjustment!

The best fix is to figure out what tags that should have spaces inserted after them. I can think of </p> and </li> and </h2>, </h3> etc.

There's an interesting answer to implement this as a custom Django template tag here: https://stackoverflow.com/a/41510640/405682