S
Stefan Matthias Aust
I'd a problem with Instiki's usage of HTMLDiff. Assume you've these two
strings
X <b>Y</b> Z
X <i>Y</i> Z
Applying HTMLDiff.diff on those strings results in
X
<del class="diffmod"><b></del>
<ins class="diffmod"><i></ins>
Y
<del class="diffmod"></b></del>
<ins class="diffmod"></i></ins>
Z
And I'm pretty sure this isn't valid HTML. At least Mozilla 1.7RC3 can't
render a larger Instiki page with lot's of similar code correctly.
Is there anything I can do about?
I found a workaround by adding these lines to Builder#op_helper:
def op_helper(tagname, tagclass, to_add)
if to_add.size == 1 and to_add.first =~
/^<\/?(b|i|tt|em|strong|code)>$/
@content << to_add.first if tagname == "ins"
to_add = []
end
...
In case that the diff is just an opening or closing tag, drop the old
tag and insert the new tag outside the diff. Some other method will
take care of empty diff tags so they're no problem.
bye
strings
X <b>Y</b> Z
X <i>Y</i> Z
Applying HTMLDiff.diff on those strings results in
X
<del class="diffmod"><b></del>
<ins class="diffmod"><i></ins>
Y
<del class="diffmod"></b></del>
<ins class="diffmod"></i></ins>
Z
And I'm pretty sure this isn't valid HTML. At least Mozilla 1.7RC3 can't
render a larger Instiki page with lot's of similar code correctly.
Is there anything I can do about?
I found a workaround by adding these lines to Builder#op_helper:
def op_helper(tagname, tagclass, to_add)
if to_add.size == 1 and to_add.first =~
/^<\/?(b|i|tt|em|strong|code)>$/
@content << to_add.first if tagname == "ins"
to_add = []
end
...
In case that the diff is just an opening or closing tag, drop the old
tag and insert the new tag outside the diff. Some other method will
take care of empty diff tags so they're no problem.
bye