Trailing newline rendered as a <br /> tag in the last paragraph due to inserted <span>
The trailing <span class="__iawmlf-post-loop-links"> element introduced in PR #338 causes WordPress to render a trailing newline as a <br /> tag in the last paragraph. This behavior differs from when Link Fixer is not active.
I don’t know if the block editor is affected, since I don’t use it, but the issue is present when using the Classic Editor, and even there you have to use the Code view (because Visual view either converts the trailing newline into a line with an , or strips the trailing newline when switching to Code view).
My guess is that this is wpautop trying to be smart about the content, seeing the trailing <span> from Link Fixer, and thinking it’s visible content, so the trailing newline in the actual content (as entered in the editor) should be rendered as a visible <br /> too.
This is probably a very niche issue, and I’m sure I can figure out a way to work around it, but I wanted to document it anyway.
Steps to reproduce
- deactivate Link Fixer
- use Classic Editor’s Code view to create a post
- end the final paragraph with a newline
previewpublish the post and inspect the last paragraph: there is no newline before the closing</p>tag- activate Link Fixer
- create another post with the same contents
previewpublish the post and inspect the last paragraph
What you expected to happen
the <span> to immediately follow the last word and immediately precede the closing </p> tag, with no newline before or after
What actually happened
the <span> is separated from the last word with a <br /> tag followed by a plain newline