Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stripIndent with stripIndent'ed string inside doesn't strip some indents #22

Closed
hogart opened this issue May 18, 2016 · 3 comments
Closed

Comments

@hogart
Copy link

hogart commented May 18, 2016

Test case:

const stripIndent = require('common-tags').stripIndent;

const line1 = stripIndent`
    line1.0
    line1.1`;

console.log(line1);

const line2 = stripIndent`
    ${line1}
    line2.0`;

console.log(line2);

Output:

line1.0
line1.1
line1.0
line1.1
    line2.0

As you see, line2.0 isn't de-indented. I'm not sure if it's expected behaviour. If so, how can I achieve desired effect? Thanks for nice lib!

@zspecza
Copy link
Owner

zspecza commented May 19, 2016

@hogart I haven't found a need for this as it's quite edge-case. The current algorithm only strips out the smallest leading indent from each line and leaves regular indents untouched. I'll have to consult with some other algorithms and see what they do, but I do plan on adding a stripIndents tag which strips all indentation line-per-line. This feature addition will be coming after a refactor to the way the core of this module works, which I can't get around to doing just yet because of work, but I will as soon as I have some time, promise :)

@zspecza
Copy link
Owner

zspecza commented May 23, 2016

I've added stripIndents but will be leaving this issue open and update it with my findings when I have time to work on this project again :)

@hogart
Copy link
Author

hogart commented May 23, 2016

Wow, thanks a lot:)

@zspecza zspecza closed this as completed Nov 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants