function stripHTML(document,fieldname)
       str = document:getFieldValue(fieldname)
       if str ~=nil then
           mylog("str is not nil");
               str = string.gsub(str,"<.->","")        
               str=stripBlank(str);
               str = convertEntities(str)
               --mylog("str========\n"..str);
               document:setFieldValue(fieldname, str)
      else
         mylog("str is  nil");
      end           
end
--strip the blank lines
function stripBlank(str)
     str = string.gsub(str,"(\n+)","\n")
     return str;
end
function convertEntities(str)  
 local entities =
{
    -- chinese entities,I get it from 
http://www.w3schools.com/HTML/html_entities.asp    --your lua scipts file should save in u8-dos,otherwise some code here will convert into question mark
    nbsp = " ",
    lt = "<",
    gt = ">",
    amp = "&",
}
       str = string.gsub(str, "&(%a+);",entities)
       return str
end
function stripHTML(document,fieldname)
       str = document:getFieldValue(fieldname)
       if str ~=nil then
           mylog("str is not nil");
               str = string.gsub(str,"<.->","")        
               str=stripBlank(str);
               str = convertEntities(str)
               --mylog("str========\n"..str);
               document:setFieldValue(fieldname, str)
      else
         mylog("str is  nil");
      end           
end
--strip the blank lines
function stripBlank(str)
     str = string.gsub(str,"(\n+)","\n")
     return str;
end
function convertEntities(str)  
 local entities =
{
    -- chinese entities,I get it from 
http://www.w3schools.com/HTML/html_entities.asp    --your lua scipts file should save in u8-dos,otherwise some code here will convert into question mark
    nbsp = " ",
    lt = "<",
    gt = ">",
    amp = "&",
}
       str = string.gsub(str, "&(%a+);",entities)
       return str
end
function stripHTML(document,fieldname)
       str = document:getFieldValue(fieldname)
       if str ~=nil then
           mylog("str is not nil");
               str = string.gsub(str,"<.->","")        
               str=stripBlank(str);
               str = convertEntities(str)
               --mylog("str========\n"..str);
               document:setFieldValue(fieldname, str)
      else
         mylog("str is  nil");
      end           
end
--strip the blank lines
function stripBlank(str)
     str = string.gsub(str,"(\n+)","\n")
     return str;
end
function convertEntities(str)  
 local entities =
{
    -- chinese entities,I get it from 
http://www.w3schools.com/HTML/html_entities.asp    --your lua scipts file should save in u8-dos,otherwise some code here will convert into question mark
    nbsp = " ",
    lt = "<",
    gt = ">",
    amp = "&",
}
       str = string.gsub(str, "&(%a+);",entities)
       return str
end