Permalink
Browse files

Item13957: Item13958: Fix white space issues in : indents

Empty indent lines were rendered as empty divs, which causes them
to disappear when viewed.  Insert a   into empyty div, so they
result in a blank line.

The Wysiwyg editor eats blank lines that are inserted between two
indented blocks.  The TML2HTML failed to recognize that it was in a
paragraph and should close the paragraph when encountering a blank line.

Note, this causes insertion of a blank line by wysiwyg:

   : Indent
      : Indent2
Un-indented text

ends up with a blank line before the un-indented text. I think that this
is acceptable,  I could not figure out how to prevent it in this case,
while preserving a blank line between two indent items.   NEEDS REVIEW!
  • Loading branch information...
1 parent d1f1d61 commit e09d7302d95c241ef94e8306ddb5d052e160a5b4 @gac410 gac410 committed Mar 19, 2016
@@ -1634,6 +1634,49 @@ ACTUAL
$this->do_test( $expected, $actual );
}
+sub test_lists_empty_items {
+ my $this = shift;
+ my $expected = <<EXPECTED;
+<div class='foswikiIndent'> Para
+</div> <div class='foswikiIndent'> Para
+</div> <div class='foswikiIndent'> &nbsp;
+</div> <div class='foswikiIndent'> Para
+</div>
+<p></p>
+<p></p> <ul>
+<li> Bullet
+</li> <li> Bullet
+</li> <li>
+</li> <li> Bullet
+</li></ul>
+<p></p> <ol>
+<li> Num
+</li> <li> Num
+</li> <li>
+</li> <li> Num
+</li></ol>
+EXPECTED
+ my $actual = <<'ACTUAL';
+ : Para
+ : Para
+ :
+ : Para
+
+
+ * Bullet
+ * Bullet
+ *
+ * Bullet
+
+ 1 Num
+ 1 Num
+ 1
+ 1 Num
+
+ACTUAL
+ $this->do_test( $expected, $actual );
+}
+
sub test_tableDoesNotTerminateList {
my $this = shift;
@@ -711,6 +711,11 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
{
# Indent pseudo-list
+ push( @result, '</p>' ) if $inParagraph;
+ $inParagraph = 0;
+ $line .= '&nbsp;'
+ if ( length($line) eq 28 )
+ ; # empty divs are not rendered, so make it non-empty.
$this->_addListItem( \@result, '', 'div', 'class="foswikiIndent"',
$1 );
$inList = 1;
@@ -686,10 +686,11 @@ HERE
HERE
},
{
- exec => ROUNDTRIP,
+ exec => TML2HTML | ROUNDTRIP,
name => 'indentColon',
html => <<'HERE',
<p>Grim
+</p>
<div class='foswikiIndent'>
Snowy
<div class='foswikiIndent'>
@@ -705,8 +706,8 @@ HERE
<div class='foswikiIndent'>
Sunny
</div>
-<span class=WYSIWYG_HIDDENWHITESPACE style={encoded:'n'}>
-</span>Pleasant
+<p>
+Pleasant
</p>
HERE
tml => <<'HERE',
@@ -718,17 +719,45 @@ Grim
: Sunny
Pleasant
HERE
+
+# SMELL: The closing of the div results in a new paragraph which grows the tml
+# by a blank line. It only happens once, and does not grow further after repeated
+# edits.
finaltml => <<'HERE',
Grim
: Snowy
: Slushy
: Rainy
: Dry
: Sunny
+
Pleasant
HERE
},
{
+ exec => ROUNDTRIP | TML2HTML,
+ name => 'indentColonBlankLine',
+ tml => <<'HERE',
+ : Indente line 1
+ : Indented line 2 next line is blank
+
+ : New indent after blank line
+ : last indent
+HERE
+ html => <<'HERE',
+<p class="foswikiDeleteMe">&nbsp;</p>
+<div class='foswikiIndent'> Indente line 1
+</div>
+<div class='foswikiIndent'> Indented line 2 next line is blank
+</div>
+<p class='WYSIWYG_NBNL'></p>
+<div class='foswikiIndent'> New indent after blank line
+</div>
+<div class='foswikiIndent'> last indent
+</div>
+HERE
+ },
+ {
exec => ROUNDTRIP,
name => 'simpleTable',
html => <<'HERE',
@@ -449,6 +449,9 @@ qr/<[Tt][Ee][Xx][Tt][Aa][Rr][Ee][Aa]\b.*?<\/[Tt][Ee][Xx][Tt][Aa][Rr][Ee][Aa]>/s,
elsif ( $line =~ s/^((\t| )+): /<div class='foswikiIndent'> / ) {
# Indent pseudo-list
+ $line .= '&nbsp;'
+ if ( length($line) eq 28 )
+ ; # empty divs are not rendered, so make it non-empty.
_addListItem( $this, \@result, '', 'div', 'foswikiIndent', $1 );
$isList = 1;
}

0 comments on commit e09d730

Please sign in to comment.