Advanced Summary Formatter
This module provides a new formatter for text fields with summaries that allows you to trim the text while preserving an configurable allow-list of HTML tags. This prevents HTML from affecting the summary length and allows essential tags for display.
Advanced Summary Formatter implements a new field formatter for text fields with summary that extends core's TextTrimmedFormatter to strip HTML while preserving a configurable allow-list of tags.
Features
Sometimes the content of the node starts with HTML markup, for example, styling the test using inline styles, and then the standard TextTrimmedFormatter trims the text to replace the summary incorrectly, the HTML tags affect the length of the trimmed text. This module allows you to trim only the text that is meaningful for display, but allow some tags that are necessary for the user
Installation
Install and enable Advanced Summary Formatter like any other add-on module. See https://www.drupal.org/docs/extending-drupal/installing-modules
Configuration
After installing and enabling Advanced Summary Formatter, you will see the Advanced Summary Formatter option in the formatting drop-down list for your text fields. For content types, it is located on the Manage Display page. With Advanced Summary Formatter, you have the options to:
* Trim length
* Add an optional suffix after trimming
* Allowed HTML tags
Since Advanced Summary Formatter provides a field formatter, you can use it anywhere field formatters are available.