node-ts-dedent
node-ts-dedent copied to clipboard
Backticks (possibly) cause no dedent
I've got a weird one for you, one that seems to be a problem in the older dedent
package as well (https://github.com/dmnd/dedent/issues/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;
}
}];
\`\`\`
Your string starts with a literal backtick, so there's no leading whitespace, so this library would do nothing, by design. I think.
Agree to Drarok - as the string starts (and ends) without indentation there is nothing to dedent