diff -urP public_html.ORIG/data/Sandbox/IncludeTest.txt public_html/data/Sandbox/IncludeTest.txt
--- public_html.ORIG/data/Sandbox/IncludeTest.txt 1970-01-01 01:00:00.000000000 +0100
+++ public_html/data/Sandbox/IncludeTest.txt 2007-11-27 16:41:05.000000000 +0100
@@ -0,0 +1,22 @@
+%META:TOPICINFO{author="MarcSCHAEFER" date="1196178065" format="1.1" reprev="1.1" version="1.1"}%
+---+!! Ceci est un test
+
+%TOC%
+
+%INCLUDE{"IncludeTestInclude"}%
+
+---++ Titre 2
+---+++ Titre3
+
+%INCLUDE{"IncludeTestInclude" offsetheadings="+++"}%
+
+---++ Titre2: b
+%INCLUDE{"IncludeTestInclude" offsetheadings="++"}%
+
+---+++ Titre3: c
+---++++ Titre4
+%INCLUDE{"IncludeTestInclude" offsetheadings="++++"}%
+
+Also go to IncludeTestInclude to see that it works standalone, too.
+
+-- Main.MarcSCHAEFER - 27 Nov 2007
diff -urP public_html.ORIG/data/Sandbox/IncludeTest.txt,v public_html/data/Sandbox/IncludeTest.txt,v
--- public_html.ORIG/data/Sandbox/IncludeTest.txt,v 1970-01-01 01:00:00.000000000 +0100
+++ public_html/data/Sandbox/IncludeTest.txt,v 2007-11-27 16:41:05.000000000 +0100
@@ -0,0 +1,46 @@
+head 1.1;
+access;
+symbols;
+locks; strict;
+comment @# @;
+
+
+1.1
+date 2007.11.27.15.41.05; author MarcSCHAEFER; state Exp;
+branches;
+next ;
+
+
+desc
+@none
+@
+
+
+1.1
+log
+@none
+@
+text
+@%META:TOPICINFO{author="MarcSCHAEFER" date="1196178065" format="1.1" reprev="1.1" version="1.1"}%
+---+!! Ceci est un test
+
+%TOC%
+
+%INCLUDE{"IncludeTestInclude"}%
+
+---++ Titre 2
+---+++ Titre3
+
+%INCLUDE{"IncludeTestInclude" offsetheadings="+++"}%
+
+---++ Titre2: b
+%INCLUDE{"IncludeTestInclude" offsetheadings="++"}%
+
+---+++ Titre3: c
+---++++ Titre4
+%INCLUDE{"IncludeTestInclude" offsetheadings="++++"}%
+
+Also go to IncludeTestInclude to see that it works standalone, too.
+
+-- Main.MarcSCHAEFER - 27 Nov 2007
+@
diff -urP public_html.ORIG/data/Sandbox/IncludeTestInclude.txt public_html/data/Sandbox/IncludeTestInclude.txt
--- public_html.ORIG/data/Sandbox/IncludeTestInclude.txt 1970-01-01 01:00:00.000000000 +0100
+++ public_html/data/Sandbox/IncludeTestInclude.txt 2007-11-27 16:40:39.000000000 +0100
@@ -0,0 +1,13 @@
+%META:TOPICINFO{author="MarcSCHAEFER" date="1196178039" format="1.1" reprev="1.1" version="1.1"}%
+%META:TOPICPARENT{name="IncludeTest"}%
+---+ Directeur
+---++ Personne
+---+++ Employé
+
+---+ Salaire
+---++ Annuel
+---++ Mensuel
+
+---+!! Commentaire
+
+-- Main.MarcSCHAEFER - 27 Nov 2007
diff -urP public_html.ORIG/data/Sandbox/IncludeTestInclude.txt,v public_html/data/Sandbox/IncludeTestInclude.txt,v
--- public_html.ORIG/data/Sandbox/IncludeTestInclude.txt,v 1970-01-01 01:00:00.000000000 +0100
+++ public_html/data/Sandbox/IncludeTestInclude.txt,v 2007-11-27 16:40:39.000000000 +0100
@@ -0,0 +1,37 @@
+head 1.1;
+access;
+symbols;
+locks; strict;
+comment @# @;
+
+
+1.1
+date 2007.11.27.15.40.39; author MarcSCHAEFER; state Exp;
+branches;
+next ;
+
+
+desc
+@none
+@
+
+
+1.1
+log
+@none
+@
+text
+@%META:TOPICINFO{author="MarcSCHAEFER" date="1196178039" format="1.1" reprev="1.1" version="1.1"}%
+%META:TOPICPARENT{name="IncludeTest"}%
+---+ Directeur
+---++ Personne
+---+++ Employé
+
+---+ Salaire
+---++ Annuel
+---++ Mensuel
+
+---+!! Commentaire
+
+-- Main.MarcSCHAEFER - 27 Nov 2007
+@
diff -urP public_html.ORIG/data/TWiki/VarINCLUDE.txt public_html/data/TWiki/VarINCLUDE.txt
--- public_html.ORIG/data/TWiki/VarINCLUDE.txt 2007-11-27 16:42:15.000000000 +0100
+++ public_html/data/TWiki/VarINCLUDE.txt 2007-11-27 16:28:02.000000000 +0100
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="TWikiContributor" date="1111929255" format="1.2" version="1"}%
+%META:TOPICINFO{author="MarcSCHAEFER" date="1196177282" format="1.1" reprev="1.2" version="1.2"}%
%META:TOPICPARENT{name="TWikiVariables"}%
#VarINCLUDE
@@ -14,8 +14,8 @@
| =raw="on"= | When a page is included, normally %WIKITOOLNAME% will process it, doing the following: 1) Alter relative links to point back to originating host, 2) Remove some basic HTML tags (html, head, body, script) and finally 3) Remove newlines from tags spanning multiple lines. If you prefer to include _exactly_ what is in the source of the originating page set this to =on=. | disabled |
| =warn="off"= | Warn if topic include fails: Fail silently (if =off=); output default warning (if set to =on=); else, output specific text (use =$topic= for topic name) | =%INCLUDEWARNING%= [[TWikiPreferences][preferences]] setting |
| =section="name"= | Includes only the specified named section, as defined in the included topic by the [[#VarSTARTSECTION][STARTSECTION]] and [[#VarENDSECTION][ENDSECTION]] variables| |
+ | =offsetheadings="offset"= | Specifying =offsetheadings="+"= for example will add a %RELATIVEHEADINGS% to each headings of the included topic, and define the variable to ="+"= as if it had been passed as a parameter manually. This is a pragmatic approach to implementing Codev.RelativeHeadingLevelsforINCLUDE. It complements the manual approach using an %EXTRA% variable: you don't need to add %EXTRA% to the included topics manually (which means the topic will be seen correctly also when %EXTRA% is undefined -- the Main.TWikiPreferences predefinition [[Support/IncludeCannotSetPredefinedPreference][doesn't work either]]) |
| =PARONE="val 1"%BR% PARTWO="val 2"= | Any other parameter will be defined as a variable within the scope of the included topic. The example parameters on the left will result in =%PARONE%= and =%PARTWO%= being defined within the included topic. | |
* __Note:__ !JavaScript in included webpages is filtered out as a security precaution per default (disable filter with =raw= parameter)
* Examples: See IncludeTopicsAndWebPages
* Related: [[#VarBASETOPIC][BASETOPIC]], [[#VarBASEWEB][BASEWEB]], [[#VarINCLUDINGTOPIC][INCLUDINGTOPIC]], [[#VarINCLUDINGWEB][INCLUDINGWEB]], [[#VarSTARTINCLUDE][STARTINCLUDE]], [[#VarSTOPINCLUDE][STOPINCLUDE]], [[#VarSTARTSECTION][STARTSECTION]], [[#VarENDSECTION][ENDSECTION]]
-
diff -urP public_html.ORIG/lib/TWiki.pm public_html/lib/TWiki.pm
--- public_html.ORIG/lib/TWiki.pm 2007-11-27 16:42:17.000000000 +0100
+++ public_html/lib/TWiki.pm 2007-11-27 16:35:03.000000000 +0100
@@ -2670,6 +2670,14 @@
my $warn = $params->remove('warn')
|| $this->{prefs}->getPreferencesValue( 'INCLUDEWARNING' );
+ # if it is empty, it is not required to define the variable
+ my $offsetheadings = $params->remove('offsetheadings') || '';
+
+ if ($offsetheadings ne '') {
+ # set the special variable
+ $this->{SESSION_TAGS}{RELATIVEHEADINGS} = $offsetheadings;
+ }
+
if( $path =~ /^https?\:/ ) {
# include web page
return $this->_includeUrl( $path, $pattern, $includingWeb, $includingTopic, $raw );
@@ -2810,6 +2818,11 @@
$this->{renderer}->putBackBlocks( \$text, $removed, 'noautolink' );
}
+ if ($offsetheadings ne '') {
+ # add special variable to any headings
+ $text =~ s/(^|\n)---(\++)/$1---$2%RELATIVEHEADINGS%/g;
+ }
+
# handle tags again because of plugin hook
$this->_expandAllTags( \$text, $includedTopic, $includedWeb );