Closed Toflar closed 8 years ago
Not easily possible, in my mind. I think this and #26, #16, #14 are all roughly similar. Those control codes expect to mutate the state of some hardware on the other end (the terminal). Whereas, this just provides static string output.
I think there's two situations you have to deal with when you see a control code that modifies existing content.
1) the content has already been returned from a previous call to .toHtml(). 2) the content to be modified, is contained in the current call to .toHtml() and has yet to be returned.
You might imagine handling case 2 internally, and being able to pass in a user provided 'mutate' option: a function which gets called with some agreed upon parameters to handle situation 1. That function probably ties into some non-trivial use-case specific machinery possibly involving client side code and websockets (as an example).
I wouldn't think that approach accommodates all the control codes of that variety. But, might get you things like deleting lines and characters. Having talked through that. I'm not sure you could get it to work reliably. But, it's my best guess at the moment.
Updating ansi-to-html to explicitly strip these codes (if it's not already doing it), is a good idea. supposing it's not possible to handle them.
I see, thanks for taking the time to reply! Very much appreciated!
We should probably have the option to have those lines removed entirely from the html if they would also have been cleared in the terminal
Hi!
Thanks for the great project! I'm currently considering using it and it works perfectly fine except for one thing! I want to output console information of a command executed using the PHP Framework Symfony. Symfony does support progress bars which is extremely helpful for longer running processes. See the manual for more information and an animated gif.
The used ansi codes can be checked out here: https://github.com/symfony/console/blob/master/Helper/ProgressBar.php#L480-L487
Do you think implementing this would be even possible?