Skip to content

Commit

Permalink
Item13957: Item13958: Fix white space issues in : indents
Browse files Browse the repository at this point in the history
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
gac410 committed Mar 19, 2016
1 parent d1f1d61 commit e09d730
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
43 changes: 43 additions & 0 deletions UnitTestContrib/test/unit/FormattingTests.pm
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
Expand Up @@ -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;
Expand Down
35 changes: 32 additions & 3 deletions WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
Expand Up @@ -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'>
Expand All @@ -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',
Expand All @@ -718,14 +719,42 @@ 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
},
{
Expand Down
3 changes: 3 additions & 0 deletions core/lib/Foswiki/Render.pm
Expand Up @@ -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;
}
Expand Down

0 comments on commit e09d730

Please sign in to comment.