zspecza / common-tags

🔖 Useful template literal tags for dealing with strings in ES2015+
Other
1.99k stars 60 forks source link

`html` behaves unexpectedly when there is no indent #209

Open marikaner opened 3 years ago

marikaner commented 3 years ago

I am trying no nest codeBlock (or html), but I am unable to do this for the root level indentation:

import { codeBlock } from 'common-tags';

const bc = () => codeBlock`
B
C
`;

const a = () => codeBlock`
A
${bc()}
  ${bc()}
`;

console.log(a());

gives me

A
B C
  B
  C

but I would expect it to be:

A
B
C
  B
  C