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

Re: [Clip] Re: stripping image tags

Expand Messages
  • 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 1 of 8 , Aug 28, 2000
    View Source
    • 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 2 of 8 , Aug 30, 2000
      View Source
      • 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 3 of 8 , Sep 7, 2000
        View Source
        • 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.