Remove HTML function

jbv jbv.silences at club-internet.fr
Sat May 18 15:20:01 EDT 2002


> > Does anyone have a script to removing HTML from a string/chunk/whole file?
>

I think the following is safer, coz I've often seen javascript code
after the body :

function html2text htmlRaw
  # trim all html tag
  put offset("<body",htmlRaw) into bodyStart
  if bodyStart > 0 then
    delete char 1 to (bodyStart -1) of htmlRaw
  end if

  put offset("</body",htmlRaw) into bodyEnd
  if bodyEnd > 0 then
    put char 1 to (bodyEnd -1) of htmlRaw into htmlRaw
  end if

  replace "<br>" with cr in htmlRaw
  replace "<p>" with cr in htmlRaw
  repeat
    put offset("<",htmlRaw) into sTag
    if sTag = 0 then exit repeat
    put offset(">",htmlRaw) into eTag
    delete char sTag to eTag of htmlRaw
  end repeat
  return htmlRaw
end html2text


JB





More information about the metacard mailing list