Problem/Motivation
Comparing revisions using the visual inline diff layout, strips out HTML5 (such as <section> <article> ....etc). These elements are replaced by <div> and <span> tags and as a result the page loses styles.
Proposed resolution
The HTMLPurifier itself is stripping out these elements. Perhaps the diff module could add a feature to allow for HTML5 Definitions for the HTML Purifier. These definitions are available: https://github.com/xemlock/htmlpurifier-html5
For the patch to work or to test, you will need to install https://github.com/xemlock/htmlpurifier-html5
composer require xemlock/htmlpurifier-html5
Issue fork diff-3226910
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adstokoe commentedComment #3
adstokoe commentedFor the patch to work or to test, you will need to install https://github.com/xemlock/htmlpurifier-html5
composer require xemlock/htmlpurifier-html5Comment #4
adstokoe commentedComment #5
adstokoe commentedComment #6
adstokoe commentedComment #7
chandraraj commented@adstokoe,
Thanks for the patch. It works well.
Comment #8
chandraraj commentedHi @phenaproxima/ @miro_dietiker
I've tested the patch. It seems to be working well for HTML5. But we need to install `xemlock/htmlpurifier-html5` package before adding the patch.
So could you please review this work and include the package in composer.json.
Thanks,
Chandra
Comment #9
adstokoe commentedComment #10
chandraraj commentedComment #11
chandraraj commented@alan-d @lhangea @juampynr
Please see https://www.drupal.org/project/diff/issues/3226910#comment-14188898.
So could you please review the work and include the package `xemlock/htmlpurifier-html5` in your composer.json.
Thanks
Comment #12
bkosborneRan into this as well, and the change makes sense to me.
Modified patch to include the composer requirement and remove unnecessary var declaration in constructor.
Comment #13
bkosborneThis one has the var removal I mentioned...
Comment #14
bkosborneNote that even though the patch includes the update to composer.json to bring in the new package, if you use this patch via composer patches, it will not bring in that dependency. I think it's just how composer works. You cannot bring in a patch that adds further composer deps. So you still need to explicitly add the new package to your own composer.json until this is committed.
Comment #15
bkosborneComment #16
druplr commentedPatch #15 works for me. Thanks!
Comment #17
steinmb commentedComment #18
saltwaterskin commentedRe-roll for 1.1
Comment #19
luke.leberAlternatively, the latest version of
caxy/php-htmldiffnow allows to completely turn off HTMLPurifier. Perhaps we can simply add a toggle to turn it off entirely? Drupal has its own filtering chain -- I don't see an overly compelling reason to add another one on the end of it.Comment #20
luke.leberAttaching demo patch.
Comment #21
luke.leberTo work around this and other issues, I've spun up https://drupal.org/project/diff_plus with a resolution for HTML5 elements as well as some other opinionated additions if any issue watchers would like to give it a try.
Comment #22
adriancidreroll
Comment #23
acbramley commentedThis needs to go into an MR with tests.
Comment #24
sandipta commentedAlong with the above mentioned things, couple of things are still getting removed
To name a few :
1. Style Attribute
2. ID's associated with Section
3. button tag
4. Attributes like aria-label, data-title, data-lity, data-toggle, aria-expanded
5. nbsp
6. iframe tag
7. Custom Data Attributes
8. Form Tag
Comment #25
tunicI've tried patch from #23 and but see no improvement, the content is displayed totally broken (CSS issues). Not sure if this is because the use of layout builder, paragraphs or what. Using Drupal 10.4.4.
Comment #27
matthijsDisabling the purifier as suggested in #19 seems the right way to go for me. Opened an MR for it.
Comment #29
acbramley commentedthe MR is failing linting and still needs tests
Comment #30
mmenavas commentedReroll of #22 for 8.x-1.10.