monowrap
Intelligently wrap monospaced text.
Usage
usage.txt
Usage: foo --bar --baz --bing --ring Options: --foo Is a simple test of how well the wrapping works. --bar blah blah blah blah And some fairly long text with a tab which should make it wrap to the end of that tab. 1) testing one two three four
example.js
var fs = ;var monowrap = ; var text = fs; var output = ; console;
output
Usage: foo --bar --baz --bing --ring Options: --foo Is a simple test of how well the wrapping works. --bar blah blah blah blah And some fairly long textwith a tab which should make it wrap to the end of that tab. 1) testing one two three four
If you just want to wrap text to a specific width, leaving all the other options at their default values, you can pass a number as the second parameter instead of an options map.
;// Is the same as...;
Notes
Line endings are always normalized. The type will be automatically detected unless overridden by setting the "eol" option.
Tabs will be replaced with spaces.
Indentation is maintained to the last tab stop.