Skip to content
Permalink
Browse files

Item11872: Handle nested div's

Closing div's were wrapping to the prior line, as were consecutive divs.
Since the witespace is not protected with <p>..</p> wrapping,  use
hidden whitespace.

Also, first close div would close the flag that parsing was inside a
<div>.   Use a counter for open/close divs.

git-svn-id: http://svn.foswiki.org/trunk@14842 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
GeorgeClark GeorgeClark
GeorgeClark authored and GeorgeClark committed May 18, 2012
1 parent 21f501e commit 1382179e799c800a424e90bda56b7edb66923416
@@ -736,19 +736,20 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
$inParagraph = 0;
$this->_addListItem( \@result, '', '', '' ) if $inList;
$inList = 0;
$inDiv = 1;
$inDiv++;
}
elsif ( $line eq $tableAndMacrosDivEnd ) {
$this->_addListItem( \@result, '', '', '' ) if $inList;
$inList = 0;
$inDiv = 0;
$inDiv--;

# The comment was only needed for this test,
# and it must be removed to prevent it ending up in TML
$line = '</div>';
}
elsif ( $line =~ m/<div/i ) {
$inDiv = 1;
$inDiv++;
$line .= $this->_hideWhitespace("\n");
push( @result, '</p>' ) if $inParagraph;
$inParagraph = 0;
}
@@ -788,7 +789,12 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
}
}
if ( $line =~ m/<\/div/i ) {
$inDiv = 0;

# Don't let the close div auto-wrap onto the prior line
if ( defined $result[-1] && $line =~ /^<\/div/i ) {
$result[-1] .= $this->_hideWhitespace("\n");
}
$inDiv--;
}
$line =~ s/(\s\s+)/$this->_hideWhitespace($1)/ge;
if ( defined $result[-1] ) {
@@ -807,9 +813,13 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
$this->_addListItem( \@result, '', '', '' );
}
elsif ($inParagraph) {

#print STDERR "autoClosing a p\n";
push( @result, '</p>' );
}
elsif ($inDiv) {

#print STDERR "autoClosing a div\n";
push( @result, '</div>' );
}

@@ -872,6 +872,36 @@ HERE
<noautolink>
RedHat & SuSE
</noautolink>
HERE
},
{
exec => $ROUNDTRIP | $TML2HTML | $HTML2TML,
name => 'nestedDiv_Item11872',
tml => <<HERE,
<div class="foswikiHelp">
<div class="jqTreeview">
* list
* item
* item
* item
</div>
</div>
HERE
html => <<HERE,
<div class="foswikiHelp TMLhtml"><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span>
<div class="jqTreeview TMLhtml"><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span>
<ul>
<li> list
<ul>
<li> item
</li>
<li> item
</li>
<li> item
</li>
</ul>
</li>
</ul><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span></div><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span></div>
HERE
},
{
@@ -884,9 +914,10 @@ HERE
* item
* item
</div>
blah
HERE
html => <<HERE,
<div class="jqTreeview TMLhtml">
<div class="jqTreeview TMLhtml"><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span>
<ul>
<li> list
<ul>
@@ -898,7 +929,9 @@ HERE
</li>
</ul>
</li>
</ul></div>
</ul><span style="{encoded:'n'}" class="WYSIWYG_HIDDENWHITESPACE">&nbsp;</span></div>
<p>blah
</p>
HERE
finaltml => <<'HERE',
<div class="jqTreeview">
@@ -907,6 +940,8 @@ HERE
* item
* item
</div>
blah
HERE
},
{

0 comments on commit 1382179

Please sign in to comment.
You can’t perform that action at this time.