include in Neovim
A function(s) for converting from ANSI color/style codes to Vim highlights (and also an option which just scrubs/removes the codes) would be useful to include in Nvim itself.
The :Man plugin that ships with Nvim does something similar though it's not complete.
So this could become a global Lua function, e.g. vim.parse_termcodes().
(For reference, :help nvim_replace_termcodes() already exists for other purposes).
I've hoped for some library being used here already, and not doing it "manually".
Could libvterm be used for this? (which only understands TERM=xterm though AFAIK).
In the end it would be great to have something that really understands the information provided via the terminal database (infocmp). But of course not all of it would need to be handled. It would just use it to query what code is used e.g. for "underline" (smul) etc.
@blueyed yes, I agree, I don't want to reimplement everything from scratch. I keep using the word "color" because that's the subset I figured would be most useful and the part that I implemented first, and concealed everything so that terminal output could be at least viewed as a baseline as if it had been stripped with functionality being added gradually.
The way I've implemented it, it could be easily modified to use an external library/function from ffi or lua by hooking into the implementation of parse_color_code which is responsible for updating the definition of highlight commands (cterm/ctermfg/etc...). Currently, if there's an error or something it has less confidence in, it will skip it, which makes it capable of being incrementally improved.
I'll be improving this as soon as I can, but I also have other things I want/need to do.