|
Cookbook /
InlineDiffSummary: Shows the difference between 2 versions by highlighting the changes in markup on word level.
Version: 2008-01-17
Prerequisites: PmWiki 2.2
Status: stable
Maintainer: Anno
Categories: Administration, Editing
DescriptionPmWiki's built in function for page history currently shows a comparison between each 2 lines of 2 versions, but without any highlighting. If the lines are long and the changes small, it is sometimes very difficult to see what actually changed. This recipe integrates the http://pear.php.net/package/Text_Diff package into the PmWiki original function to provide the highlighting so one can immediately spot the differences. You have to press "Show changes to markup" on the history page, to see the highlighting. Example of markup highlighting: ![]() Installation1. Extract the contents of the pagerevinline1.2.zipΔ file to the cookbook/ folder, preserving the directory structure: cookbook/pagerevinline/pagerevinline.php
/Text/Diff.php
/Diff/Renderer.php
/Renderer/inline.php
/Engine/native.php
2. Add this to your local/config.php file: if ($action=='diff')
include_once("If you would like to default to the markup view in the page history, add these lines instead: if(!isset($_REQUEST['source'])) $DiffShow['source'] ='y';
if ($action=='diff')
include_once("(This exact sequence is important in order for the "Show changes to markup/preview" links to work properly.) Release Notes
Comments2007-09-17, Maddes: Also then I get some assert errors in native.php on line 202. Is it possible to extend the cookbook also for the output changes? Great recipe, thanks a lot! :-) --Henning May 16, 2007, at 10:33 AM After recognizing the importance of the correct sequence of includes, I have tried to point it out in the recipe documentation here. I hope that will help others to avoid the mistake I made. --Henning June 04, 2007, at 11:11 AM This is a very nice recipe! I did a small change in the beginning, the CSS definitions of the SDV(Thanks! --Petko August 19, 2007, at 04:28 PM Excellent recipe, thanks! I've made a small adjustment on my site to it, as the ## begin edit by Eemeli, was:
## $nextpos = strcspn(substr($string, $pos + $spaces), " \n");
$s = substr($string, $pos + $spaces);
$nextpos = strspn($s, "!@#$%^&*()=+[]{}'\\:|");
if ( $nextpos == 0 ) $nextpos = strcspn($s, " \n!@#$%^&*()=+[]{}'\\:|");
## end edit
Which should let InlineDiff see blocks of markup as separate words instead of as part of whatever word they're next to. --EemeliAro January 16, 2008, at 06:20 PM April 7, 2008 - Very good script with nice output! I made two changes on my installation: Deleted lines Deleted lines are displayed without the <del> tags. I've edited lines 108-110 of pagerevinline.php to inclde the tags: echo "<div class='diffmarkup'><del>",
str_replace("\n","<br />",htmlspecialchars(join("\n",$in))),
"</del></div>";
Hide "changed from" Since the "Changed to" block also contains the "from" information, I could not see any point of displaying the old text as well. So before including pagerevinline.php in config.php, I added: if ($DiffShow['source'] == 'y' || $_REQUEST['source'] == 'y') {
SDV($DiffDelFmt['c'],"<div style='display:none;'>");
SDV($DiffAddFmt['c'],"</div>
<div class='difftype'>\$[Changed line \$DiffLines:]</div>
<div class='diffchange'>");
}
This will hide the "Changed lines ..." block. Jantah See AlsoContributors |