From 542ef4ee17cf8e8499854a239e7485099252c14c Mon Sep 17 00:00:00 2001 From: Mike Fix <62121649+mfix-stripe@users.noreply.github.com> Date: Wed, 21 Sep 2022 10:47:50 -0700 Subject: [PATCH] fix formatting for tags within fences (#210) --- src/formatter.test.ts | 22 ++++++++++++++++++++++ src/formatter.ts | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/formatter.test.ts b/src/formatter.test.ts index 74439a0..cc25340 100644 --- a/src/formatter.test.ts +++ b/src/formatter.test.ts @@ -488,4 +488,26 @@ Yes! check(source, expected); stable(expected); }); + + it('fences with block level tags', () => { + const source = `{% tab %} +\`\`\`json {% filename="package.json" %} +{ + "dependencies": { + ... + {% highlight type="remove" %} + "beta": "1.2.3", + {% /highlight %} + {% highlight type="add" %} + "main": "1.2.4", + {% /highlight %} + ... + } +} +\`\`\` +{% /tab %} +`; + + check(source, source); + }); }); diff --git a/src/formatter.ts b/src/formatter.ts index 4723960..5d3b408 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -185,7 +185,8 @@ function* formatNode(n: Node, o: Options = {}) { yield* formatAnnotations(n); yield NL; yield indent; - yield* formatChildren(n, no); + // TODO use formatChildren once we can differentiate inline from block tags within fences + yield n.attributes.content; // yield* formatChildren(n, no); yield indent; yield '```'; yield NL;