redactor
redactor copied to clipboard
Redactor frequently adds line breaks at the end of block elements
Description
If I take any article I've edited with Redactor, I see <br>
tags at the very end of <li>
and <p>
tags, just before the closing tag. This happens in Firefox and Chrome. It happens on all versions of Craft and Redactor I have used in the last 4 years.
This causes various small issues when editing text.
Steps to reproduce
- Edit text for a while
- Look at the source
One reliable way to reproduce this is to have two paragraphs, then positioning the caret at the very beginning of the second paragraph and hitting enter. For some reason, this generates <p><br></p>.
Then, when hitting backspace, it deletes the paragraph, but moves the <br>
tag to the very end of the previous paragraph.
I can reproduce this on Imperavi's website.
I'm sorry to say this is another Redactor core bug and is a bit out of our hands..
This is still a serious annoyance for me. Is there perhaps a way to filter those out through Craft?
I currently fix this with a template filter:
{{
body|replace({
'<br></p>': '</p>',
'<br></li>': '</li>',
})
}}