User:Catrope/Unwrap

From MediaWiki.org
Jump to: navigation, search

The conceptually correct way[edit]

Initial state:

<list> <item> <par> Foo </par> </item> <item> <par> Bar </par> </item> <item> <par> Baz </par> </item> </list>

First split:

<list> <item> <par> Foo </par> </item> </list> <list> <item> <par> Bar </par> </item> <item> <par> Baz </par> </item> </list>

Second split:

<list> <item> <par> Foo </par> </item> </list> <list> <item> <par> Bar </par> </item> </list> <list> <item> <par> Baz </par> </item> </list>

Unwrapping (note that the removed item tags precede the previously inserted list tags, so the transaction processor's cursor would have to move backwards)

<list> <item> <par> Foo </par> </item> </list> <list> <item> <par> Bar </par> </item> </list> <list> <item> <par> Baz </par> </item> </list>

Final state:

<list> <item> <par> Foo </par> </item> </list> <par> Bar </par> <list> <item> <par> Baz </par> </item> </list>

The condensed way, and why it probably won't work[edit]

Combined diff of all the changes above:

<list> <item> <par> Foo </par> </item> </list> <list> <item> <par> Bar </par> </item> </list> <list> <item> <par> Baz </par> </item> </list>

Reduced/condensed diff (dropping the list tags that are added and immediately removed again):

<list> <item> <par> Foo </par> </item> </list> <item> <par> Bar </par> </item> <list> <item> <par> Baz </par> </item> </list>

However, the intermediate state would look like this:

<list> <item> <par> Foo </par> </item> </list> <item> <par> Bar </par> </item> <list> <item> <par> Baz </par> </item> </list>

which is invalid, because the second list item is not the child of a list. Most likely, the prepare functions will refuse to construct such a transaction, and the transaction processor will refuse to execute it (and those are good things). Hacking around that for this special case is probably hard and probably a bad idea.