Here's a quick solution built with the "html" procedures in the IPL:

# rmimg.icn
link html
procedure main()
    every c := htchunks(&input) do
        match("<img", map(c)) | writes(c)
end

It's plain old Icon so you can build it with 'icont rmimg.icn' or 'unicon
rmimg.icn'.  It reads standard input and writes the stripped version to
standard output.  Example:

        rmimg < x.htm >x2.htm

Here's a more general version that strips tags named on the command line:

# rmtag.icn
link html
procedure main(args)
    every c := htchunks(&input) do
        match("<"||map(!args), map(c)) | writes(c)
end

Usage:

        rmtag p img input < x.htm > x2.htm

NOTE THAT htchunks() elides HTML comments.

Note also that rmtag isn't too smart -- a command line argument like "p"
gets <param ...> tags as as well as paragraph tags.  (I'll call that a
feature and leave smarter behavior as an exercise.)

p.s.
Thanks to Gregg Townsend for writing the html procs in the IPL. 


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to