"Filtered HTML" text format does not support manual teaser break (<!--break-->)

Created on 2 December 2018, over 6 years ago
Updated 17 February 2023, about 2 years ago

Placing the following line inside a story node's body (I guess it also works for other content types) adds a manual teaser break:

<!--break-->

This works fine when the story uses the "Full HTML" text format. It stops working, however, when I switch the story's text format to "Filtered HTML". I expect manual teaser breaks to work with any text format, if not out of the box then at least by configuring the text format in some way (e.g. by modifying the text format's set of allowed HTML tags).

A similar issue โ†’ already exists for Drupal 7, but In Drupal 7 a workaround exists because it's possible to add <!--> to the "Filtered HTML" text format's set of allowed HTML tags (cf. comment 118 โ†’ of the other issue).

The same workaround does not work for Drupal 8 because in Drupal 8 "Filtered HTML" treats the set of allowed HTML tags as DOM elements (cf. implementation of the function FilterHtml::getHtmlRestrictions()), but the manual teaser break is a HTML comment.

๐Ÿ› Bug report
Status

Needs review

Version

10.1 โœจ

Component
Filterย  โ†’

Last updated 4 days ago

No maintainer
Created by

๐Ÿ‡จ๐Ÿ‡ญSwitzerland herzbube

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States alison

    Rebased; tests are running.

    I wonder if we should update the issue title and description to "Basic HTML" instead of "Filtered HTML", based on what comes with recent versions of Drupal?

    -------
    Meanwhile, I tried to review the changes in DrupalPod, so far, I don't seem to be able to add <!-- break --> to a WYSIWYG-enabled text area and have it be preserved, but I might be testing wrong -- am I meant to create a text format called filtered_html?

    The only config change I tried so far was to add <!-- break --> to editor[settings][plugins][ckeditor5_sourceEditing][allowed_tags], but this change didn't "stick" (when I went back into the basic_html config form, the break tag wasn't there anymore). ANYWAY, I'm probably just not testing right -- maybe worth adding test instructions to the issue summary?

  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Self review.

    Will have to retake a look at this. Title could be updated and something may have to be tweaked as it longer appears to be working. Could use an issue summary update.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland stefanos.petrakis@gmail.com Biel, Switzerland

    Regarding #52: The provided solution is only effective for non-WYSIWYG editing. CKEditor 5 is by default removing any html comments so the reported issue will be caused by the editor and not Drupal's text formats. More on this here =>
    https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support...
    That being said, if you would pick e.g. the RestrictedHTML format when editing which doesn't use an editor, you could test the provided solution.

    In general, even if a solution is presented for CKEditor (e.g. sth similar to https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html), the existing solution will still be necessary to tackle this issue.

    This issue may need to change into a task, e.g. "Support manual summary delimiter breaks", where 2 problems will be addressed:

    1. FilterHTML's support for the delimiter (already has a solution)
    2. CKEditor5's support for the delimiter (as in a CKEditor Plugin that would preserve this html comment). That was also suggested in #40
  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    @alison: It's <!--break-->, not <!-- break -->. I tried both, and only <!--break--> works :)

    I can confirm that the "Full HTML" text format cuts off the text after <!--break-->, both in node display, as well as in a view.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    I wonder if we should update the issue title and description to "Basic HTML" instead of "Filtered HTML", based on what comes with recent versions of Drupal?

    Great idea, I updated to that.

  • For those upgrading from older versions of Drupal, it is also true that it doesn't work for "Filtered HTML" either.

    Is this issue still being worked on? The last update re code is from a year ago, and I do not see any issue regarding the CKE5 issue mentioned in #56.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    Gรกbor Hojtsy โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    I think its fine to fix the backend processing in this issue and solve the CKEditor problem in another issue. I changed the target branch of the MR to 11.x where it should be, but there are conflicts that need resolving. Hope someone can pick that up? :) In general I think the diff looks reasonable BTW.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    BTW https://www.drupal.org/project/ckeditor_drupalbreaks โ†’ is a contributed project that provides a UI to add the break as well as a filter to preserve the break.

  • Assigned to Anita verma
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada phjou Vancouver ๐Ÿ‡จ๐Ÿ‡ฆ ๐Ÿ‡ช๐Ÿ‡บ

    Just discovered that the site I was using had that patch and broke the upgrade when switching to Ckeditor5. AFter removing the patch it was working, but I guess I lose the feature.
    Thanks @Gabor for the suggestion of the module, it already installed on my site, I'll try the new branch.
    Do you know if we need the patch + the module or is the module enough?

  • First commit to issue fork.
  • Merge request !11460Apply changes from MR 3106 โ†’ (Open) created by Harlor
  • Pipeline finished with Failed
    about 1 month ago
    Total: 113s
    #447369
  • Pipeline finished with Failed
    about 1 month ago
    Total: 154s
    #447799
  • Pipeline finished with Failed
    about 1 month ago
    Total: 160s
    #447803
  • Pipeline finished with Failed
    about 1 month ago
    Total: 801s
    #447810
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Harlor Berlin

    I created a new MR based on 11.x with the diff from MR 3106.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Harlor Berlin

    I'm not sure if the test failures have anything todo with the changes in this issue. I hope someone finds time to find this out.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Harlor Berlin

    Ah OK the tests did pass at a rerun now.

    Back to needs review.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Gave a light review but was previously tagged for an issue summary update which will be needed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mradcliffe USA

    I performed Novice Triage on this issue. I am leaving the Novice tag on this issue based on @smustgrave's triage. We should focus on the issue summary update based on recent work and resolving the code review.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mr. libby Boston

    Issue Summary

    I tested the BREAK functionality in Drupal 11 using the latest patch from the 3017548-d11 branch with @jeff chicoine. The expected behavior is that content before BREAK should appear in the teaser view, while the full content should be visible in the full node view. However, my testing indicates that

    <!--break-->

    is not working as expected.

    Steps to Reproduce

    1.) Set up a Drupal 11 environment using DDEV and Composer.

    2.) Checked out the 3017548-d11 branch and pulled the latest changes.

    3.) Created a new content type: Testing Text WYSIWYG.
    Added two fields:
    Basic Formatted w/ Summary (Basic HTML text format)
    Full Formatted w/ Summary (Full HTML text format)
    4.) Configured the Manage Display settings:
    Both fields are set to show in Teaser and Full content display modes.
    Teaser display mode set to "Trimmed or Summary".
    5.) Created new content using this content type.
    Added two paragraphs of text in both fields.
    Inserted BREAK between the paragraphs.
    6.) Viewed the node in both Full content and Teaser view.

    Observed Behavior


    In Full view, both paragraphs appear as expected.
    In Teaser view, the entire content is still displayed instead of stopping at BREAK.
    The behavior is the same for both "Basic HTML" and "Full HTML" fields.

    Expected Behavior


    The Teaser view should display only the text before BREAK, but currently, it does not.

    Possible Causes / Next Steps


    It seems that BREAK is not being processed correctly when rendering teaser content.
    This could be due to text filtering stripping out comments or incorrect processing in the teaser rendering logic.
    Further investigation is needed to confirm where BREAK is being ignored.
    Note: the break tag was written correctly for the test, but when trying to describe it here break was working correctly and ruining my comment. : )
Production build 0.71.5 2024