diff --git a/src/main.c b/src/main.c index 23e9d49..b6f8881 100644 --- a/src/main.c +++ b/src/main.c @@ -264,6 +264,11 @@ just_strip_it(bool ignore_sgr_errors) { state = STATE_TEXT; } + else if (c == 'K') + { + // Ignore "Erase in Line" sequence. + state = STATE_TEXT; + } else { if (ignore_sgr_errors) @@ -519,6 +524,16 @@ static inline __attribute__((always_inline)) void ansi2html( ); span_outputted = false; } + else if (c == 'K') + { + // Ignore "Erase in Line" sequence. + state = STATE_TEXT; + if (span && !span_outputted) + { + append_to_buffer(span); + span_outputted = true; + } + } else { // The character should be a digit, or semicolon. diff --git a/tests/csi-k.sh b/tests/csi-k.sh new file mode 100755 index 0000000..f7fb9c0 --- /dev/null +++ b/tests/csi-k.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +. "$(dirname "$0")/".functions.sh + +# CSI K is a no-op when stripping OR converting to HTML +str=$'Hello, \e[0;1mBold\e[K\e[0m world!' +want=$'Hello, Bold world!' +got=$(printf '%s' "$str" | ./ansi2html -p vga) +str_eq_html "$str" "$want" "$got" + +want=$'Hello, Bold world!' +got=$(printf '%s' "$str" | ./ansi2html -S) +str_eq_html "$str" "$want" "$got" + +done_testing