diff --git a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/Table.pm b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/Table.pm index 125d931afd..606e1e3296 100644 --- a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/Table.pm +++ b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/Table.pm @@ -699,7 +699,7 @@ sub generateHelp { $attrs->{helptopic} ); my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); $text =~ s/.*?%STARTINCLUDE%//s; - $text =~ s/%STOPINCLUDE%.*//s; + $text =~ s/%(?:STOP|END)INCLUDE%.*//s; $text =~ s/^\s*//s; $text =~ s/\s*$//s; $help = Foswiki::Func::renderText($text); diff --git a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/TableParser.pm b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/TableParser.pm index db61aaa60f..5ec929ab46 100644 --- a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/TableParser.pm +++ b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/TableParser.pm @@ -35,7 +35,7 @@ sub parse { # them from processing as tables by converting them to verbatim. $text =~ s///g; - $text =~ s//<\/verbatim \001="$1">/g; + $text =~ s//<\/verbatim \001="$1">/g; $this->SUPER::parse( $text, $meta ); @@ -82,7 +82,7 @@ sub parse { } else { - # STARTINCLUDE/STOPINCLUDE support + # STARTINCLUDE/STOP/ENDINCLUDE support $t =~ s/<\/?verbatim \001="(.*?)">//gs; } push( @result, $t ); diff --git a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/View.pm b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/View.pm index 4a5b9725dd..486be6dc6c 100644 --- a/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/View.pm +++ b/EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin/View.pm @@ -187,7 +187,7 @@ sub process { ) { $precruft = "\n"; - $postcruft = "\n"; + $postcruft = "\n"; } $_ = $precruft . $line . $postcruft; $hasTables = 1; diff --git a/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin/SlideShow.pm b/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin/SlideShow.pm index 91de0e7b44..2362446909 100644 --- a/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin/SlideShow.pm +++ b/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin/SlideShow.pm @@ -242,19 +242,20 @@ sub renderSlideToc { sub readSlideTemplate { my $this = shift; - my ( $web, $topic ) = Foswiki::Func::normalizeWebTopicName( $this->{web}, + my ( $web, $topic ) = + Foswiki::Func::normalizeWebTopicName( $this->{web}, $this->{params}{template} || $this->{defaultTemplateTopic} ); my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); - # remove everything before %STARTINCLUDE% and after %STOPINCLUDE% + # remove everything before %STARTINCLUDE% and after %STOP/ENDINCLUDE% unless ($text) { return _htmlAlert( "%SYSTEMWEB%.SlideShowPlugin Error:", "Slide template topic $web.$topic not found or empty!" ); } $text =~ s/.*?%STARTINCLUDE%//s; - $text =~ s/%STOPINCLUDE%.*//s; + $text =~ s/%(?:END|STOP)INCLUDE%.*//s; unless ( $text =~ /%SLIDETITLE%/ && $text =~ /%SLIDETEXT%/ ) { return _htmlAlert( diff --git a/UnitTestContrib/test/unit/Fn_INCLUDE.pm b/UnitTestContrib/test/unit/Fn_INCLUDE.pm index ae891127a0..a84ed666ef 100644 --- a/UnitTestContrib/test/unit/Fn_INCLUDE.pm +++ b/UnitTestContrib/test/unit/Fn_INCLUDE.pm @@ -70,7 +70,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, - '1 %STARTINCLUDE%2%STOPINCLUDE% 3' ); + '1 %STARTINCLUDE%2%ENDINCLUDE% 3' ); $this->assert_str_equals( $includeError ? "A $includeError B" : 'A 2 B', Foswiki::Func::expandCommonVariables( @@ -90,7 +90,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{type="include"}%2%STOPSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' ); $this->assert_str_equals( $includeError ? "A $includeError B" : 'A 24 B', @@ -101,7 +101,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, - '1 %STARTSECTION%2%ENDSECTION% 3' ); + '1 %STARTSECTION%2%STOPSECTION% 3' ); $this->assert_str_equals( $includeError ? "A $includeError B" : 'A 1 2 3 B', Foswiki::Func::expandCommonVariables( @@ -121,7 +121,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%STOPSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' ); $this->assert_str_equals( $includeError ? "A $includeError B" : 'A 2 B', @@ -132,7 +132,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%STOPSECTION{type="include"}% 5' ); $this->assert_str_equals( $noSectionError ? "A $noSectionError B" : 'A 2 B', @@ -143,7 +143,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%STOPSECTION{type="include"}% 5' ); $this->assert_str_equals( $includeError ? "A B" : 'A 2 B', @@ -157,7 +157,7 @@ sub run_test_simple { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%STOPSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' ); $this->assert_str_equals( $noSectionError ? "A B" : 'A 2 B', @@ -325,7 +325,7 @@ sub test_simple_section { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, - '1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3' ); + '1 %STARTSECTION{type="include"}%2%STOPSECTION{type="include"}% 3' ); $this->assert_str_equals( $noSectionError ? "A $noSectionError B" : 'A 2 B', Foswiki::Func::expandCommonVariables( @@ -339,7 +339,7 @@ sub test_simple_section { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%STOPSECTION{type="include"}% 5' ); $this->assert_str_equals( $noSectionError ? "A $noSectionError B" : 'A 24 B', @@ -368,7 +368,7 @@ sub test_simple_section { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, - '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3' ); + '1 %STARTSECTION{"_default"}%2%STOPSECTION{"_default"}% 3' ); $this->assert_str_equals( $noSectionError ? "A $noSectionError B" : 'A 1 2 3 B', Foswiki::Func::expandCommonVariables( @@ -382,7 +382,7 @@ sub test_simple_section { ); Foswiki::Func::saveTopic( $this->{test_web}, 'FirstTopic', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%STOPSECTION{type="include"}% 5' ); $this->assert_str_equals( $includeError ? "A $includeError B" : 'A 2 B', @@ -451,7 +451,7 @@ sub test_select_first_that_defines_section { } Foswiki::Func::saveTopic( $this->{test_web}, 'NoSection', undef, -'1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"_default"}%2%STOPSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' ); $this->test_simple_section( 'section_name', @@ -469,7 +469,7 @@ sub test_select_first_that_defines_section { if ( !$this->check_dependency('Foswiki,<,1.2') ) { Foswiki::Func::saveTopic( $this->{test_web}, 'TheSection', undef, -'1 %STARTSECTION{"section_name"}%::%ENDSECTION{"section_name"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5' +'1 %STARTSECTION{"section_name"}%::%ENDSECTION{"section_name"}% 3 %STARTSECTION{type="include"}%4%STOPSECTION{type="include"}% 5' ); $this->assert_str_equals( 'A :: B', @@ -607,7 +607,7 @@ sub test_3158 { Snurfle %STARTSECTION{"suction"}% Such a section! -%ENDSECTION{"suction"}% +%STOPSECTION{"suction"}% Out of scope THIS $inkyDink->save(); @@ -657,11 +657,11 @@ sub test_5649 { Snurfle %STARTSECTION{"suction"}% Such a section! -%ENDSECTION{"suction"}% +%STOPSECTION{"suction"}% Out of scope THIS my $handledTopicText = $topicText; - $handledTopicText =~ s/%(START|END)SECTION{"suction"}%//g; + $handledTopicText =~ s/%(START|STOP|END)SECTION{"suction"}%//g; my ($inkyDink) = Foswiki::Func::readTopic( $this->{other_web}, $includedTopic ); @@ -953,7 +953,7 @@ HERE Foswiki::Func::saveTopic( $this->{test_web}, $includeTopic . 'Next', undef, <<'HERE' ); -%STARTSECTION{"one" one="_"}% %one% %two% - %INCLUDE{"%nest%" section="one" one="%one%"}% - %three% %last% %ENDSECTION{"one" last="999"}% +%STARTSECTION{"one" one="_"}% %one% %two% - %INCLUDE{"%nest%" section="one" one="%one%"}% - %three% %last% %STOPSECTION{"one" last="999"}% HERE $this->assert_str_equals( diff --git a/UnitTestContrib/test/unit/Fn_SECTION.pm b/UnitTestContrib/test/unit/Fn_SECTION.pm index d9cfced7af..83e3340c4f 100644 --- a/UnitTestContrib/test/unit/Fn_SECTION.pm +++ b/UnitTestContrib/test/unit/Fn_SECTION.pm @@ -119,6 +119,20 @@ sub test_sections8 { ); } +sub test_sections8S { + my $this = shift; + + # Unnamed sections of different types overlap + my $text = +'0%STARTSECTION{type="include"}%1%STARTSECTION{type="templateonly"}%2%STOPSECTION{type="include"}%3%STOPSECTION{type="templateonly"}%4'; + my ( $nt, $s ) = Foswiki::parseSections($text); + $this->assert_str_equals( "01234", $nt ); + $this->assert_str_equals( +'end="3" name="_SECTION0" start="1" type="include";end="4" name="_SECTION1" start="2" type="templateonly"', + dumpsec($s) + ); +} + sub test_sections9 { my $this = shift; @@ -133,6 +147,20 @@ sub test_sections9 { ); } +sub test_sections9S { + my $this = shift; + + # Named sections of same type overlap + my $text = +'0%STARTSECTION{"one"}%1%STARTSECTION{"two"}%2%STOPSECTION{"one"}%3%STOPSECTION{"two"}%4'; + my ( $nt, $s ) = Foswiki::parseSections($text); + $this->assert_str_equals( "01234", $nt ); + $this->assert_str_equals( +'end="3" name="one" start="1" type="section";end="4" name="two" start="2" type="section"', + dumpsec($s) + ); +} + sub test_sections10 { my $this = shift; @@ -147,6 +175,20 @@ sub test_sections10 { ); } +sub test_sections10S { + my $this = shift; + + # Named sections nested + my $text = +'0%STARTSECTION{name="one"}%1%STARTSECTION{name="two"}%2%STOPSECTION{name="two"}%3%STOPSECTION{name="one"}%4'; + my ( $nt, $s ) = Foswiki::parseSections($text); + $this->assert_str_equals( "01234", $nt ); + $this->assert_str_equals( +'end="4" name="one" start="1" type="section";end="3" name="two" start="2" type="section"', + dumpsec($s) + ); +} + # For test_manysections, Item10316 sub _manysections_inc { my ( $this, $section ) = @_; @@ -160,27 +202,27 @@ HERE } sub _manysections_setup { - my ($this) = @_; - my $junk = "I am a fish.\n" x 100; - my $text = <<"HERE"; + my ( $this, $end ) = @_; + my $junk = "I am a fish.\n" x 100; + my $text = <<"HERE"; Pre-INCLUDEable %STARTINCLUDE% In-the-INCLUDEable bit $junk -%STARTSECTION{"1"}% 1 content $junk%ENDSECTION{"1"}% +%STARTSECTION{"1"}% 1 content $junk%${end}SECTION{"1"}% %STARTSECTION{"2"}% 2 content -%STARTSECTION{"21"}% 2.1 content $junk%ENDSECTION{"21"}% +%STARTSECTION{"21"}% 2.1 content $junk%${end}SECTION{"21"}% %STARTSECTION{"22"}% 2.2 content -%STARTSECTION{"221"}% 2.2.1 content $junk%ENDSECTION{"221"}% -%STARTSECTION{"222" ignored="asd"}% 2.2.2 content $junk%ENDSECTION{"222"}% -%STARTSECTION{"223"}% 2.2.3 content $junk%ENDSECTION{"223" ignoreend="oooooo"}% -%STARTSECTION{"224"}% 2.2.4 start continued content $junk%ENDSECTION{"224"}% -%STARTSECTION{"224"}% 2.2.4b continue continued content $junk%ENDSECTION{"224"}%$junk%ENDSECTION{"22"}% -%STARTSECTION{"23"}% 2.3 content %STARTSECTION{"224"}% 2.2.4c continue again continued content $junk%ENDSECTION{"224"}%$junk%ENDSECTION{"23"}% -%STARTSECTION{"224"}% 2.2.4d continue yet again continued content $junk%ENDSECTION{"224"}% +%STARTSECTION{"221"}% 2.2.1 content $junk%${end}SECTION{"221"}% +%STARTSECTION{"222" ignored="asd"}% 2.2.2 content $junk%${end}SECTION{"222"}% +%STARTSECTION{"223"}% 2.2.3 content $junk%${end}SECTION{"223" ignoreend="oooooo"}% +%STARTSECTION{"224"}% 2.2.4 start continued content $junk%${end}SECTION{"224"}% +%STARTSECTION{"224"}% 2.2.4b continue continued content $junk%${end}SECTION{"224"}%$junk%${end}SECTION{"22"}% +%STARTSECTION{"23"}% 2.3 content %STARTSECTION{"224"}% 2.2.4c continue again continued content $junk%${end}SECTION{"224"}%$junk%${end}SECTION{"23"}% +%STARTSECTION{"224"}% 2.2.4d continue yet again continued content $junk%${end}SECTION{"224"}% $junk -%ENDSECTION{"2"}% +%${end}SECTION{"2"}% Still-in-the-INCLUDEable bit -%STARTSECTION{"224"}% 2.2.4e continue yet again more continued content $junk%ENDSECTION{"224"}% -$junk%STOPINCLUDE% Post-INCLUDEable -%STARTSECTION{"3"}% 3 content %STARTSECTION{"224"}% 2.2.4f continue yet again even more continued content $junk%ENDSECTION{"224"}%$junk%ENDSECTION{"3"}% +%STARTSECTION{"224"}% 2.2.4e continue yet again more continued content $junk%${end}SECTION{"224"}% +$junk%${end}INCLUDE% Post-INCLUDEable +%STARTSECTION{"3"}% 3 content %STARTSECTION{"224"}% 2.2.4f continue yet again even more continued content $junk%${end}SECTION{"224"}%$junk%${end}SECTION{"3"}% HERE my ($topicObj) = Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); @@ -232,9 +274,21 @@ HERE ); } -sub test_manysections { +sub test_manysections_END { + my ($this) = @_; + my %sections = $this->_manysections_setup('END'); + + foreach my $section ( keys %sections ) { + $this->assert_str_equals( $sections{$section}, + $this->_manysections_inc($section) ); + } + + return; +} + +sub test_manysections_STOP { my ($this) = @_; - my %sections = $this->_manysections_setup(); + my %sections = $this->_manysections_setup('STOP'); foreach my $section ( keys %sections ) { $this->assert_str_equals( $sections{$section}, @@ -246,7 +300,7 @@ sub test_manysections { sub test_manysections_timing { my ($this) = @_; - my %sections = $this->_manysections_setup(); + my %sections = $this->_manysections_setup('STOP'); my $numsections = scalar( keys %sections ); my $numcycles = 50; my $benchmark = timeit( diff --git a/core/data/System/VarENDINCLUDE.txt b/core/data/System/VarENDINCLUDE.txt new file mode 100644 index 0000000000..4d225e6e49 --- /dev/null +++ b/core/data/System/VarENDINCLUDE.txt @@ -0,0 +1,8 @@ +%META:TOPICINFO{author="ProjectContributor" date="1396410293" format="1.1" version="1"}% +%META:TOPICPARENT{name="Macros"}% +#VarENDINCLUDE +---+++ ENDINCLUDE -- end position of topic text if included + * If present in included topic, stop to include text at this location and ignore the remaining text. A normal view of the topic shows everyting exept the =%STOPINCLUDE%= macro itself. + * Syntax: =%ENDINCLUDE%= + * Related: [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarINCLUDE][INCLUDE]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTARTINCLUDE][STARTINCLUDE]] + diff --git a/core/data/System/VarINCLUDE.txt b/core/data/System/VarINCLUDE.txt index 6333b3eaa0..68cb500176 100644 --- a/core/data/System/VarINCLUDE.txt +++ b/core/data/System/VarINCLUDE.txt @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="ProjectContributor" date="1394718137" format="1.1" version="1"}% +%META:TOPICINFO{author="ProjectContributor" date="1396410293" format="1.1" version="1"}% %META:TOPICPARENT{name="Macros"}% #VarINCLUDE ---+++ INCLUDE{"topic"} -- include other topic. @@ -15,7 +15,7 @@ | =section="name"= | Includes only the specified named section, as defined in the included topic by the [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION{"name" type="section"} ]] and [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarENDSECTION][ENDSECTION{"name" type="section"}]] macros. Nothing is shown if the named section does not exists. =section=""= is equivalent to not specifying a section | | | =PARONE="val 1"%BR% PARTWO="val 2"= | Any other parameter will be defined as a macro 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. | | * Examples: See IncludeTopicsAndWebPages - * Related: [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarBASETOPIC][BASETOPIC]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarBASEWEB][BASEWEB]], [[#VarINCLUDEURL][INCLUDE("URL")]], [[#VarINCLUDEdoc][INCLUDE("doc:")]] ,[[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarINCLUDINGTOPIC][INCLUDINGTOPIC]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarINCLUDINGWEB][INCLUDINGWEB]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTARTINCLUDE][STARTINCLUDE]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTOPINCLUDE][STOPINCLUDE]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarENDSECTION][ENDSECTION]] + * Related: [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarBASETOPIC][BASETOPIC]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarBASEWEB][BASEWEB]], [[#VarINCLUDEURL][INCLUDE("URL")]], [[#VarINCLUDEdoc][INCLUDE("doc:")]] ,[[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarINCLUDINGTOPIC][INCLUDINGTOPIC]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarINCLUDINGWEB][INCLUDINGWEB]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTARTINCLUDE][STARTINCLUDE]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarENDINCLUDE][ENDINCLUDE]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTOPINCLUDE][STOPINCLUDE]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION]], [[%IF{"'%BASETOPIC%'='Macros'" then="#"}%VarENDSECTION][ENDSECTION]] #VarINCLUDEURL ---+++ INCLUDE{"url"} -- include a web page * Syntax: =%INCLUDE{"http://..." ...}%= (See also the topic form of =%INCLUDE%=) diff --git a/core/data/System/VarSTARTINCLUDE.txt b/core/data/System/VarSTARTINCLUDE.txt index 33ef864c8d..6e1cb95893 100644 --- a/core/data/System/VarSTARTINCLUDE.txt +++ b/core/data/System/VarSTARTINCLUDE.txt @@ -1,9 +1,9 @@ -%META:TOPICINFO{author="ProjectContributor" date="1394718138" format="1.1" version="1"}% +%META:TOPICINFO{author="ProjectContributor" date="1396410293" format="1.1" version="1"}% %META:TOPICPARENT{name="Macros"}% #VarSTARTINCLUDE ---+++ STARTINCLUDE -- start position of topic text if included - * If present in included topic, start to include text from this location up to the end, or up to the location of the =%STOPINCLUDE%= macro. A normal view of the topic shows everything exept the =%STARTINCLUDE%= macro itself. + * If present in included topic, start to include text from this location up to the end, or up to the location of the =%ENDINCLUDE%= macro. A normal view of the topic shows everything except the =%STARTINCLUDE%= macro itself. * Syntax: =%STARTINCLUDE%=
%T% If you want more than one part of the topic included, use =%STARTSECTION{type="include"}%= instead
- * Related: [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarINCLUDE][INCLUDE]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTOPINCLUDE][STOPINCLUDE]] + * Related: [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarINCLUDE][INCLUDE]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarENDINCLUDE][ENDINCLUDE]] diff --git a/core/data/System/VarSTOPINCLUDE.txt b/core/data/System/VarSTOPINCLUDE.txt index f7cb7bb588..8465713f54 100644 --- a/core/data/System/VarSTOPINCLUDE.txt +++ b/core/data/System/VarSTOPINCLUDE.txt @@ -1,8 +1,6 @@ -%META:TOPICINFO{author="ProjectContributor" date="1394718138" format="1.1" version="1"}% +%META:TOPICINFO{author="ProjectContributor" date="1396410293" format="1.1" version="1"}% %META:TOPICPARENT{name="Macros"}% #VarSTOPINCLUDE ----+++ STOPINCLUDE -- end position of topic text if included - * If present in included topic, stop to include text at this location and ignore the remaining text. A normal view of the topic shows everyting exept the =%STOPINCLUDE%= macro itself. - * Syntax: =%STOPINCLUDE%= +---+++ STOPINCLUDE -- Alias for [[VarENDINCLUDE][ENDINCLUDE]] * Related: [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarINCLUDE][INCLUDE]], [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTARTINCLUDE][STARTINCLUDE]] diff --git a/core/data/System/VarSTOPSECTION.txt b/core/data/System/VarSTOPSECTION.txt new file mode 100644 index 0000000000..571073eca4 --- /dev/null +++ b/core/data/System/VarSTOPSECTION.txt @@ -0,0 +1,6 @@ +%META:TOPICINFO{author="ProjectContributor" date="1396410293" format="1.1" version="1"}% +%META:TOPICPARENT{name="Macros"}% +#VarSTOPSECTION +---+++ STOPSECTION{"name"} -- Alias for [[VarENDSECTION][ENDSECTION]] + * Related: [[%IF{"'%INCLUDINGTOPIC%'='Macros'" then="#"}%VarSTARTSECTION][STARTSECTION]] + diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm index ec5835b949..c922a3ee51 100644 --- a/core/lib/Foswiki.pm +++ b/core/lib/Foswiki.pm @@ -305,12 +305,14 @@ BEGIN { # Constant tag strings _not_ dependent on config. These get nicely # optimised by the compiler. + STOPSECTION => sub { '' }, ENDSECTION => sub { '' }, WIKIVERSION => sub { $VERSION }, WIKIRELEASE => sub { $RELEASE }, STARTSECTION => sub { '' }, STARTINCLUDE => sub { '' }, STOPINCLUDE => sub { '' }, + ENDINCLUDE => sub { '' }, ); $contextFreeSyntax{IF} = 1; @@ -2490,7 +2492,9 @@ sub parseSections { my $seq = 0; my $ntext = ''; my $offset = 0; - foreach my $bit ( split( /(%(?:START|END)SECTION(?:{.*?})?%)/, $text ) ) { + foreach + my $bit ( split( /(%(?:START|STOP|END)SECTION(?:{.*?})?%)/, $text ) ) + { if ( $bit =~ /^%STARTSECTION(?:{(.*)})?%$/ ) { require Foswiki::Attrs; @@ -2523,7 +2527,7 @@ sub parseSections { $sections{$id} = $attrs; push( @list, $attrs ); } - elsif ( $bit =~ /^%ENDSECTION(?:{(.*)})?%$/ ) { + elsif ( $bit =~ /^%(?:END|STOP)SECTION(?:{(.*)})?%$/ ) { require Foswiki::Attrs; # SMELL: unchecked implicit untaint? diff --git a/core/lib/Foswiki/Contrib/core/MANIFEST b/core/lib/Foswiki/Contrib/core/MANIFEST index 9e21cc77df..2e6ab729af 100644 --- a/core/lib/Foswiki/Contrib/core/MANIFEST +++ b/core/lib/Foswiki/Contrib/core/MANIFEST @@ -213,6 +213,7 @@ data/System/VarDISPLAYTIME.txt 0644 data/System/VarEDITACTION.txt 0644 data/System/VarENCODE.txt 0644 data/System/VarENDCOLOR.txt 0644 +data/System/VarENDINCLUDE.txt 0644 data/System/VarENDSECTION.txt 0644 data/System/VarENV.txt 0644 data/System/VarEXPAND.txt 0644 @@ -295,6 +296,7 @@ data/System/VarSTARTINCLUDE.txt 0644 data/System/VarSTARTSECTION.txt 0644 data/System/VarSTATISTICSTOPIC.txt 0644 data/System/VarSTOPINCLUDE.txt 0644 +data/System/VarSTOPSECTION.txt 0644 data/System/VarSYSTEMWEB.txt 0644 data/System/VarT.txt 0644 data/System/VarTEAL.txt 0644 diff --git a/core/lib/Foswiki/IncludeHandlers/doc.pm b/core/lib/Foswiki/IncludeHandlers/doc.pm index b63de2d8c4..19786dc52f 100644 --- a/core/lib/Foswiki/IncludeHandlers/doc.pm +++ b/core/lib/Foswiki/IncludeHandlers/doc.pm @@ -120,7 +120,7 @@ s/^---\+(?:!!)?\s+package\s*(.*)/---+ =$visibility package= $1/; Foswiki::putBackBlocks( \$pod, \%removedblocks, 'verbatim', 'verbatim' ); $pod =~ s/.*?%STARTINCLUDE%//s; - $pod =~ s/%STOPINCLUDE%.*//s; + $pod =~ s/%(?:END|STOP)INCLUDE%.*//s; if ($howSmelly) { my $podSmell = '
' diff --git a/core/lib/Foswiki/Macros/INCLUDE.pm b/core/lib/Foswiki/Macros/INCLUDE.pm index 7d244f0066..5d53af6c00 100644 --- a/core/lib/Foswiki/Macros/INCLUDE.pm +++ b/core/lib/Foswiki/Macros/INCLUDE.pm @@ -218,7 +218,7 @@ sub _includeTopic { # a section is explicitly defined if ( !$control->{section} ) { $text =~ s/.*?%STARTINCLUDE%//s; - $text =~ s/%STOPINCLUDE%.*//s; + $text =~ s/%(?:END|STOP)INCLUDE%.*//s; } # prevent dirty areas in included topics from being parsed