33 public $insClass =
' class="diffchange diffchange-inline"';
35 public $delClass =
' class="diffchange diffchange-inline"';
49 private function flushGroup( $new_tag ) {
50 if ( $this->group !==
'' ) {
51 $encGroup = htmlspecialchars( $this->group, ENT_NOQUOTES );
52 if ( $this->tag ==
'ins' ) {
53 $this->line .=
"<ins{$this->insClass}>$encGroup</ins>";
54 } elseif ( $this->tag ==
'del' ) {
55 $this->line .=
"<del{$this->delClass}>$encGroup</del>";
57 $this->line .= $encGroup;
61 $this->tag = $new_tag;
67 private function flushLine( $new_tag ) {
68 $this->flushGroup( $new_tag );
69 if ( $this->line !=
'' ) {
70 $this->lines[] = $this->line;
72 # make empty lines visible by inserting an NBSP
73 $this->lines[] =
"\u{00A0}";
82 public function addWords( $words, $tag =
'' ) {
83 if ( $tag != $this->tag ) {
84 $this->flushGroup( $tag );
87 foreach ( $words as $word ) {
92 if ( $word[0] ==
"\n" ) {
93 $this->flushLine( $tag );
94 $word = substr( $word, 1 );
98 assert( !strstr( $word,
"\n" ) );
99 $this->group .= $word;
107 $this->flushLine(
'~done' );