diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 03:59:34 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 03:59:34 +0200 |
| commit | fd98a2d3053279bd4a848faa52a3ac676db10cbb (patch) | |
| tree | 8a2aa2a16380d779fe0f8a51dcab917edff636b8 /test/models | |
| parent | d18e0fa70de9b5029ebed93a1760aea46e8abf19 (diff) | |
Stop diff output from corrupting the document on structural tag changes
sdiff aligned an inserted paragraph break correctly, but the renderer
wrapped the raw </p>/<p> tokens in <ins> regardless -- invalid nesting
that browsers silently repair by dropping the unmatched closing tag,
leaving everything downstream rendered inside an <ins> with nothing
left to close it. Same failure mode as the retired cacycle_diff.js,
different cause.
Tag tokens now render as a plain-text pilcrow with a tooltip naming
the actual tag, never as literal markup inside <ins>/<del>. Applies to
both inline and side-by-side. Side-by-side's new panel flattening a
real paragraph break into a marker, rather than showing its own true
structure, is a known, accepted trade-off for now -- not the same
problem, and not fixed here.
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/page_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/models/page_test.rb b/test/models/page_test.rb index ac5691a..3868a53 100644 --- a/test/models/page_test.rb +++ b/test/models/page_test.rb | |||
| @@ -210,4 +210,22 @@ class PageTest < ActiveSupport::TestCase | |||
| 210 | assert_match "<del>Old</del>", old_html | 210 | assert_match "<del>Old</del>", old_html |
| 211 | assert_match "<ins>New</ins>", new_html | 211 | assert_match "<ins>New</ins>", new_html |
| 212 | end | 212 | end |
| 213 | |||
| 214 | test "diff_against handles an inserted paragraph split without corrupting the document" do | ||
| 215 | n = Node.root.children.create! :slug => "paragraph_split_test" | ||
| 216 | d = n.find_or_create_draft @user1 | ||
| 217 | d.body = "<p>Der Vortragsraum ist ab 19 Uhr geöffnet, der Zugang erfolgt über den Hinterhof.</p>" | ||
| 218 | d.save! | ||
| 219 | n.publish_draft! | ||
| 220 | |||
| 221 | d2 = n.find_or_create_draft @user1 | ||
| 222 | d2.body = "<p>Der Vortragsraum ist ab 19 Uhr geöffnet,</p>\n<p>der Zugang erfolgt über den Hinterhof.</p>" | ||
| 223 | d2.save! | ||
| 224 | |||
| 225 | diff = d2.diff_against(n.head) | ||
| 226 | fragment = Nokogiri::HTML::DocumentFragment.parse(diff[:body]) | ||
| 227 | |||
| 228 | assert_equal 2, fragment.css('ins.diff_structural').length | ||
| 229 | assert_match "der Zugang erfolgt über den Hinterhof.", fragment.text | ||
| 230 | end | ||
| 213 | end | 231 | end |
