36 public $insClass =
' class="diffchange diffchange-inline"';
38 public $delClass =
' class="diffchange diffchange-inline"';
52 private function flushGroup( $new_tag ) {
53 if ( $this->group !==
'' ) {
54 if ( $this->tag ==
'ins' ) {
55 $this->line .=
"<ins{$this->insClass}>" . htmlspecialchars( $this->group ) .
'</ins>';
56 } elseif ( $this->tag ==
'del' ) {
57 $this->line .=
"<del{$this->delClass}>" . htmlspecialchars( $this->group ) .
'</del>';
59 $this->line .= htmlspecialchars( $this->group );
63 $this->tag = $new_tag;
69 private function flushLine( $new_tag ) {
70 $this->flushGroup( $new_tag );
71 if ( $this->line !=
'' ) {
72 array_push( $this->lines, $this->line );
74 # make empty lines visible by inserting an NBSP
75 array_push( $this->lines,
"\u{00A0}" );
84 public function addWords( $words, $tag =
'' ) {
85 if ( $tag != $this->tag ) {
86 $this->flushGroup( $tag );
89 foreach ( $words as $word ) {
94 if ( $word[0] ==
"\n" ) {
95 $this->flushLine( $tag );
96 $word = substr( $word, 1 );
100 assert( !strstr( $word,
"\n" ) );
101 $this->group .= $word;
109 $this->flushLine(
'~done' );