You are here: Foswiki>Tasks Web>Item1430 (29 May 2009, SallyHoughton)Edit Attach

Item1430: EditChapter breaks with TOC and PRE/VERBATIM (patch available)

pencil
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
Applies To: Extension
Component: EditChapterPlugin
Branches:
Reported By: SallyHoughton
Waiting For: Main.MichaelDaum
Last Change By: SallyHoughton
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

ItemTemplate edit

Summary EditChapter breaks with TOC and PRE/VERBATIM (patch available)
ReportedBy SallyHoughton
Codebase 1.0.5, 1.0.4
SVN Range Foswiki-1.0.4 Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component EditChapterPlugin
Priority Normal
CurrentState Closed
WaitingFor MichaelDaum
Checkins
TargetRelease n/a
ReleasedIn
Topic revision: r5 - 29 May 2009, SallyHoughton
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy