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/prettier
and checkout thepyscript-3.0.0-alpha.6
branch git fetch upstream --tags
git rebase HEAD~1 --onto <NEW_TAG>
where for instanceNEW_TAG
might be3.0.0-alpha.7
.- Force push this to
hoodmane/prettier
yarn build
(you may need to runnpm i -g yarn
to install yarn first).- In this repo,
rm -rf dist
- Copy the
prettier/dist
directory into this repo. - Commit the new version and tag it.