Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions tests/csi-k.sh
Original file line number Diff line number Diff line change
@@ -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, <span style="font-weight:bold;">Bold</span> 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