vitaly-t / decomment

:hammer: Removes comments from JSON, JavaScript, CSS, HTML, etc.
75 stars 21 forks source link

No output in the original format when the switch or end contains a blank symbol #24

Closed wll8 closed 1 year ago

wll8 commented 3 years ago

No output in the original format when the switch or end contains a blank symbol

For example, when there are multiple spaces.

environment

How to reproduce

The result of this place should be true

const decomment = require('decomment')
const raw = `
    html {
      margin: 0;
      padding: 0;
    }

`
const res = decomment.text(raw)
console.log(`res`, res === raw) // false => The result of this place should be `true`
vitaly-t commented 2 years ago

Most likely your editor issue, when it compiles line breaks differently from when it passes it in as a string. Make sure you do not extraneous white spaces there, which may be truncated at the end.

wll8 commented 2 years ago

So the above use case cannot be reproduced on your computer, right? Or do you think this is not a problem to be solved?

vitaly-t commented 2 years ago

I can reproduce it by tweaking end symbols to contain extra spaces on lines.

Anyway, I wouldn't expect identical text just because it doesn't contain comment blocks.

vitaly-t commented 1 year ago

Closing, for being old, and no follow-up.