Summary: Talk page for InlineDiff.
Users: +5 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Does not work with LimitDiffsPerPage2.php for now BlacK? July 11, 2018, at 11:25 AM

2012-10-20, Maddes:
I updated to InlineDiff 2010-02-03 and pmwiki 2.2.43, but the display of this recipe now differs to the old display.

  • Deleted inline diffs are now yellow, before they were red and striked through.
  • Added inline diffs are still green, but before they were also underlined.

How do I have to modify my local config.php to get back the old format?

I think that pagerev.php of pmwiki is the cause of that issue, as it does not use the separate $HTMLStylesFmt['diffinline'] for .diffmarkup del/ins. Maybe a solution must be found in cooperation with the pmwiki authors, e.g. by changing pagerev.php to use $HTMLStylesFmt['diffinline'] for .diffmarkup del/ins. Additionally the recipe should be updated to include ".diffmarkup { font-family:monospace; }" The change in pmwiki was done in r2501 by Petko.

You can override all core CSS styles by redefining them in your file pmwiki/pub/css/local.css (if it doesn't exist, create it). From config.php you should be able to override them by adding them with the "!important" keyword in a $HTMLStylesFmt variable:

  $HTMLStylesFmt['mydiff'] = "
    .diffmarkup del {text-decoration: line-through !important; background-color: #fcc !important;}
    .diffmarkup ins {text-decoration: underline !important; }

(I have enabled these styles for this talk page: InlineDiff-Talk?action=diff.)

I am considering splitting the core .diffmarkup del/ins styles in another $HTMLStylesFmt variable, but there are different things to consider, as this might break some skins. --Petko October 21, 2012, at 12:16 AM

Does this recipe provide any additional features to the PmWiki version 2.2.12 (2010-02-17) built-in word-level difference highlighter? See $EnableDiffInline. If so what are the differences? Or can this recipe be deprecated?

simon August 19, 2010, at 05:53 PM

The display is different, compare the attached screenshotΔ with a core diff. Some users prefer this one. :-) --Petko August 19, 2010, at 06:32 PM

2007-09-17, Maddes:
I do not get inline diffs for the output, only for the markup.
This is the intended behavior. --Anno

Also then I get some assert errors in native.php on line 202.
I'm using PmWiki 2.1.27, is this the reason for these problems?
Probably, this has been developed fro the 2.2 version of PmWiki --Anno

I started to get these as well, and managed to dig up, based on which I fixed this by changing line 202 of pagerevinline/Text/Diff/Engine/native.php to:

assert($y <= $this->seq[$k]);

Eemeli Aro August 06, 2009, at 10:39 AM

Is it possible to extend the cookbook also for the output changes?
This would be difficult to do and I have no plans to do it --Anno
Personal contact via

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 ins and del markups: otherwise elements in the sidebar/header/footer also change bgcolor:

 SDV($HTMLStylesFmt['diffinline'], " 
   .diffmarkup del { background:#fcc; }\n
   .diffmarkup ins { background:#cfc; }\n");

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 Text_Diff_Renderer_inline by default splits words on white space only. This is fine for normal text, but wiki pages tend to often have changes to the markup, which is mostly from a slightly different set of characters. Hence, I've replaced line 142 of Diff/Renderer/inline.php with the following:

## 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 include the tags:

echo "<div class='diffmarkup'><del>",
str_replace("\n","<br />",htmlspecialchars(join("\n",$in))),

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;'>");

      <div class='difftype'>\$[Changed line \$DiffLines:]</div>
      <div class='diffchange'>");

This will hide the "Changed lines ..." block. Jantah

In addition to the above change, you can add the following AFTER including pagerevinline.php to change the delete border color to red and add a yellow border color for changed lines.

$HTMLStylesFmt['diff'] .= ".diffdel { border-left:5px #ff9999 solid; padding-left:5px; }
    .diffchange { border-left:5px #ffff99 solid; padding-left:5px; }";

Modified version

While putting together PageDiffSize I ended up going through the guts of InlineDiff as well, and put together my own modified versionΔ that makes better use of the defaults set by scripts/pagerev.php as well as implementing similar changes as those proposed by Jantah, along with cleaning up the code a bit. To use, download pagerevinline-ea-2009-06-09.phpΔ and include it instead of pagerevinline/pagerevinline.php.

I'm also using the following in my config file to get rid of the superfluous coloured left-hand border and to default to viewing changes to the markup: —Eemeli Aro June 09, 2009, at 06:11 AM

$DiffShow['source'] = (@$_REQUEST['source']!='n') ? 'y' : 'n';
if ($DiffShow['source']=='y') {
	$DiffDelFmt['a'] = "\n<div class='difftype'>\$[Deleted line \$DiffLines:]</div>";
	$DiffAddFmt['d'] = "\n<div class='difftype'>\$[Added line \$DiffLines:]</div>";
	$DiffAddFmt['c'] = "\n<div class='difftype'>$[Changed line \$DiffLines:]</div>";
	$DiffEndDelAddFmt = '';

PHP 5.3 Problems

Using PHP 5.3 results in deprecated warnings:

Deprecated: Assigning the return value of new by reference is deprecated in cookbook/pagerevinline/Text/Diff.php on line 50, 304, 326, 348, 370
Deprecated: Assigning the return value of new by reference is deprecated in cookbook/pagerevinline/Text/Diff/Renderer/inline.php on line 122, 126
Deprecated: Assigning the return value of new by reference is deprecated in cookbook/pagerevinline/Text/Diff/Renderer.php on line 88, 104
Deprecated: Assigning the return value of new by reference is deprecated in cookbook/pagerevinline/Text/Diff/Engine/native.php on line 106, 121, 123, 125

Scott Connard November 08, 2009, at 08:08 PM

I've repackaged Eemeli Aro's cleaned up version of the recipe and a fresh copy of Text_Diff from Horde's CVS (with very small changes to include paths and a method declared static). So try this one pagerevinline1.3pre.zipΔ and report how it works... Could someone please test this with PHP 4? -- Rogutes, 2009-11-11
Sorry for the delay in testing. It works great under PHP 5.3 and 5.2.4, but under PHP 4.4.9 I get the following error on a diff with inline changes (i.e., NOT full line inserts or deletes):
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in 
pmwiki/cookbook/pagerevinline/Text/Diff.php on line 212

Scott Connard November 24, 2009, at 04:12 PM

Comments on css and question

I had to edit the definitions of .del and .ins to include a color tag in it, as my site's color scheme is dark with white letters. Setting color:#000; combined with background:#fcc; will provide good contrast.

I wondered why you set it up to only show the inline diffs in changes to markup?

Many thanks for the recipe - it definitely fills a hole in the diff engine!

Peter Kay December 06, 2009, at 10:44 PM

Talk page for the InlineDiff recipe (users).