link stripunb
May 2, 2001; Richard L. Goerwitz
This file is in the public domain.
This routine strips material from a line which is unbalanced with
respect to the characters defined in arguments 1 and 2 (unbalanced
being defined as bal() defines it, except that characters preceded
by a backslash are counted as regular characters, and are not taken
into account by the balancing algorithm).
One little bit of weirdness I added in is a table argument. Put
simply, if you call stripunb() as follows,
stripunb('<','>',s,&null,&null,t)
and if t is a table having the form,
key: "bold" value: outstr("\e[2m", "\e1m")
key: "underline" value: outstr("\e[4m", "\e1m")
etc.
then every instance of "<bold>" in string s will be mapped to
"\e2m," and every instance of "</bold>" will be mapped to "\e[1m."
Values in table t must be records of type output(on, off). When
"</>" is encountered, stripunb will output the .off value for the
preceding .on string encountered.