Skip to content

<br> in CKEditor gets output as </br> in Twig #607

Description

@foxtrotcz

Description

If your text in CKEditor includes line breaks <br> they get outputed as </br> in Twig.

Steps to reproduce

  1. Create CKEditor and input two lines separated as line breaks
Image

The source inside CKEditor should look like this:

Image
  1. Then just output into Twig template.
    First we check {{ dump(entry.ckeditorTranslate) }}
craft\ckeditor\data\FieldData {#3103 ▼
  -content: null
  #rawContent: "<p>first line<br />second line</p>"
  #siteId: 1
  -loadedEntries: false
  -rendered: false
  -field: craft\ckeditor\Field {[#640 ▶](mysite.com#sf-dump-1045772604-ref2640)}
}

Then we output normally {{ entry.ckeditorTranslate }} and check source code of the site.
<p>first line<br />second line</p>

As you can see, it changed into <br />.

This is wrong and then HTML Validator will tell you:
Info: Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.

https://validator.w3.org/nu/

This should be fixed so we can output correct HTML.

Thanks.

Additional info

  • Craft version: Craft Solo 5.10.10
  • PHP version: 8.5.7
  • Database driver & version: MySQL 8.4.9
  • Plugins & versions:
    Asset Rev 8.0.0
    Asset Usage 4.3.0
    Bulk Edit 5.0.0-beta.1
    CKEditor 5.6.1
    Field Manager 4.0.4
    Multi Translator 2.28.3
    Recentchanges 3.0.3
    SEOMate 3.3.1
    Sherlock 5.2.1
    User Audit v2.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions