Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display spaces #51

Open
mark-spurgeon opened this issue Mar 8, 2019 · 5 comments
Open

Add option to display spaces #51

mark-spurgeon opened this issue Mar 8, 2019 · 5 comments

Comments

@mark-spurgeon
Copy link

Hi,
I know html does not take into account spaces in text, but sometimes ansi text only displays correctly when we include spaces.
I needed to display log info in html, so I added a 'spaces' option that replaces spaces with 'span' tags that have a width of 0.6em. Implementation is pretty easy, but it's also pretty much hacking, which is why I'm not doing a pull request.
But do you think that may be a good feature ? And would there be a better way to do it?

@rburns
Copy link
Owner

rburns commented Mar 14, 2019

@the-duck having a toggle to preserve spaces seems reasonable. maybe outputting it as an html entity (` ') is a better option than a span element.

It's related to the existing configuration option for preserving newlines. (https://github.com/rburns/ansi-to-html/blob/master/README.md#options) It would be tempting to preserve spaces and newlines in one config key. Though, the newlines key behaviour would need to be unchanged for compatibility.

Possibly the existing newlines key and an additional spaces key. or alternatively the existing newlines key and an additional whitespace key that does both. Not certain which would be most useful.

@brettz9
Copy link
Contributor

brettz9 commented May 22, 2019

Or how about newlines, spaces, and a setting whitespace that does both?

Just in case one wishes XML support,   would be a little safer than   which may only be supported in HTML (HTML supports either).

Am eager to have an option to auto-generate CLI docs (using command-line-usage), and preserving spacing is critical for this. But your tool otherwise looks to be doing the job quite nicely!

@rburns
Copy link
Owner

rburns commented May 22, 2019

Either of those solutions are likely fine. (three config keys, or two). I struggle to imagine a scenario where you would want spaces preserved, but not newlines, or the opposite.

I guess a whitespace key would have to take into account not only spaces and newlines, but also other whitespace characters like tabs.

Makes me think newlines and whitespace would be enough. For example, adding a tabs key in addition to newlines and spaces wouldn't make a lot of sense.

@brettz9 brettz9 mentioned this issue May 22, 2019
@brettz9
Copy link
Contributor

brettz9 commented May 22, 2019

In my PR #57 , I've just added a tabs option as well, as I do think it's utility as a separate preference can be in using it to indicate the number of non-breaking spaces that each tab should be converted into.

@brettz9
Copy link
Contributor

brettz9 commented May 22, 2019

Though of course whatever API you prefer--just demoing the idea...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants