Loading ...
Sorry, an error occurred while loading the content.

stripping image tags

Expand Messages
  • bill.poole@tpl.org
    Can someone supply a clip for stripping HTML image tags only from a document? This may be in one of the supplied libraries, but I have been unable to find it.
    Message 1 of 8 , Aug 18, 2000
    • 0 Attachment
      Can someone supply a clip for stripping HTML image tags only from a document?
      This may be in one of the supplied libraries, but I have been unable to find it.

      Thanks for your help.

      Bill Poole
      Associate Director, Public Affairs
      Trust for Public Land
      bill.poole@...
      415 495-4014
      fax 415 495-0540
      http://www.tpl.org
    • Jody
      Hi Bill, ... You do not need a Clip for that. Focus the document, on the main menu click on Modify | Strip HTML and choose and Option. Happy Clip n! Jody
      Message 2 of 8 , Aug 18, 2000
      • 0 Attachment
        Hi Bill,

        >Can someone supply a clip for stripping HTML image tags only from
        >a document? This may be in one of the supplied libraries, but I
        >have been unable to find it.

        You do not need a Clip for that. Focus the document, on the main
        menu click on Modify | Strip HTML and choose and Option.

        Happy Clip'n!
        Jody

        http://www.sureword.com/notetab

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@...
        mailto:Ntb-Clips-UnSubscribe@...
        http://www.egroups.com/group/ntb-clips
      • Stephen Riddle
        ... Oh Phooey!! And I just spent a happy two hours figuring out how to do it. I created it to where it could be selectively used for other tags too. Oh well,
        Message 3 of 8 , Aug 19, 2000
        • 0 Attachment
          --- In ntb-clips@egroups.com, Jody <KJB1611@a...> wrote:
          > Hi Bill,
          >
          > >Can someone supply a clip for stripping HTML image tags only from
          > >a document?
          > You do not need a Clip ... Focus the document, on the main
          > menu click on Modify | Strip HTML and choose and Option.
          >
          > Happy Clip'n!
          > Jody
          Oh Phooey!!
          And I just spent a happy two hours figuring out how to do it. I
          created it to where it could be selectively used for other tags too.
          Oh well, here it is:

          ;**************Begin Clip************

          H="Strip one kind of tag"

          ;This clip uses regular expressions to remove
          ; all occurances of any particular tag in a document.
          ^!Set %tag%=^?[Which element would you like to remove from the
          document?]
          ^!Replace (<^%tag%{.*}>) ^%EMPTY% ATIWRS
          ;If it is not an empty tag, search and replace the endtag.
          ^!Replace (</^%tag%{.*}>) ^%EMPTY% ATIWRS


          ;*************End Clip*******************


          I shoulda' known there was an easier way.

          Stephen
        • Jody
          Hi Stephen, ... Actually, I read his post wrong skipping over image even though it was also in the Subject. Your method is probably faster and requires less
          Message 4 of 8 , Aug 19, 2000
          • 0 Attachment
            Hi Stephen,

            >Oh Phooey!!

            Actually, I read his post wrong skipping over "image" even though
            it was also in the Subject. Your method is probably faster and
            requires less lines, plus gives me yet one more RegExp to study. ;)

            >^!Set %tag%=^?[Which element would you like to remove from the
            >document?]
            >^!Replace (<^%tag%{.*}>) ^%EMPTY% ATIWRS
            >;If it is not an empty tag, search and replace the endtag.
            >^!Replace (</^%tag%{.*}>) ^%EMPTY% ATIWRS


            Happy Clip'n!
            Jody

            http://www.sureword.com/notetab

            Subscribe, UnSubscribe, Options
            mailto:Ntb-Clips-Subscribe@...
            mailto:Ntb-Clips-UnSubscribe@...
            http://www.egroups.com/group/ntb-clips
          • Eb Guenther
            Hi Stephen, ... Sorry to put a damper on your happyness, Stephen, but your clip only works as expected if there are no other tags on the same line. Regular
            Message 5 of 8 , Aug 19, 2000
            • 0 Attachment
              Hi Stephen,

              >And I just spent a happy two hours figuring out how to do it. I
              >created it to where it could be selectively used for other tags too.
              >...
              >H="Strip one kind of tag"
              >^!Set %tag%=^?[Which element would you like to remove from the document?]
              >^!Replace (<^%tag%{.*}>) ^%EMPTY% ATIWRS
              >;If it is not an empty tag, search and replace the endtag.
              >^!Replace (</^%tag%{.*}>) ^%EMPTY% ATIWRS

              Sorry to put a damper on your happyness, Stephen, but your clip
              only works as expected if there are no other tags on the same line.

              Regular expressions are greedy and will grab EVERYTHING that
              matches.

              Your regexp above will match everything from the beginning of
              the desired tag to the LAST ">" on the same line.

              For example:
              ^!Replace (<IMG{.*}>) ^%EMPTY% ATIWRS
              will replace

              [<h2><a href="menu.html"><img src="pic.gif">Click Here</a></h2>]

              with

              [<h2><a href="menu.html">]



              Change your regexp to

              ^!Replace (<IMG[^>]*>) ^%EMPTY% ATIWRS

              where the "[^>]" says anything BUT ">", which selects
              the entire opening tag up to, but not including the
              ">", which is then specified as the next single character.

              Treat both your opening and closing tags this way.

              Good luck,


              Eb
            • Stephen Riddle
              EB, Darn and double darn, not only is there an easy and built in way to strip the tags, but if you happen to format stuff different than I do. . . I ll just
              Message 6 of 8 , Aug 28, 2000
              • 0 Attachment
                EB,
                Darn and double darn, not only is there an easy
                and built in way to strip the tags, but if you
                happen to format stuff different than I do. . .
                I'll just have to look for happiness elsewhere.
                Thanks
                Stephen

                ______________________________________________________
                Get your free web-based email at http://www.xoom.com
                Birthday? Anniversary? Send FREE animated greeting
                cards for any occasion at http://greetings.xoom.com
              • Stephen Riddle
                Hi Bill, Jody, Eb and whomever, ... document? ... to find it. ... I was insecure with the results I got from regular expressions. Eventually, I hope they
                Message 7 of 8 , Aug 30, 2000
                • 0 Attachment
                  Hi Bill, Jody, Eb and whomever,
                  --- In ntb-clips@egroups.com, bill.poole@t... wrote:
                  > Can someone supply a clip for stripping HTML image tags only from a
                  document?
                  > This may be in one of the supplied libraries, but I have been unable
                  to find it.
                  >
                  > Thanks for your help.
                  >
                  > Bill Poole

                  I was insecure with the results I got from regular expressions.
                  Eventually, I hope they "take", but apparently not yet. I also like
                  flexible clips.
                  However, I am happy again. I created the following clip, tested it
                  under horrendous conditions. It works with any tag, but is
                  pre-selected to img tags so Bill will be happy. It compensates for
                  white space both before and after the element string in a tag. I kept
                  thinking of different conditions for it to work with and think I have
                  gone to the point of diminishing returns. It is about fifty-six lines
                  long with a couple of long lines, but seems to work pretty quickly
                  anyhow.

                  H="Strip-a-tag"

                  ;<!-- ---StartClipBody---- -->
                  ;This clip created with loving care and not a little bit of cussin'
                  ; by Stephen Riddle: Esselare@...
                  ; This clip removes all instances of any
                  ; element from an HTML document.
                  ; First determine which tag we will strip
                  ^!Set %tag%=^?[Which element would you like to remove from the
                  document?=!--|a|abbr|acronym|address|applet|area|b|base|basefont|bdo|b
                  gsound|big|blink|blockquote|body|br|button|caption|center|cite|code|co
                  l|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|font|for
                  m|frame|frameset|h1|h2|h3|h4|h5|h6|head|hr|html|i|iframe|ilayer|_img|i
                  nput|ins|isindex|kbd|keygen|label|layer|legend|li|link|map|marquee|men
                  u|meta|nobr|noembed|noframes|nolayer|noscript|object|ol|optgroup|optio
                  n|p|param|pre|q|s|samp|script|select|server|small|spacer|span|strike|s
                  trong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt
                  |u|ul|var|wbr]
                  ;Get the entire document.
                  ^!Set %output%=^$GetText$
                  ;Assign variables for various reasons.
                  ^!Set %plaintag%=^%tag%>
                  ^!Set %tag%=^%tag%^%SPACE%
                  ^!Set %testtagone%=/^%tag%
                  ^!Set %testtagtwo%=/^%plaintag%

                  :whitespace
                  ;Define a loop to remove white space between an opening
                  ; angle bracket and element names.
                  ;replace all instances of "< " with "<"
                  ^!Set %output%=^$StrReplace("< ";"<";"^%output%";FALSE;TRUE)$
                  ^!Set %output%=^$StrReplace("<^P";"<";"^%output%";FALSE;TRUE)$
                  ^!If ^$StrPos("< ";^%output%;FALSE)$=0 ripper ELSE whitespace
                  ^!If ^$StrPos("<^P";^%output%;FALSE)$=0 ripper ELSE whitespace

                  ; Define a loop to replace all occurences of the tag.
                  :ripper
                  ^!If ^$StrPos("<^%tag%";^%output%;FALSE)$=0 endtag ELSE NEXT
                  ^!Set %checker%=^$StrPos("<^%tag%";^%output%;FALSE)$
                  ; Locate the next instance of ">"
                  ^!Set %mater%=^$StrPosMid(">";"^%output%";^%checker%;FALSE)$
                  ; Assign the everything from the open brace to the end brace to a
                  string.
                  ^!Set
                  %captor%=^$StrCopy("^%output%";^%checker%;^$Calc(^%mater%-^%checker%+1
                  )$)$
                  ; Delete all instances of the string.
                  ^!Set
                  %output%=^$StrReplace("^%captor%";"^%EMPTY%";"^%output%";FALSE;TRUE)$
                  ; Test if there are more instances of the tag.
                  ^!If ^$StrPos("<^%tag%";^%output%;FALSE)$=0 endtag ELSE ripper

                  :endtag
                  ^!Set %tag%=/^%tag%

                  ; This loop does the same thing as the previous loop except it's for
                  an endtag if there is one.
                  :endripper
                  ^!If ^$StrPos("<^%tag%";^%output%;FALSE)$=0 tosimple ELSE NEXT
                  ^!Set %checker%=^$StrPos("<^%tag%";^%output%;FALSE)$
                  ; Locate the next instance of ">"
                  ^!Set %mater%=^$StrPosMid(">";"^%output%";^%checker%;FALSE)$
                  ; Assign the everything from the open brace to the end brace to a
                  string.
                  ^!Set
                  %captor%=^$StrCopy("^%output%";^%checker%;^$Calc(^%mater%-^%checker%+1
                  )$)$
                  ; Delete all instances of the string.
                  ^!Set
                  %output%=^$StrReplace("^%captor%";"^%EMPTY%";"^%output%";FALSE;TRUE)$
                  ; Test if there are more instances of the tag.
                  ^!If ^$StrPos("<^%tag%";^%output%;FALSE)$=0 tosimple ELSE endripper

                  :tosimple
                  ^!IfSame ^%tag% ^%testtagtwo% finish else NEXT
                  ^!Set %tag%=^%plaintag%
                  ^!GoTo ripper

                  :finish
                  ; Clear the original document, replace it with the new and improved.
                  ^!Toolbar Clear All
                  ^!InsertHtml ^%output%
                  ;<!-- ---EndClipBody---- -->


                  So there it is,
                  Have lots of fun with it,
                  Stephen
                • Jody
                  Hi Stephen, ... It works good Stephen. thanks! Above is one of those places where Join Lines will not work to remove the breaks that were added in the mail.
                  Message 8 of 8 , Sep 7, 2000
                  • 0 Attachment
                    Hi Stephen,

                    >H="Strip-a-tag"
                    >
                    >;<!-- ---StartClipBody---- -->
                    >;This clip created with loving care and not a little bit of cussin'
                    >; by Stephen Riddle: Esselare@...
                    >; This clip removes all instances of any
                    >; element from an HTML document.
                    >; First determine which tag we will strip
                    >^!Set %tag%=^?[Which element would you like to remove from the
                    >document?=!--|a|abbr|acronym|address|applet|area|b|base|basefont|bdo|b
                    >gsound|big|blink|blockquote|body|br|button|caption|center|cite|code|co
                    >l|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|font|for
                    >m|frame|frameset|h1|h2|h3|h4|h5|h6|head|hr|html|i|iframe|ilayer|_img|i
                    >nput|ins|isindex|kbd|keygen|label|layer|legend|li|link|map|marquee|men
                    >u|meta|nobr|noembed|noframes|nolayer|noscript|object|ol|optgroup|optio
                    >n|p|param|pre|q|s|samp|script|select|server|small|spacer|span|strike|s
                    >trong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt
                    >|u|ul|var|wbr]

                    It works good Stephen. thanks! Above is one of those places
                    where Join Lines will not work to remove the breaks that were
                    added in the mail. Each line has to be joined manually using the
                    backspace key or use the Replace tool "^p" >> "" H. ;)

                    There were some other places too that had to be done manually
                    with the functions else a space would be left when joining where
                    you do not want it causing the Clip to fail.

                    Happy Clip'n!
                    Jody

                    http://www.sureword.com/notetab

                    Subscribe, UnSubscribe, Options
                    mailto:Ntb-Clips-Subscribe@...
                    mailto:Ntb-Clips-UnSubscribe@...
                    http://www.egroups.com/group/ntb-clips
                  Your message has been successfully submitted and would be delivered to recipients shortly.