-rw-r--r-- | html.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -56,24 +56,52 @@ void html_txt(char *txt) else if (c=='<') html("<"); else if (c=='&') html("&"); txt = t+1; } t++; } if (t!=txt) html(txt); } +void html_ntxt(int len, char *txt) +{ + char *t = txt; + while(*t && len--){ + int c = *t; + if (c=='<' || c=='>' || c=='&') { + *t = '\0'; + html(txt); + *t = c; + if (c=='>') + html(">"); + else if (c=='<') + html("<"); + else if (c=='&') + html("&"); + txt = t+1; + } + t++; + } + if (t!=txt) { + char c = *t; + *t = '\0'; + html(txt); + *t = c; + } + if (len<0) + html("..."); +} void html_attr(char *txt) { char *t = txt; while(*t){ int c = *t; if (c=='<' || c=='>' || c=='\'') { *t = '\0'; html(txt); *t = c; if (c=='>') html(">"); |