MartinKolarik / dedent-js

Remove indentation from multiline strings
MIT License
55 stars 6 forks source link

Bug with escaped newlines #2

Open sirian opened 5 years ago

sirian commented 5 years ago
dedent`foo\n    bar`

is not the same as

dedent`foo
    bar`

But both produces "foo\nbar"

dedent`foo\n    bar` should be "foo\n    bar"
MartinKolarik commented 5 years ago

This is in line with the test suite and readme. IIRC it wasn't possible to detect the difference. You can write it like this though:

dedent`
    foo
        bar
`
sirian commented 5 years ago

it's possible to detect via raw value of template strings

image