#!/usr/bin/env perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
# $Author$ Last modified: 14 Dec 2003 15:30:18
# Suggested name: "pmnodecomp-blockquoter" - shorten if wished.
# Or better yet make a symlink or alias.
use strict;
BEGIN {
use vars qw! $plugin !;
$plugin =
(eval { # Place your own home-brewed filter module below.
# This is only a suggestive example / default.
require PMntextFilter;
# import PMnTextFilter "quazzle wrench bangbar";
}) ? 'extern' : 'intern';
}
use warnings;
use vars qw! $DeBug $acq $outfm $rcnt $pictstr !,
qw! $amps $ltgt $sqbr !;
use subs qw! bbegin bendin newblk filtermeta !;
$DeBug = 0;
use constant rCNT => 66; # arbitrary length for output lines.
format EBLK =
</blockquote>
.
format BBLK =
<blockquote>
.
format NBLK =
<br><br>
.
if ($plugin eq 'extern')
{
$amps = sub { PMntextFilter::amps(@_) };
$ltgt = sub { PMntextFilter::ltgt(@_) };
$sqbr = sub { PMntextFilter::sqbr(@_) };
}
else
{
$amps = sub
{
my $amper = '&';
my $para = shift;
$para =~ s% \& %$amper%oxgm;
return $para;
};
$ltgt = sub
{
my ($lt,$gt) = ( '<','>' );
my $para = shift;
$para =~ s% \< %$lt%oxgm;
$para =~ s% \> %$gt%oxgm;
print STDERR "\n$acq\n" if $DeBug;
return $para;
};
$sqbr = sub
{
my ($sqbro,$sqbrc) =
( '[',']' );
my $para = shift;
$para =~ s% \[ %$sqbro%oxgm;
$para =~ s% \] %$sqbrc%oxgm;
print STDERR "\n$acq\n" if $DeBug;
return $para;
};
}
$pictstr = q[^] . q[<] x rCNT;
$outfm = qq[format STDOUT = ]
.qq[\n $pictstr\n]
. q[$acq] . qq[\n.\n];
eval $outfm;
die "Bad perl format!: $@" if $@;
my $splurt = sub { local $/ = qq[]; $acq = <STDIN> };
my $pc = 0;
bbegin;
while (&$splurt and $pc++ < 10000)
{
filtermeta $acq;
write while $acq;
newblk unless eof(STDIN);
}
bendin;
exit 0;
sub filtermeta
{ # Do what you want to here. Given is a minimal default.
$acq=&$amps($acq);
$acq=&$ltgt($acq);
$acq=&$sqbr($acq);
}
sub newblk
{
local $~ = "NBLK";
write;
}
sub bbegin
{
local $~ = "BBLK";
write;
}
sub bendin
{
local $~ = "EBLK";
write;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.