(raw: string, number: number)
| 905 | } |
| 906 | |
| 907 | const makeLine = (raw: string, number: number): Line => { |
| 908 | let indentation = 0 |
| 909 | while (raw.charCodeAt(indentation) === 32) indentation++ |
| 910 | // Scan `raw` once, including indentation, so comment and separator indices share an origin. |
| 911 | const found = { separator: -1 } |
| 912 | const comment = findIndicator(raw, "#", 0, found) |
| 913 | return { |
| 914 | raw, |
| 915 | text: comment === -1 |
| 916 | ? raw.slice(indentation) |
| 917 | : raw.slice(indentation, Math.max(indentation, whiteEnd(raw, comment))), |
| 918 | indent: indentation, |
| 919 | number, |
| 920 | // Rejected where the line is read as structure; block scalar content may hold tabs. |
| 921 | tabIndent: raw.charCodeAt(indentation) === 9, |
| 922 | comment: comment !== -1, |
| 923 | separator: found.separator === -1 ? -1 : found.separator - indentation |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | // Removes the comment from a marker or directive line, keeping characters before |
| 928 | // it that are not YAML separation so they can be rejected. |
no test coverage detected