Roxen.git / server / modules / filters / whitespace_remover.pike

version» Context lines:

Roxen.git/server/modules/filters/whitespace_remover.pike:1:   // This is a roxen module. Copyright © 2000 - 2009, Roxen IS.      inherit "module";    - constant cvs_version = "$Id: whitespace_remover.pike,v 1.8 2009/05/07 14:15:54 mast Exp $"; + constant cvs_version = "$Id$";   constant thread_safe = 1;   constant module_type = MODULE_FILTER;   constant module_name = "Whitespace Remover";   constant module_doc = "Removes all whitespace from pages.";      void create() {       defvar("comment",    Variable.Flag(0, 0, "Strip HTML comments",    "Removes all <!-- --> type of comments") );
Roxen.git/server/modules/filters/whitespace_remover.pike:52:    return ({ p->current() });   }      mapping filter(mapping result, RequestID id)   {    if(!result)    return 0;    string|array(string) type = result->type;    if (arrayp(type))    type = type[0]; -  if(!has_prefix(type||"", "text/html") -  || (id->misc->moreheads && id->misc->moreheads["Content-Type"] && -  id->misc->moreheads["Content-Type"] != "text/html") -  || !stringp(result->data) -  || id->prestate->keepws -  || id->misc->ws_filtered++) +  if (!type || +  !has_prefix(type, "text/html") && +  !has_prefix(type, "text/xml") && +  !has_prefix(type, "application/xml") && +  !has_suffix(type, "+xml"))    return 0; -  +  type = (id->misc->moreheads && id->misc->moreheads["Content-Type"]); +  if (type && +  !has_prefix(type, "text/html") && +  !has_prefix(type, "text/xml") && +  !has_prefix(type, "application/xml") && +  !has_suffix(type, "+xml")) +  return 0; +  if (!stringp(result->data) || +  id->prestate->keepws || +  id->misc->ws_filtered++) +  return 0;       Parser.HTML parser = Parser.HTML();    foreach(query("verbatim"), string tag)    parser->add_container( tag, verbatim );    parser->add_quote_tag("!--", query("comment")&&"", "--");    parser->_set_data_callback( remove_consecutive_whitespace );    result->data = parser->finish( result->data )->read();    return result;   }