From 4b769882cb568ac7d54d4a8b68b8d8cc8af28c2c Mon Sep 17 00:00:00 2001
From: Antony Faris
Date: Sat, 2 Oct 2021 19:56:42 -0500
Subject: [PATCH] Preserve tag case (#19)
---
src/printer.js | 12 +++++++++++-
test/astro-prettier.test.mjs | 2 +-
test/fixtures/in/preserve-tag-case.astro | 7 +++++--
test/fixtures/in/with-script.astro | 7 +++++--
test/fixtures/out/preserve-tag-case.astro | 2 ++
test/fixtures/out/with-script.astro | 5 ++++-
6 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/src/printer.js b/src/printer.js
index b06a807..dd91803 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -108,7 +108,8 @@ const print = (path, opts, print) => {
}
// If we don't see any JSX expressions, this is just embedded HTML
// and we can skip a bunch of work. Hooray!
- if (text.indexOf('{') === -1) {
+ const hasInlineComponent = node.children.filter((x) => x.type === 'InlineComponent').length > 0;
+ if (text.indexOf('{') === -1 && !hasInlineComponent) {
node.__isRawHTML = true;
node.content = text;
return path.call(print);
@@ -395,6 +396,15 @@ const embed = (path, print, textToDoc, opts) => {
return group(['---', hardline, textToDoc(node.content, { ...opts, parser: 'typescript' }), '---', hardline]);
}
+ // format
\ No newline at end of file
diff --git a/test/fixtures/out/preserve-tag-case.astro b/test/fixtures/out/preserve-tag-case.astro
index 9a7a2a9..c7183c7 100644
--- a/test/fixtures/out/preserve-tag-case.astro
+++ b/test/fixtures/out/preserve-tag-case.astro
@@ -1,6 +1,8 @@
---
import Footer from "./Footer.astro";
+import { Body } from "lib";
---
+
diff --git a/test/fixtures/out/with-script.astro b/test/fixtures/out/with-script.astro
index 00faeef..929507c 100644
--- a/test/fixtures/out/with-script.astro
+++ b/test/fixtures/out/with-script.astro
@@ -1,5 +1,8 @@