Item1430: EditChapter breaks with TOC and PRE/VERBATIM (patch available)
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
When
EditChapter plugin and
RenderList Plugin are both enabled and you try to do a TOC using renderlist, then
EditChapter labels the entries in the TOC as something to edit -- these should be left alone, really.
Trying to do this;
%RENDERLIST{"thread"}%
%TOC%
without editchapter enabled HTML output looks like this (works);
<a name="foswikiTOC"></a><div class="foswikiToc"><table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/dot_ur.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><nobr> <a href="#some_tests"> some tests</a> </nobr></td>
</tr></table>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/empty.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/dot_udr.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><nobr> <a href="#heading_2"> heading 2</a> </nobr></td>
</tr></table>
with editchapter enabled HTML output looks like this (doesn't work);
<a name="foswikiTOC"></a><div class="foswikiToc"><table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/dot_ur.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><nobr> <a href="#some_tests"><span class="ecpHeading"> some tests <img src="/pub/System/EditChapterPlugin/pencil.png" height="16" width="16" border="0" /></span></a> </nobr></td>
</tr></table>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/empty.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><img src="http://unixwiki/pub/System/RenderListPlugin/dot_udr.gif" width="16" height="16" alt="" border="0" /></td>
<td valign="top"><nobr> <a href="#heading_2"><span class="ecpHeading"> heading 2 <img src="/pub/System/EditChapterPlugin/pencil.png" height="16" width="16" border="0" /></span></a> </nobr></td>
</tr></table>
--
SallyHoughton - 09 Apr 2009
I've also noticed that the edit chapter plugin doesn't ignore the pre and verbatim tags (except when using EXTRACTCHAPTER)...meaning that when you have something in a PRE block and it is a heading, then the little pencil icon will show up there as well.
--
SallyHoughton - 28 May 2009
Try these patches:
--- lib/Foswiki/Plugins/EditChapterPlugin/Core.pm (revision 3783)
+++ lib/Foswiki/Plugins/EditChapterPlugin/Core.pm (working copy)
@@ -83,6 +83,7 @@
my $this = shift;
### my ( $text, $topic, $web, $include, $meta ) = @_;
+ my $text = $_[0];
my $topic = $_[1];
my $web = $_[2];
@@ -93,7 +94,12 @@
#writeDebug("called commonTagsHandler($web, $topic)");
- $_[0] =~ s/%(EN|DIS)ABLEEDITCHAPTER%/
+ my $blocks = {};
+ my $renderer = $Foswiki::Plugins::SESSION->renderer;
+ $text = $renderer->takeOutBlocks($text, 'verbatim', $blocks);
+ $text = $renderer->takeOutBlocks( $text, 'pre', $blocks);
+
+ $text =~ s/%(EN|DIS)ABLEEDITCHAPTER%/
$this->handleEnableEditChapter($web, $topic, $1)
/ge;
@@ -111,13 +117,18 @@
#writeDebug("enabled=$enabled");
+
# loop over all lines
my $chapterNumber = 0;
- $_[0] =~ s/(^)(---+[\+#]{$this->{minDepth},$this->{maxDepth}}[0-9]*(?:!!)?)([^$this->{translationToken}\+#!].+?)($)/
+ $text =~ s/(^)(---+[\+#]{$this->{minDepth},$this->{maxDepth}}[0-9]*(?:!!)?)([^$this->{translationToken}\+#!].+?)($)/
$1.
$this->handleSection($web, $topic, \$chapterNumber, $3, $2, $4, $enabled)
/gme;
+ $renderer->putBackBlocks( \$text, $blocks, 'pre' );
+ $renderer->putBackBlocks( \$text, $blocks, 'verbatim' );
+
+ $_[0] = $text;
}
and
--- pub/System/EditChapterPlugin/ecpstyles.css (revision 3783)
+++ pub/System/EditChapterPlugin/ecpstyles.css (working copy)
@@ -15,7 +15,7 @@
border:0px;
}
/* some foswiki fixes */
-.foswikiToc img {
+.foswikiToc .ecpHeading img {
display:none;
}
.foswikiToc .ecpHeading {
--
MichaelDaum - 28 May 2009
That works! Thanks so much...I've now got no ecp heading at all in my pre/verbatim and although the ecpHeading tags are still there in a TOC, the
RenderListPlugin works fine.
Thanks so much!
--
SallyHoughton - 29 May 2009