New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sanitizer truncate - some parameter are ignored #1015
Comments
I came across this recently as well. As a workaround, this works:
|
Thanks @Klenkes I've pushed a fix for this issue, though the issue is not that "some parameter ignored" because 'underlineHeadlines' is not a documented option/param for the truncate() method. The problem was instead that it wasn't properly applying (by disabling) that option when having the markupToText() strip markup. I have updated it so that it is now properly disabling options that shouldn't appear in truncate/collapse calls. Regarding the ellipsis appearing between headlines or headline + other text: that is the correct behavior. It can however be adjusted with the 'collapseLinesWith' option. Though that's an option I would not recommend disabling unless you have some other kind of punctuation accommodating it. Otherwise it can result in creating sentences that aren't meant to be merged, creating unusual, awkward, gibberish or humorous combinations that appear as full sentences but aren't in the source markup. |
|
Seems to work fine now. |
Short description of the issue
Using $sanitizer->truncate like this:
wire('sanitizer')->truncate($item->body, $maxLength=200);
wire('sanitizer')->truncate($item->body, 200, array('underlineHeadlines' => false));
Expected behavior
In PW 3.0.123 the result was pure text with no HTML tags and no linebreaks, ready to be used for example in a search results page
Actual behavior
underlineHeadlines is used(true), so that every headline is followed by ===(h2) or ---(h3)
It used to work correctly in PW 3.0.123 but not anymore in 3.0.143
Related forum post with more description and screenshots(by me)
https://processwire.com/talk/topic/22491-sanitizer-truncate-inserts-as-breaks/
older post:
https://processwire.com/talk/topic/22190-truncate-leads-to-crazy-link-leftovers/
Could be on to the source of the problem:
https://processwire.com/talk/topic/22491-sanitizer-truncate-inserts-as-breaks/?do=findComment&comment=192949
Versions
PW 3.0.123 = okay
PW 3.0.143 = not okay
PHP 5.6 up to 7.2
The text was updated successfully, but these errors were encountered: