jonschlinkert / word-wrap

Wrap words to a specified length.
https://github.com/jonschlinkert
MIT License
194 stars 57 forks source link

Feature Request: param "Ignore" based on pattern #12

Closed mm-gmbd closed 7 years ago

mm-gmbd commented 8 years ago

A handy feature would be to ignore wrapping based on whether or not the line in the string that was being processed matched a certain pattern (or a pattern in an array of patterns).

My use case is that I have a large block of markdown text that is stored as a string in Javascript, and then I'd like to output that to a human readable markdown file. For most all cases, this library works wonderfully, however, in the case of markdown tables, I'd like for the word wrapping not to happen, even though they are longer than the specified width. An option to ignore based on a pattern that would match lines in a markdown table (i.e. start and end with |) would be very useful.

Another wrinkle here is that I'm also supplying an indent, and would like the indent to still apply for that line.

Any interest in this? Either way, thanks for the tool!

jonschlinkert commented 7 years ago

Hi @mm-gmbd I think this is beyond the scope of this tool. A similar problematic issue is gfm code blocks. In the past I've written libraries that will temporarily remove tables or gfm code blocks using a heuristic before formatting, then restore them afterwords. Might be worth a try.