From: Brion Vibber Date: Fri, 30 Sep 2011 22:50:48 +0000 (+0000) Subject: * (bug 12130) Initial newlines are now preserved correctly during editing X-Git-Tag: 1.31.0-rc.0~27338 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=969cec9322dcccf369fdb9334e98ec741d7d600e;p=lhc%2Fweb%2Fwiklou.git * (bug 12130) Initial newlines are now preserved correctly during editing HTML browsers strip the first newline from the literal contents of a 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 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. --- diff --git a/includes/Html.php b/includes/Html.php index 48cef6f6dd..e778c72ee7 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -685,7 +685,16 @@ class Html { } } - return self::element( 'textarea', $attribs, $value ); + if (substr($value, 0, 1) == "\n") { + // Workaround for bug 12130: browsers eat the initial newline + // assuming that it's just for show, but they do keep the later + // newlines, which we may want to preserve during editing. + // Prepending a single newline + $spacedValue = "\n" . $value; + } else { + $spacedValue = $value; + } + return self::element( 'textarea', $attribs, $spacedValue ); } /**