titlecase icon indicating copy to clipboard operation
titlecase copied to clipboard

preserve input leading/trailing whitespace from beginning and end in output

Open kevinlawler opened this issue 1 year ago • 2 comments

whitespace is dropped if it is at the beginning or end. this is undesirable if using titlecase say as a method or plugin in a text editor such as vim. please preserve whitespace at beginning and end. I might prefer this to be the default behavior, but perhaps it makes sense to instead add this functionality as a flag like -w or --preserve-whitespace

input f g expected F G actual F G

or with visible spaces: input ␣␣␣␣f␣␣g␣␣␣ expected ␣␣␣␣F␣␣G␣␣␣ actual F␣␣G

kevinlawler avatar Oct 15 '24 19:10 kevinlawler

The default is always going to be whatever way John Gruber’s code behaves. But adding a switch for this seems fine. But I made the 5-line patch to implement that and all test hell failed loose: the capitalization rules expect to be operating on whole titles, and they rely on the title being trimmed to make things simpler. And I don’t want to change that code more than absolutely necessary so as not to make it harder than unavoidable to merge with upstream changes in John Gruber’s code. So this will have to be done by way of trim-then-untrim logic. Right now I have to attend to other things but I’ll get back to it.

ap avatar Oct 16 '24 01:10 ap

Woops.

ap avatar Oct 16 '24 01:10 ap