Tried to add a few style thingies back into the renderer
authorArt Cancro <ajc@citadel.org>
Wed, 21 Sep 2022 23:13:45 +0000 (19:13 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 21 Sep 2022 23:13:45 +0000 (19:13 -0400)
libcitadel/lib/html_to_ascii.c

index 2d604ac4fa3ab250519e022fca2d988f8bf3aaaf..33373c19d3c44cd4f75a28d2a457f09ba3d3e12c 100644 (file)
@@ -185,34 +185,52 @@ char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int ansi)
                                        strcat(outbuf, nl);
                                }
 
-#if 0
-       These seemed like a good idea at the time, but it just makes a mess.
-
                                else if (
                                        (!strcasecmp(tag, "B"))
-                                       || (!strcasecmp(tag, "/B"))
                                        || (!strcasecmp(tag, "STRONG"))
+                               ) {
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[1m");
+                                       }
+                               }
+                               else if (
+                                       (!strcasecmp(tag, "/B"))
                                        || (!strcasecmp(tag, "/STRONG"))
                                ) {
-                                       strcat(outbuf, "*");
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[22m");
+                                       }
                                }
 
                                else if (
                                        (!strcasecmp(tag, "I"))
-                                       || (!strcasecmp(tag, "/I"))
                                        || (!strcasecmp(tag, "EM"))
-                                       || (!strcasecmp(tag, "/EM"))
                                ) {
-                                       strcat(outbuf, "/");
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[3m");
+                                       }
                                }
 
                                else if (
-                                       (!strcasecmp(tag, "U"))
-                                       || (!strcasecmp(tag, "/U"))
+                                       (!strcasecmp(tag, "/I"))
+                                       || (!strcasecmp(tag, "/EM"))
                                ) {
-                                       strcat(outbuf, "_");
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[23m");
+                                       }
+                               }
+
+                               else if (!strcasecmp(tag, "U")) {
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[4m");
+                                       }
+                               }
+
+                               else if (!strcasecmp(tag, "/U")) {
+                                       if (ansi) {
+                                               strcat(outbuf, "\033[24m");
+                                       }
                                }
-#endif
 
                                else if (!strcasecmp(tag, "BR")) {
                                        strcat(outbuf, nl);