package xm::colontags;
use xm::o;
"
look for <:tag whatever> markups and replace the sequence before
with the one surrounded by the given tag. examples:
\"abc\"<:em> -> <em>abc</abc>
\'abc\'<:em> -> <em>abc</abc>
http:see\@there<:em> -> <em>http:see\@there</abc>
see abc <:em> -> <em> see abc </abc> ... the complete line
"}
my $in = shift;
my $max;
$max = 100; while (--$max and $in =~
s{ ^ (\s*) <(\w[^<>]*):> (.*) $ }
{
$1.$3." <:".$2.">".$4
}gmex) {};
$max = 100; while (--$max and $in =~
s{ \" ([^\"\<\>]*) \" <:(\w[^\s<>]*)([^<>]*>|\s*\n?[^<>]*>) }
{
"<".$2.$3.$1."</".$2.">"
}gmex) {};
# if there is a sgl-quoted-text just before, use only that one
$max = 100; while (--$max and $in =~
s{ \' ([^\'\<\>]*) \' <:(\w[^\s<>]*)([^<>]*>|\s*\n?[^<>]*>) }
{
"<".$2.$3.$1."</".$2.">"
}gmex) {};
# and for a single word ... enough charspan given for an url...
$max = 100; while (--$max and $in =~
s{ \b (\w[\:\/\.\-\+\@\w]+) \b <:(\w[^\s<>]*)([^<>]*>|\s*\n?[^<>]*>) }
{
"<".$2.$3.$1."</".$2.">"
}gmex) {};
# and finally, expand as a line tag...
$max = 1000; while (--$max and $in =~
s{ ^ ((?:.(?!<:\w[^<>]*>))*\s) <:(\w[^\s<>]*)([^<>]*>|\s*\n?[^<>]*>) }
{
"<".$2.$3.$1."</".$2.">"
}mex) {};
return $in;
}
return xm::o::args_stdin(@_, DESC); }
return DO(xm::o::args_stdin(@_, DESC)); }
1;