com-lihaoyi / fansi

Scala/Scala.js library for manipulating Fancy Ansi colored strings
Other
226 stars 26 forks source link

Parsing standard-conform ansi encodings from other applications #22

Open mpollmeier opened 4 years ago

mpollmeier commented 4 years ago

Fansi doesn't currently parse many standard-conform ansi encoded strings. E.g. we're using source-highlight to render coloured sourcecode, which on the terminal renders nicely coloured text:

echo "if" > if.c
source-highlight-esc.sh if.c

So that we can display the output with fansi, I came up with four regexes to preprocess the ansi-encoded Strings before handing them to fansi.Str.apply. The comments give an example for each of the four differences, and tests are at https://github.com/ShiftLeftSecurity/codepropertygraph/blob/9a7b743/console/src/test/scala/io/shiftleft/console/PPrinterTest.scala

Would you like fansi to handle those standard-conform ansi encoded Strings, or rather make it a non-goal and not have the complexity in the parsing logic?

lihaoyi commented 2 years ago

This seems like something that Fansi should be able to handle. If there's a clear spec for what the escapes should look like, we should implement it and add a comment to the implementation linking back to the spec