This is a precommit hook that applies a patched version of prettier that
recognizes the py-script and py-config tags and does not reformat their
contents. The patch that has been applied to prettier is as follows:
--- a/src/language-html/utils/index.js
+++ b/src/language-html/utils/index.js
@@ -106,7 +106,8 @@ function isTextLikeNode(node) {
function isScriptLikeTag(node) {
return (
node.type === "element" &&
- (node.fullName === "script" ||
+ (node.fullName === "py-script" ||
+ node.fullName === "py-config" ||
+ node.fullName === "script" ||
node.fullName === "style" ||
node.fullName === "svg:style" ||
(isUnknownNamespace(node) &&
-- This patched version of prettier is hosted at https://github.com/hoodmane/prettier/tree/pyscript. To update prettier to a new version:
- clone
hoodmane/prettierand checkout thepyscript-3.0.0-alpha.6branch git fetch upstream --tagsgit rebase HEAD~1 --onto <NEW_TAG>where for instanceNEW_TAGmight be3.0.0-alpha.7.- Force push this to
hoodmane/prettier yarn build(you may need to runnpm i -g yarnto install yarn first).- In this repo,
rm -rf dist - Copy the
prettier/distdirectory into this repo. - Commit the new version and tag it.