HTML Strip for Diff, WYSIWYG Friendly
| Project: | Diff |
| Version: | 6.x-2.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
In looking for a way to make DIFF and a WYSIWYG editor play nice, I came across this thread to which I was unsure what had ever happened... http://drupal.org/node/125494
I found several errors in the patch code for modifying DIFF to strip HTML and work with WYSIWYG editors. I have created a fixed version of /diff/node.inc that works on my 5.x system to make WYSIWYG and DIFF play nice.
This is a critical component for us and I hope it helps someone. I'm not competent with patches so I'll upload the whole file.
Hope this helps someone, if not please help direct me into why I wasn't able to get it to work without modifying the code (someone said the changes we're rolled in, but I don't see this to be the case).
Sorry if I seem a little lost, this is my first attempt at contributing.
| Attachment | Size |
|---|---|
| node.inc_.zip | 1.44 KB |

#1
Thanks for posting this. I took your code and made a few changes for Drupal 6. I'm attaching a patch for Diff 6.x-2.0.
#2
Sorry, my patch didn't seem to attach. Here we go again.
#3
#4
#5
I liked that patch, it's working well as I could notice until now. If I find some problem, I'll tell.
#6
I'm using the patch too and it's working well.
One point someone could improve:
All entities like "Umlaut" ü %ouml; are note replaced with ü ä and so one.
If someone has an easy idea how to replace them, please post it here.
#7
subscribe
#8
I made a generic patch using html_entity_decode() and it seems to be working ok. It was not tested deeply enough to make sure it is. That way all possible HTML entities will be decoded including the one suggested. I tested with portuguese accentuation marks because is my mother language and it decoded everything right. Using this PHP function requires PHP 4 >= 4.3.0 and above. An observation, patch the original node.inc without any other patch otherwise this patch will fail to be applied.
#9
The patch applied cleanly. However, I found that when I look at multiple revisions to a node, the diff only strips HTML for the older ones.
To reproduce:
1. Make multiple revisions to a node (with revision moderation and FCKeditor turned on)
2. View revisions showing a diff between the current version and the oldest version
#10
I don't use revision moderation module that's why I didn't see that. I don't know if I'll fix it for use with revision moderation. I don't understand Drupal in it's inner parts, don't know anything about module integration and interaction. I simply saw your code, understood how you were doing the substitution and changed it.
#11
I did the patch to decode the HTML entities not to strip HTML tags. The entities it's decoding are those like   ã and all of the others.
#12
I applied this patch, adn nothing changed on my site, all the HTML is still there...I also emptied cache, so I think this patch does not work under all circumstances....
I use diff latest dev version..
This is what I get in the terminal window :
imac-de-alexis-dufresne:temp alexis$ patch < Diff_HTMLtags_juliakm_021909_2.patch
patching file node.inc
Seem like patch is applied, but is there any way to actually make sure I'm using a patched file?
thanks,
Patchak
#13
Use patch that is on post #8 instead, I know it works because it's the one I use on my site. But please patch the original node.inc that comes with the module without any other patch.
#14
I used the patch in post #8 and it worked splendidly. Thanks to the person who did it and we hope it becomes part of the module. We did not test on previously created nodes because we are using this module and patch with all new installations.
Thanks again.
geoff
#15
sub
#16
Perhaps this needs to be an option, or tied to whether or not a WYSIWYG editor is in place? I can imagine stripping tags from DIFF would be a real headache for anyone writing page body code by hand.
#17
So is anyone still following this? I'm wondering what the next steps are.
Probably either to:
Add an option for stripping tags in Diff
or
Make it do so gracefully, not showing extraneous tags, but somehow showing markup that DID change....
#18
Why can't the HTML be rendered in the Diff and CSS be used to highlight differences? I feel this would be the most intuitive way to handle WYSIWYG.
For instance, if someone changes the heading size from
<h2>to<h6>a div can be placed around the change and used to highlight the difference.Like this:
<div class="diff-delete"><h2>My Content Title</h2></div>
<div class="diff-add"><h6>My Content Title</h6></div>
The code above would be rendered like normal html and the .diff-delete and the .diff-add will be highlighted red and green using CSS.
Additionally, a button could be added to switch between this new, rendered diff and the classic, code diff.
#19
This is a perfectly reasonable option, and probably preferable to either no html or plain html for a lot of people (but not everyone). The use case that originally brought me to this is end users communicating to each other collaborating via posts with a WYSIWYG editor. For these people, even seeing the HTML makes them think they broke something.
So I can envision a couple different options that would cover the bases of almost everyone....
1) Classic Code Diff
2) Highlighted (or lowlighted) Tag Diff
3) Tags only show when changed Diff, highlighted
4) No tags in Diff, text only
And really one of these might be redundant.
#20
Just tested the patch and it works great.
I think this should be the default option for Diff, but once your viewing the Diff there could be a button "Show HTML" which could toggle the HTML on and off by using jQuery. This would mean each html tag would need to be wrapped in a div with a class that jQuery could target.
#21
One side issue, by the way, which we've worked around.... The Diff module in either form -- stripped of html or not -- renders the font color and style functions in FCKeditor inoperable. Esssentially the Diff module CSS needs overrule the FCKeditor settings with respect to color of font and background font colors.....
geoff
#22
I was the author of the patch on #8. I used the original patch posted here but was not decoding the entities and I simply added the decode instruction. But I really stopped following here now I'm back. I think it could be an option if there is somebody documenting real HTML code using Drupal Diff module to make version control of it.
#23
Subscribing...
#24
subscribe