Is it possible to make manual teaser breaks work with "Filtered HTML"? This question is about Drupal 8.

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

&lt;!--break--&gt;


In Drupal 7, to make manual teaser breaks work with the "Filtered HTML" text format it was necessary to add &lt;!--&gt; to the text format's set of allowed HTML tags (for instance, see this "Drupal Answers" post).

In Drupal 8, however, this solution no longer works: Manual teaser breaks are silently ignored even if &lt;!--&gt; is present in the allowed HTML tags of "Filtered HTML". I have tried to add a couple of plausible seeming combinations to the "Filtered HTML" text format, such as &lt;!--break--&gt; or &lt;!----&gt;, and a couple of implausible combinations (&lt;!--...--&gt; and &lt;!--.*--&gt;), but nothing works.

I double-checked and manual teaser breaks work fine when I switch a story's text format to "Full HTML" text format.

How can I get manual teaser breaks to work again with "Filtered HTML" in Drupal 8? If this is not possible I will have to go through all nodes of my site after the D7 > D8 migration and switch them to "Full HTML".
This comes down to being a problem of DomDocument and its childNodes property that does not include DomComments. Specifically, Drupal\filter\Plugin\Filter\FilterHtml::getHtmlRestrictions() will not consider any comment-like tags that are added in the 'allowed HTML tags' list. This is due to these lines in that function's code:

$html = str_replace('&gt;', ' /&gt;', $this-&gt;settings['allowed_html']);
// Protect any trailing * characters in attribute names, since DomDocument
// strips them as invalid.
$star_protector = '__zqh6vxfbk3cg__';
$html = str_replace('*', $star_protector, $html);
$body_child_nodes = Html::load($html)-&gt;getElementsByTagName('body')-&gt;item(0)-&gt;childNodes;


This loads the text of the 'allowed HTML tags' text as an HTML DomDocument and retrieves the list of the children. Only 'proper' HTML tags will be listed as part of the childNodes property and therefore, the Drupal 7 workaround will not work for Drupal 8.

In order to solve this, one could override the FilterHtml plugin in order to allow &lt;!--break--&gt; to remain in the text.

One attempt following this approach exists here:

https://www.drupal.org/project/drupal8breaks

which was in turn inspired by

https://medium.com/@djphenaproxima/how-to-bend-drupal-8-plugins-to-your-nefarious-will-94da0c31f095

Good luck!

P.S.: Also available on GitHub https://github.com/stefanospetrakis/drupal8breaks