All files / src/nesting protectBlockContent.ts

100% Statements 5/5
100% Branches 1/1
100% Functions 1/1
100% Lines 5/5

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 173x         3x 23x     14x         9x    
import { NEWLINE, SPACE } from './block-constants';
 
/**
 * Escapes block content to protect newline and space characters
 */
export function protectBlockContent(blockContent: string): string {
    if (typeof blockContent !== 'string') {
        // Note: This can happen when using in javascript and not in typescript
 
        throw new TypeError(
            `spaceTrim nested block expected string, but got ${typeof blockContent}`,
        );
    }
 
    return blockContent.split('\n').join(NEWLINE).split(' ').join(SPACE);
}