xowiki::text_diff_in_html (private)

 xowiki::text_diff_in_html doc1 doc2

Defined in packages/xowiki/tcl/xowiki-www-procs.tcl

Simple plain text based diff, used as fallback.

Parameters:
doc1 (required)
doc2 (required)

Partial Call Graph (max 5 caller/called nodes):
%3 xowiki::Page instproc www-diff xowiki::Page instproc www-diff (public) xowiki::text_diff_in_html xowiki::text_diff_in_html xowiki::Page instproc www-diff->xowiki::text_diff_in_html list::longestCommonSubsequence list::longestCommonSubsequence xowiki::text_diff_in_html->list::longestCommonSubsequence

Testcases:
No testcase defined.
Source code:
    set out ""
    set i 0
    set j 0

    regsub -all \n $doc1 " <br>" doc1
    regsub -all \n $doc2 " <br>" doc2
    set lines1 [split $doc1 " "]
    set lines2 [split $doc2 " "]

    foreach { x1 x2 } [list::longestCommonSubsequence $lines1 $lines2] {
      foreach p $x1 q $x2 {
        while { $i < $p } {
          set l [lindex $lines1 $i]
          incr i
          #puts "R\t$i\t\t$l"
          append out "<span class='removed'>$l</span>\n"
        }
        while { $j < $q } {
          set m [lindex $lines2 $j]
          incr j
          #puts "A\t\t$j\t$m"
          append out "<span class='added'>$m</span>\n"
        }
        set l [lindex $lines1 $i]
        incr i; incr j
        #puts "B\t$i\t$j\t$l"
        append out "$l\n"
      }
    }
    while { $i < [llength $lines1] } {
      set l [lindex $lines1 $i]
      incr i
      #puts "$i\t\t$l"
      append out "<span class='removed'>$l</span>\n"
    }
    while { $j < [llength $lines2] } {
      set m [lindex $lines2 $j]
      incr j
      #puts "\t$j\t$m"
      append out "<span class='added'>$m</span>\n"
    }

    return $out
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: