Skip to content

Widow protection doesn't work correctly and doesn't handle links. #167

@uandco

Description

@uandco

Describe the bug

Widow protection doesn't work correctly and doesn't handle links.

To reproduce

Create content with various word lengths at the end of paragraphs, and links with 2 words at the end of a paragraph.
Set dewidow settings to:

    // enables widow handling
    "set_dewidow" => true,

    // establishes maximum length of a widows that will be protected
    "set_max_dewidow_length" => 10,

    // establishes the maximum number of words considered for dewidowing.
    "set_dewidow_word_number" => 1,

    // establishes maximum length of pulled text to keep widows company
    "set_max_dewidow_pull" => 10,

Only a few paragraphs will be dewidowed correctly

Expected behaviour

Widow protection should be consistent and work in links too.

Screenshots

Original content:

<p>Return the bottom portion of your invoice with a cheque to:</p>
<p>Cheques should be made payable to Urban Utilities.</p>
<p>Testing dewidow thingy with a <a href="https://saslab.docker.amazee.io/services-we-offer#entry:14@1:url">short link</a></p>

Output:

<p>Return the bottom portion of your invoice with a&nbsp;cheque to:</p>
<p>Cheques should be made payable to Urban&nbsp;Utilities.</p>
<p>Testing dewidow thingy with a&nbsp;<a href="https://saslab.docker.amazee.io/services-we-offer">short link</a></p>

As you can see only the second paragraph is correct

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions