This has always lingered in the back of my mind, so I figure I might as well go ahead and ask.
How does a wiki handle multiple edits on the same content?
Here\'s
I believe Wikipedia uses a fairly simple diff/merge algorithm, similar to how most source code control software does it.
In the example you gave, it would raise a merge conflict error, because there's no way for it to know which line should come first in the final markup. The second person to save their changes would be presented with a merge error page where they have to choose how to resolve the conflict.
Keep in mind, though, that wikipedia is on the high-end of the concurrent users scale. For the majority of wikis, it would probably be acceptable to use a very simple "last save wins" algorithm, where the second person's edits simply overwrites the first person's. With the addition of history, it should be easy for the first person to spot that their changes have been overwritten and add them back again.
I believe this solution is what Stack Overflow uses. SO has an additional feature where an Ajax call is used to notify the editor if someone else comes in and modifies the page before they're finished.