ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

white-space:nowrap #39

Closed ozgurakgun closed 8 years ago

ozgurakgun commented 8 years ago

Using style="white-space:nowrap;" for flags, so they do not get broken into multiple lines.

For example, I had html output where "-o" was being broken into multiple lines. That doesn't look good at all.

I am checking the first non-whitespace character of the contents of the td tag to detect flags. If the first character is '-', it is assumed to be a flag. I am not sure if this is the best way of implementing this, but it seems to work good enough.

ndmitchell commented 8 years ago

Thanks, I'll review this tomorrow with the other patch.

ozgurakgun commented 8 years ago

Thanks! I thought I would submit this too before you looked into the other one, to save you some time. A small bit of economies of scale, hopefully.

ndmitchell commented 8 years ago

So you mean -o was being line wrapped so the line break occurred between the - and the o? I agree, that looks terrible. I guess this is because HTML considers - to be a hyphen, and we want it to be a non-breaking hyphen (but not in reality, since then people copying and pasting would get garbage on their console). Given that, seems thoroughly sensible.

ndmitchell commented 8 years ago

I've added a comment explaining the line wrap thing in the code, so I don't accidentally decide to remove it one day.

Thanks for your contributions. Do you have other things in the immediate pipeline? If not, I'll make a minor release containing these fixes.

ozgurakgun commented 8 years ago

Now that the '\n' issue (#18) is solved for textual output, maybe we can add a <br /> tag for newlines in the html output. Let me have a look and get back to you.

ndmitchell commented 8 years ago

Yep, that makes a lot of sense.

For info, an alternative way to solve the -o thing would have been to do our own words splitting, and when we see a word that disagrees with HTML's definition, e.g. -o, then wrap it in <span style=wrap-style:none> tags. It's a theoretically cleaner solution, but might generate a little verbose HTML, so I'm fine with either trade-off.