reduce excessive ANSI markup codes using -a - webdump - HTML to plain-text converter for webpages
(HTM) git clone git://git.codemadness.org/webdump
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8d29c76012b91bbfaad1feca31b2af4cfbc99032
(DIR) parent dc7717417afb10040e4ea5d9472cc1c2658f1c8c
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 12 Sep 2023 20:00:18 +0200
reduce excessive ANSI markup codes using -a
Diffstat:
M webdump.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
---
(DIR) diff --git a/webdump.c b/webdump.c
@@ -677,10 +677,12 @@ hflush(void)
return;
if (!nbytesline) {
- emitmarkup(0);
+ if (curmarkup)
+ emitmarkup(0);
rindent();
/* emit code again per line, needed for GNU/less -R */
- emitmarkup(curmarkup);
+ if (curmarkup)
+ emitmarkup(curmarkup);
}
for (i = 0; i < rbuflen; i++)
@@ -833,10 +835,12 @@ hputchar(int c)
ncells = 0;
} else {
if (!nbytesline) {
- emitmarkup(0);
+ if (curmarkup)
+ emitmarkup(0);
rindent();
/* emit code again per line, needed for GNU/less -R */
- emitmarkup(curmarkup);
+ if (curmarkup)
+ emitmarkup(curmarkup);
}
putchar(c);
nbytesline++;
@@ -1020,10 +1024,12 @@ printpre(const char *s, size_t len)
case '\t':
hadnewline = 0;
if (!nbytesline) {
- emitmarkup(0);
+ if (curmarkup)
+ emitmarkup(0);
rindent();
/* emit code again per line, needed for GNU/less -R */
- emitmarkup(curmarkup);
+ if (curmarkup)
+ emitmarkup(curmarkup);
}
/* TAB to 8 spaces */
@@ -1036,10 +1042,12 @@ printpre(const char *s, size_t len)
continue;
if (!nbytesline) {
- emitmarkup(0);
+ if (curmarkup)
+ emitmarkup(0);
rindent();
/* emit code again per line, needed for GNU/less -R */
- emitmarkup(curmarkup);
+ if (curmarkup)
+ emitmarkup(curmarkup);
}
putchar(*s);