stevebauman / purify

A Laravel wrapper for HTMLPurifier by ezyang
MIT License
447 stars 35 forks source link

HTML5 summary and details tags #82

Closed Aterniad closed 8 months ago

Aterniad commented 11 months ago

Hi! Once input had <summary> and <details> HTML5 tags I immediately got an error: "Element 'details' is not supported (for information on implementing this, see the support forums)"

As your docs say, I've fixed it in the following way:

class Html5Definition extends \Stevebauman\Purify\Definitions\Html5Definition
{
    public static function apply(\HTMLPurifier_HTMLDefinition $definition)
    {
        parent::apply($definition);
        $definition->addElement('summary', 'Block', 'Flow', 'Common', [
            'open' => 'Bool',
        ]);
        $definition->addElement('details', 'Block', 'Flow', 'Common');
    }
}

Specifications: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

Would be rather cool to have this working out of box ;)

stevebauman commented 11 months ago

Thanks for the info @Aterniad! Would you mind pushing a PR and making these additions to the Html5 definition here?

https://github.com/stevebauman/purify/blob/master/src/Definitions/Html5Definition.php

binaryfire commented 10 months ago

These fall under Interactive Elements: https://html.spec.whatwg.org/dev/interactive-elements.html. They include summary, details and dialog, all of which need to be added.

@Aterniad I can make this PR if you don't have time.

stevebauman commented 8 months ago

This has been released in v6.2.0