Add a DOM process plugin that removes HTML elements

Created on 14 June 2019, about 5 years ago
Updated 17 February 2023, over 1 year ago

Problem/Motivation

The dom_apply_styles plugin from #3042539: Apply styles configured for CKEditor β†’ can replace an HTML element with another, but it cannot remove an element entirely, leaving just the inner HTML.

For example, we might want to change this

<p>Old <font>markup</font> can have all sorts of <i></i> useless <font>tags</font>!</p>

to this:

<p>Old markup can have all sorts of  useless tags!</p>

Proposed resolution

Either add a new DOM plugin for removing tags, based on an XPath expression, or add options to the dom_apply_styles plugin to achieve the same result.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Fixed

Version

5.0

Component

Plugins

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

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

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States leonardpg

    Was a process plugin ever created to address the use case originally presented about removing just the tags and leaving the inner text? I'm asking here before I go ahead and roll my own. Thanks.

  • πŸ‡©πŸ‡ͺGermany szeidler Berlin

    For stripping the tags there is no additional plugin needed. You can just use the callback plugin like this.

      body/value:
        plugin: callback
        callable: strip_tags
        source: body
    
Production build 0.69.0 2024