Repository: collective/zpretty (language: python)

Issue:
pre-commit config should use -x or -z option where needed
Seen with https://github.com/plone/Products.CMFPlacefulWorkflow/pull/48 where I ran zpretty and then the tests failed.

Sample `test.pt`, with code copied from `CMFPlacefulWorkflow`:

```
<div class="input-group mb-3"
tal:define="ctype_title ctype/Title;
ctype_id ctype/getId;

chain python:wf_policy.getChainFor(ctype_id, managescreen=True) or ('backward compatibility',);">
</div>
```

Call `zpretty` on it with various settings:

```
$ zpretty -z test.pt 
<div
    class="input-group mb-3"
    define="ctype_title ctype/Title; ctype_id ctype/getId; new-line-325543de-bce0-4c57-9943-51081bbf16bd="
    >"
chain python:wf_policy.getChainFor(ctype_id, managescreen=True) or ('backward compatibility',);"&gt;
</div>
$ zpretty -x test.pt 
<?xml version="1.0" encoding="utf-8"?>
<div class="input-group mb-3"
     define="ctype_title ctype/Title; ctype_id ctype/getId; new-line-b8c2457f-8f41-461f-b20c-9c8b35bb96b7="
>"
chain python:wf_policy.getChainFor(ctype_id, managescreen=True) or ('backward compatibility',);"&gt;
</div>
$ zpretty test.pt 
<div class="input-group mb-3"
     "=""
     ('backward=""
     chain=""
     compatibility',);"=""
     managescreen="True)"
     or=""
     python:wf_policy.getchainfor(ctype_id,=""
     tal:define="
       ctype_title ctype/Title;
       ctype_id ctype/getId;
       new-line-6cb196f8-2f79-4a48-9209-63852f7887b5=;
     "
>
</div>
```

So I guess if you don't pass anything at all, `zpretty` formats the file as html, which mostly works, but makes it really weird here, giving a page compilation error when using it.

We may need separate entries in the pre-commit hook.


Discussion / hints:

Fix patch:
diff --git a/HISTORY.md b/HISTORY.md
index 445922c..6bc3837 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -3,7 +3,9 @@
 3.0.1 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Fix an issue with empty lines inside an attribute.
+  (Fixes #106)
+  [ale-rt]
 
 
 3.0.0 (2023-02-09)
diff --git a/zpretty/prettifier.py b/zpretty/prettifier.py
index 5154996..596abb5 100644
--- a/zpretty/prettifier.py
+++ b/zpretty/prettifier.py
@@ -19,7 +19,7 @@ class ZPrettifier(object):
     parser = "html.parser"
     builder = None
     _end_with_newline = True
-    _newlines_marker = f'new-line-{str(uuid4())}=""'
+    _newlines_marker = f"new-line-{str(uuid4())}"
     _ampersand_marker = str(uuid4())
     _cdata_marker = str(uuid4())
     _cdata_pattern = re.compile(r"<!\[CDATA\[(.*?)\]\]>", re.DOTALL)


Test patch:
diff --git a/zpretty/tests/original/sample_pt.pt b/zpretty/tests/original/sample_pt.pt
index 5a3c8ec..267530d 100644
--- a/zpretty/tests/original/sample_pt.pt
+++ b/zpretty/tests/original/sample_pt.pt
@@ -16,6 +16,11 @@
         >whatever</a>)
         a<b disabled="disabled"
            href="#"
+           tal:define="
+             foo python:1
+
+             bar python:2;
+           "
         >whatever</b>
         "<c href="#">whatever</c>"
         <pre>