Problem/Motivation
We have a nice summary with taw HTML since #3008364: Show raw summary when striping tags returns empty
However if there is 150 characters of HTML first, it switches to raw HTML display instead of trying to extract text after stripping first.
Proposed resolution
Run strip HTML on the full body and cutoff afterwards.
Only show raw HTML if still nothing.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff-3011151-9-11.txt | 752 bytes | johnchque |
| #11 | extract_text_long_html-3011151-11.patch | 2.97 KB | johnchque |
| #9 | interdiff-3011151-5-9.txt | 407 bytes | johnchque |
| #9 | extract_text_long_html-3011151-9.patch | 3.04 KB | johnchque |
| #6 | interdiff-3011151-2-5.txt | 619 bytes | johnchque |
Comments
Comment #2
johnchqueThis should make the magic, adding tests. :)
Comment #3
miro_dietikerIf this creates an encoded entity like & after 148 characters then it would be cutoff and display wrongly.
I think we should apply htmlspecialchars after truncation.
But yeah you're right, the raw summary isn't truncated at all currently...
I think we should truncate right after this line for the first time.
Comment #5
johnchqueShould be better now. :)
Comment #6
johnchqueI forgot the interdiff.
Comment #8
miro_dietikerWe should truncate this too, otherwise it could be a huge BLOB of HTML Script or so.
Comment #9
johnchqueTest not changing, thus previous test only patch still applies. :)
Comment #10
berdirThere is no need to do a separate strlen() check ourself for > 150, Unicode:: truncate() does that too as basically the very first thing.
So I think you can just integrate that into the existing lines: Unicode::truncate(trim(strip_tags($text))) and then the same for the html version.
Comment #11
johnchqueMore magic. :) Thanks @Berdir!
Comment #12
berdirThanks.
Comment #14
miro_dietikerAwesome. Committed. :-)