* (bug 12130) Initial newlines are now preserved correctly during editing
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Sep 2011 22:50:48 +0000 (22:50 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 30 Sep 2011 22:50:48 +0000 (22:50 +0000)
commit969cec9322dcccf369fdb9334e98ec741d7d600e
treebaf719b4a340177d22512888866800e105c910d0
parent0483ca934347c5761eb2a06062377095e6b1ef0b
* (bug 12130) Initial newlines are now preserved correctly during editing

HTML browsers strip the first newline from the literal contents of a <textarea>, but keep any additional newlines beyond that.

Prepending an extra newline in Html::textarea() when the contained text started with a newline makes our output basically look like this:

<textarea>             <-- (this added newline is ignored)
                       <-- (any original newline here is preserved)
blah blah</textarea>

This seems to consistently resolve the stripping of single initial newlines from every edit operation as seen on bug 12130; as noted on comments there <https://bugzilla.wikimedia.org/show_bug.cgi?id=12130#c17> this had deleterious effects on Wikisource, where transcription/proofreading tends to involve breaking up lots of little pages, which may have a significant newline at the start of a page boundary.

Text that didn't have initial newlines won't see any difference in the HTML output.

Followup to test cases in r98576, which confirm that supported browsers consistently have this behavior.
includes/Html.php