Bug #1437

Styled HTML is Not Shown in Category/Search Product Lists

Added by Pavan Rikhi 11 months ago. Updated 4 months ago.

Status:ClosedStart date:08/08/2019
Priority:NormalDue date:08/08/2019
Assignee:Pavan Rikhi% Done:

100%

Category:ProductsSpent time:-
Target version:v0.7.0 - Misc Pages & UI
Easy Pickings:

Description

The detail route for a product shows any html in the description.

The search/list routes for products don't show this, due to the truncateDescription function, which strips the HTML so it can properly count out the 40 words.

Maybe there's a way to count the words without removing the HTML? Or maybe we should strip the HTML, drop 40 words, then split the original description using the remaining text? That wouldn't work if there's HTML in the remaining text, or might leave opened tags unclosed.

Or maybe this will be solved when we use the short description field of products?

Associated revisions

Revision 052cf42a
Added by Pavan Rikhi 4 months ago

[#1437] Fix Rednering of HTML in Truncated Descriptions

Fix a bug causing the truncated product descriptions from showing HTML
styling. This was caused by the truncateDescription function stripping
out any HTML markup before truncating the text.

To resolve the issue, a new truncateHtml function has been added to the
Models.Utils module. This parses & iterates over the text, preventing
the tags from adding towards the current word count. One the desired
count is reached, any tags that are still open are closed, and the HTML
is rendered back into a Text value.

Closes #1437

History

#1 Updated by Pavan Rikhi 4 months ago

Pavan Rikhi wrote:

Maybe there's a way to count the words without removing the HTML? Or maybe we should strip the HTML, drop 40 words, then split the original description using the remaining text? That wouldn't work if there's HTML in the remaining text, or might leave opened tags unclosed.

I'm thinking of using the tagsoup package to parse the HTML, then keep a stack of opened tags while counting words. When a tag is closed, pop it off the stack. When the word count is reached, close all remaining tags. There may be issues with the non-HTML tags irena has added as trigger words for searches.

#2 Updated by Pavan Rikhi 4 months ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

#3 Updated by Pavan Rikhi 4 months ago

  • Start date set to 08/08/2019
  • Due date set to 08/08/2019

Also available in: Atom PDF