[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
New WML feature for pass 6 - Area Substitution (patch)
- From: Thomas Akin <nospam@thanx>
- Date: Wed, 20 Oct 1999 16:54:06 -0400
Name: wml174.p6.patch
WML Version: WML 1.7.4
Patch Author: Thomas Akin
Applying the patch:
1) copy the patch to your wml-1.7.4 directory
2) delete everything up to and including the line
------- <cut here> -------------------
3) run 'patch -b -p1 < patchfilename'
where "patchfilename" is the name of the patch file.
Function:
This patch adds a new tag pair called
<noasub> ... </noasub>. Anything within these tags will be
ignored by pass 6 the Area Substitution pass.
Why:
This patch was developed because I needed it :)
Here was the problem... I have a site template which contains
something similar to
{:
[[s|(data.here)|<a href="data-here.html">$1</a>|igs]]
[[s|(other.data)|<a href="other-data.html">$1</a>igs]]
etc...
<<BODY>>
:}
That way I have key phrases that are automatically substituted
anywhere in my entire site. But, there are certain locations
where I only want part of the body substituted. For example,
when I rendered a table of contents using the <toc> tag it was
not only marking up the data below the TOC, but also any
matching phrases in the TOC. I had links within links.
Having to place individual {: :} blocks in each page that I
only wanted partially substituted seemed extremely tedious. I
needed a way to tell pass 6 to ignore certain areas of
data. Hence the <noasub> ... </noasub> tags.
Details:
Anything located inside the tags <noasub> .... </noasub> is
ignored by pass 6. It deals nicely with nested tags by simply
removing and ignoring any nested <noasub> .... </noasub> tags.
The <noasub> and </noasub> tags are removed after the last
area substitution pass.
Example:
The wml code:
{:
[[s|(home.page)|<a href="index.html">$1</a>|igs]]
See my home page when you get a chance!
<noasub>
My brother is also working on a home page. Watch for it soon.
</noasub>
}:
Renders:
See my <a href="index.html">home page</a> when you get a chance!
My brother is also working on a home page. Watch for it soon.
That's it.... Let me know if you find this useful or have any
questions... Denis, any chance of this making it into the next
release? I have found this tag extremely useful and it seems a logical
extension to pass 6...
Thanks,
Thomas
---------------------------------------------------------------
Thomas Akin Kennesaw State University
Networking Instructor Continuing Education
CNX, CSA, ICS 1000 Chastain Road
takin@kennesaw.edu Kennesaw, GA 30144-5591
---------------------------------------------------------------
------- <cut here> -------------------
Index: wml-1.7.4/wml_backend/p6_asubst/asubst.src
*** wml-1.7.4.1/wml_backend/p6_asubst/asubst.src Tue Jan 12 09:24:25 1999
--- wml-1.7.4/wml_backend/p6_asubst/asubst.src Tue Oct 19 18:38:40 1999
***************
*** 223,231 ****
$str =~ s|\[\[(s(.)[^\2]+?\2[^\2]*?\2[igosme]*?)\]\]|push(@SCMD, $1), ''|sge;
$str =~ s|\[\[(tr(.)[^\2]+?\2[^\2]+?\2[igosme]*?)\]\]|push(@SCMD, $1), ''|sge;
foreach $scmd (@SCMD) {
! eval "\$str =~ $scmd;";
}
return $str;
}
sub cnvpost {
my ($str, $level) = @_;
--- 223,277 ----
$str =~ s|\[\[(s(.)[^\2]+?\2[^\2]*?\2[igosme]*?)\]\]|push(@SCMD, $1), ''|sge;
$str =~ s|\[\[(tr(.)[^\2]+?\2[^\2]+?\2[igosme]*?)\]\]|push(@SCMD, $1), ''|sge;
+
+
+ my $outstr;
+ my $tmpstr;
foreach $scmd (@SCMD) {
!
! $outstr = '';
! # Lets tear apart $str and build an asubbed $outstr
! while ($str ne '') {
! # If we don't have any <noasub> tags mark up and were done.
! if ($str !~ m|<noasub>|is) {
! eval "\$str =~ $scmd;";
! $outstr .= $str;
! $str = '';
! } else {
! # We strip out any begging text and asub it
! # Making sure to leave in the <noasub> tag
! $str =~ s|^(.*?)<noasub>|<noasub>|is;
! $tmpstr = $1;
! eval "\$tmpstr =~ $scmd;";
! $outstr .= $tmpstr;
!
! # Now we find the smallest <noasub>...</noasub> block
! $str =~ s|<noasub>(.*?)</noasub>||is;
! $tmpstr = $1;
!
! # If there are no nested tags we add this to our
! # $outstr not marked up.
! if ($tmpstr !~ m|<noasub>|is) {
! $outstr .= "<noasub>$tmpstr</noasub>";
!
! # Else we have to deal with the nested tags...
! } else {
! # Get rid of nested <noasub> tag.
! $tmpstr =~ s|<noasub>||is;
! # Rebuild $str
! $str = "<noasub>$tmpstr$str";
! }
! }
! }
! # Reset $str
! $str = $outstr;
}
+ # Now strip out all of the <noasub> tags
+ $str =~ s|<noasub>||isg;
+ $str =~ s|</noasub>||isg;
+
+ # and finally return... :)
return $str;
}
+
sub cnvpost {
my ($str, $level) = @_;
______________________________________________________________________
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List sw-wml@engelschall.com
Automated List Manager majordomo@engelschall.com