Properly handle <!--break--> HTML comment

Created on 18 June 2023, about 2 years ago

This issue has been spun off from 🐛 Truncate must not count HTML comments Fixed .

How should we handle HTML <!--break-->?

  1. Should we treat this as an HTML comment and not count it?
  2. If Smart Trim sees this, should it automatically return the text before it as the trimmed text (and ignore the formatter configuration)?

With option 2, we would be treating <!--break--> as a "golden ticket" and allow it to dictate what is returned by the formatter.

With option 1, we would be ignoring any possible intent by authors to "hard code" the summary into the body field by manually inserting a <!--break-->.

I am leaning towards option 1 as <!--break--> is kind of out-dated (IMHO).

Thoughts?

-mike

📌 Task
Status

Active

Version

2.1

Component

Code

Created by

🇺🇸United States ultimike Florida, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ultimike
  • 🇺🇸United States markie Albuquerque, NM

    I am leaning towards #1 as well. Should be documented though.

  • 🇮🇪Ireland lostcarpark

    Just looking at the CKEditor options, and there doesn't seem to be an option to insert a <!--break-->, at least in the default button set. I think the preferred option nowadays is to use the summary field. So option 1 sounds the preferred choice to me.

    Agree it should be documented.

  • Assigned to jofitz
  • 🇬🇧United Kingdom jofitz Coventry

    Option 2 is my preferred choice, especially while core is supporting <!--break-->.

    I doubt it would take much work to create a CKEditor option to insert <!--break--> (but that is beyond the scope of this issue/module).

    MR on its way...

  • 🇬🇧United Kingdom jofitz Coventry
    • Set correct version
    • Created merge requests
    • Added Needs Tests tag
    • Set status to Needs Work
  • Issue was unassigned.
  • Status changed to Needs work 8 days ago
  • 🇺🇸United States loze Los Angeles

    For the record there is a contrib module that allows <!--break--> in ckeditor https://www.drupal.org/project/ckeditor_drupalbreaks

  • 🇺🇸United States loze Los Angeles

    I tried this out and it didnt quite work for me.

    the <!--break--> tag is still ignored when creating the trimmed version.

  • 🇮🇪Ireland lostcarpark

    It would make sense to use <!--break--> to end the text if it comes within the smart trim limit.

    For example, if Smart Trim was set with a limit of 100 characters, and a <!--break--> was present at character 50, then Smart Trim would return up to the <!--break-->.

    However, if the <!--break--> came at character 150, then Smart Trim's normal rules would apply, and only the first 100 characters (adjusted for word breaks) would be returned.

    As an extra module is required to support the <!--break--> with CKEditor, I don't think this is widely used, I wonder should there be a config option added to enable support of <!--break-->? If selected, text would be trimmed at <!--break-->, if it appeared within the trim length. If not enabled, <!--break--> would be treated as a comment.

Production build 0.71.5 2024