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.

CommentFileSizeAuthor
#2 3061737-2.patch1.82 KBbenjifisher

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

StatusFileSize
new1.82 KB

The attached patch provides a new process plugin, dom_remove. It does what the issue title says: it removes HTML elements (or the related DOMDocument nodes). This is different from the example in the issue description, where just the tags are removed.

I am providing the patch here for convenience. The active discussion is on the related DrupalSpoons issue.

heddn’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

leonardpg’s picture

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.

szeidler’s picture

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