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

Backticks (possibly) cause no dedent #27

Closed
shellscape opened this issue Aug 22, 2021 · 2 comments
Closed

Backticks (possibly) cause no dedent #27

shellscape opened this issue Aug 22, 2021 · 2 comments

Comments

@shellscape
Copy link

I've got a weird one for you, one that seems to be a problem in the older dedent package as well (dmnd/dedent#26). Escaped backticks result in no dedent-ing.

const content = '    [APBannerManager showBannerWithTitle:@"Title"\n' +
    '                                          subtitle:@"Subtitle"\n' +
    '                                          body:@"Body"\n' +
    '                                          image:[UIImage imageNamed:@"myPicture"]\n' +
    '                                          actionBlock:^(APBannerActionType type) {\n' +
    '                                            switch (type) {\n' +
    '                                              case APBannerActionTypeTap:\n' +
    '                                                NSLog(@"TAP");\n' +
    '                                                break;\n' +
    '                                              case APBannerActionTypeDismiss:\n' +
    '                                                NSLog(@"DISMISS");\n' +
    '                                                break;\n' +
    '                                            }\n' +
    '                                          }];';
   dedent(`\`\`\`
${content}
\`\`\``);

What we end up with is:

\`\`\`
    [APBannerManager showBannerWithTitle:@"Title"
                                          subtitle:@"Subtitle"
                                          body:@"Body"
                                          image:[UIImage imageNamed:@"myPicture"]
                                          actionBlock:^(APBannerActionType type) {
                                            switch (type) {
                                              case APBannerActionTypeTap:
                                                NSLog(@"TAP");
                                                break;
                                              case APBannerActionTypeDismiss:
                                                NSLog(@"DISMISS");
                                                break;
                                            }
                                          }];
\`\`\`
@Drarok
Copy link

Drarok commented Oct 5, 2021

Your string starts with a literal backtick, so there's no leading whitespace, so this library would do nothing, by design. I think.

@tamino-martinius
Copy link
Owner

Agree to Drarok - as the string starts (and ends) without indentation there is nothing to dedent

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

3 participants