From: nishi Date: Thu, 1 Feb 2024 04:08:37 +0000 (+0000) Subject: made w3b ignore style tag X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=899508069c7231065c5a57b3eec07a7e73617b31;p=libw3.git made w3b ignore style tag git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@147 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/w3b/w3b.c b/Example/w3b/w3b.c index ed5d3be..39eeb3d 100644 --- a/Example/w3b/w3b.c +++ b/Example/w3b/w3b.c @@ -139,8 +139,14 @@ char* titlebuf = NULL; int nl; int start = 0; +bool style = false; + void html_handler(char* tagname, char* attr) { if(nl - start > termh - 3) return; + if(style){ + if(strcasecmp(tagname, "/style") == 0) style = false; + return; + } int oldnl = nl; if(strcasecmp(tagname, "title") == 0) { title = true; @@ -197,6 +203,8 @@ void html_handler(char* tagname, char* attr) { } else if(strcasecmp(tagname, "/h6") == 0) { if(nl >= start) printf("\n"); nl++; + }else if(strcasecmp(tagname, "style") == 0){ + style = true; } else if(strcasecmp(tagname, "img") == 0) { if(nl >= start) { char* alt = W3_Tag_Attr(attr, "alt"); @@ -230,6 +238,7 @@ void html_handler(char* tagname, char* attr) { } void text_handler(char* data) { + if(style) return; if(title) { if(titlebuf == NULL) { titlebuf = malloc(1); @@ -302,6 +311,7 @@ void render_site() { pre = false; titlebuf = NULL; nl = 0; + style = false; if(ctype != NULL && strcasecmp(ctype, "text/html") == 0) { W3_Tag_Parse(databuf, datalen, html_handler, text_handler); } diff --git a/W3Version.h.p b/W3Version.h.p index f004d37..a1a2676 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.2B" \ +#define LIBW3_VERSION "2.2C" \ SUFFIX #ifdef __cplusplus