webdump

Fork of git://git.codemadness.org/webdump
git clone git://git.z3bra.org/webdump.git
Log | Files | Refs | README | LICENSE

commit 20864299480293458c69c4ba3506289d0077042d
parent a0685543b462a0d1f1cffda7a117a95662fcfdcf
Author: Willy Goiffon <dev@z3bra.org>
Date:   Wed,  9 Oct 2019 11:29:35 +0200

Translate semantic tags to ANSI escapes

Diffstat:
webdump.c | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/webdump.c b/webdump.c @@ -516,6 +516,15 @@ xmltagstart(XMLParser *x, const char *t, size_t tl) break; } } + if (!strcasecmp(cur->tag, "b")) printf("\033[1m"); + if (!strcasecmp(cur->tag, "strong")) printf("\033[1m"); + if (!strcasecmp(cur->tag, "i")) printf("\033[3m"); + if (!strcasecmp(cur->tag, "em")) printf("\033[3m"); + if (!strcasecmp(cur->tag, "u")) printf("\033[4m"); + if (!strcasecmp(cur->tag, "br")) { + curnode--; + printf("\n"); + } } static void @@ -551,6 +560,12 @@ xmltagend(XMLParser *p, const char *t, size_t tl, int isshort) putchar('='); putchar('\n'); } + } else if (cur->displaytype & DisplayInline) { + if (!strcasecmp(t, "b")) fputs("\033[0m", stdout); + if (!strcasecmp(t, "strong")) fputs("\033[0m", stdout); + if (!strcasecmp(t, "i")) fputs("\033[0m", stdout); + if (!strcasecmp(t, "em")) fputs("\033[0m", stdout); + if (!strcasecmp(t, "u")) fputs("\033[0m", stdout); } else if (!strcasecmp(t, "br")) { fputs("\n", stdout); }