| 10347 | |
| 10348 | // Indents every line in a string. Empty lines (\n only) are not indented. |
| 10349 | function indentString(string, spaces) { |
| 10350 | var ind = common.repeat(' ', spaces), |
| 10351 | position = 0, |
| 10352 | next = -1, |
| 10353 | result = '', |
| 10354 | line, |
| 10355 | length = string.length; |
| 10356 | |
| 10357 | while (position < length) { |
| 10358 | next = string.indexOf('\n', position); |
| 10359 | if (next === -1) { |
| 10360 | line = string.slice(position); |
| 10361 | position = length; |
| 10362 | } else { |
| 10363 | line = string.slice(position, next + 1); |
| 10364 | position = next + 1; |
| 10365 | } |
| 10366 | |
| 10367 | if (line.length && line !== '\n') result += ind; |
| 10368 | |
| 10369 | result += line; |
| 10370 | } |
| 10371 | |
| 10372 | return result; |
| 10373 | } |
| 10374 | |
| 10375 | function generateNextLine(state, level) { |
| 10376 | return '\n' + common.repeat(' ', state.indent * level); |