tamino-martinius / node-ts-dedent

TypeScript package which smartly trims and strips indentation from multi-line strings
MIT License
159 stars 8 forks source link

Remove trailing spaces on empty lines in interpolated text #37

Open rattrayalex opened 1 year ago

rattrayalex commented 1 year ago

See https://github.com/indentjs/endent/pull/12 for an example failing test.

const insertion = "indented 1\n\nindented 2";
const output = endent`
  foo
    ${insertion}
`;
const current = output === "foo\n  indented 1\n  \n  indented 2"
const desired = output === "foo\n  indented 1\n\n  indented 2"

I have worked around this by tacking .replaceAll(/\n\s*\n/gi, '\n\n') at the end of our dedent() calls in a wrapper function.