|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
454 bytes
|
| Line | |
|---|
| 1 | // Wrap lines after 79 chars
|
|---|
| 2 | exports.wrap = function wrap(str) {
|
|---|
| 3 | var out = [];
|
|---|
| 4 | var pad = ' ';
|
|---|
| 5 | var line = pad;
|
|---|
| 6 |
|
|---|
| 7 | var chunks = str.split(/,/g);
|
|---|
| 8 | chunks.forEach(function(chunk, i) {
|
|---|
| 9 | var append = chunk;
|
|---|
| 10 | if (i !== chunks.length - 1)
|
|---|
| 11 | append += ',';
|
|---|
| 12 |
|
|---|
| 13 | if (line.length + append.length > 79) {
|
|---|
| 14 | out.push(line);
|
|---|
| 15 | line = pad;
|
|---|
| 16 | }
|
|---|
| 17 | line += append;
|
|---|
| 18 | });
|
|---|
| 19 | if (line !== pad)
|
|---|
| 20 | out.push(line);
|
|---|
| 21 |
|
|---|
| 22 | return out.join('\n');
|
|---|
| 23 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.