Strip leading and trailing whitespace in text

Right now this means things like headings and list items are rendered
nicer (without the whitespace), but also get their whitespace normalized
when saving back. I'll submit code tomorrow that preserves this
whitespace.

Submitting this now because it's needed to make <br>s look reasonable

Change-Id: I4b5e5ad8ee1bbe2f1eaf0fb860dd59f6e401dc3d
This commit is contained in:
Catrope 2012-08-08 16:07:50 -07:00 committed by Trevor Parscal
parent d6d05a40c5
commit c0ea02c0bf

View file

@ -316,9 +316,12 @@ ve.dm.Converter.prototype.getDataFromDom = function ( domElement, annotations, d
if ( !branchIsContent ) {
// If it's bare content, strip leading and trailing newlines
// FIXME these newlines should be turned into placeholders instead
// FIXME these newlines should be preserved somehow
text = text.replace( /^\n+/, '' ).replace( /\n+$/, '' );
}
// Strip leading and trailing whitespace
// TODO store it in the element so it can be preserved
text = text.replace( /^\s+/, '' ).replace( /\s+$/, '' );
if ( text === '' ) {
// Don't produce an empty text node or an empty paragraph
break;