Skip to content

Commit 16d4076

Browse files
Gyorgy Morapixelb
authored andcommitted
ansi2html.sh: handle truecolor froeground/background escapes
1 parent 8cff543 commit 16d4076

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scripts/ansi2html.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Handle codes with combined attributes and color.
3333
# Handle isolated <bold> attributes with css.
3434
# Strip more terminal control codes.
35-
# V0.23, 28 Feb 2016
35+
# V0.24, 14 Sep 2017
3636
# http://github.com/pixelb/scripts/commits/master/scripts/ansi2html.sh
3737

3838
gawk --version >/dev/null || exit 1
@@ -235,6 +235,12 @@ sed "
235235
# escape HTML (ampersand and quote done above)
236236
s#>#\&gt;#g; s#<#\&lt;#g;
237237
238+
# handle truecolor
239+
s#${p}38;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
240+
<span style=\"color:rgb(\1\,\2\,\3\)\">#g
241+
s#${p}48;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
242+
<span style=\"background-color:rgb(\1\,\2\,\3\)\">#g
243+
238244
# normalize SGR codes a little
239245
240246
# split 256 colors out and mark so that they're not

0 commit comments

Comments
 (0)