Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 3x 3x 3x 6x 6x 15x 15x 15x 15x 15x 27x 6x | import { spaceTrimSimple } from '../spaceTrimSimple';
import { NEWLINE, SPACE } from './block-constants';
/**
* Unescapes block content to protect newline and space characters
*/
export function restoreBlockContent(content: string): string {
let horizontalyTrimmedLines = spaceTrimSimple(content).split('\n');
horizontalyTrimmedLines = horizontalyTrimmedLines.map((line) => {
const sublines = line.split(NEWLINE);
const firstSubine = sublines[0];
const contentStart =
firstSubine.length - firstSubine.trimStart().length;
const indentation = ' '.repeat(contentStart);
return sublines
.map(
(subline) =>
`${indentation}${subline
.trimStart()
.split(SPACE)
.join(' ')}`,
)
.join('\n');
});
return horizontalyTrimmedLines.join('\n');
}
|