#1006164 tidy: keeps on adding new line before inline CDATA

Package:
tidy
Source:
tidy-html5
Description:
HTML/XML syntax checker and reformatter
Submitter:
Martin-Éric Racine
Date:
2026-01-10 11:39:40 UTC
Severity:
normal
#1006164#5
Date:
2022-02-20 08:57:02 UTC
From:
To:
$ cat .tidyrc
add-xml-decl: no
break-before-br: yes
char-encoding: raw
clean: no
indent-attributes: no
indent: auto
indent-spaces: 2
keep-time: yes
logical-emphasis: yes
output-xhtml: no
show-warnings: yes
tidy-mark: no
vertical-space: no
wrap: 78
wrap-attributes: no
write-back: yes

Problem HTML fragment:

<div id="footer">
  Copyright ©
  <script type="text/javascript">
    //<![CDATA[
    document.write(new Date().getFullYear())
    //]]>
  </script> All rights reserved.
</div>

Every time 'tidy' is run on that HTML document, an empty line is added before the CDATA:

<div id="footer">
  Copyright ©
  <script type="text/javascript">

    //<![CDATA[
    document.write(new Date().getFullYear())
    //]]>
  </script> All rights reserved.
</div>

Run 'tidy' 5 consecutive times on that document and you end up with 5 empty lines before the CDATA fragement.

<div id="footer">
  Copyright ©
  <script type="text/javascript">





    //<![CDATA[
    document.write(new Date().getFullYear())
    //]]>
  </script> All rights reserved.
</div>

- -- System Information:
Debian Release: 11.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-11-amd64 (SMP w/8 CPU threads)
Locale: LANG=fi_FI.utf8, LC_CTYPE=fi_FI.utf8 (charmap=UTF-8), LANGUAGE=fi:en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages tidy depends on:
ii  libc6         2.31-13+deb11u2
ii  libtidy5deb1  2:5.6.0-11

tidy recommends no packages.

tidy suggests no packages.

- -- no debconf information
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEyJACx3qL7GpObXOQrh+Cd8S017YFAmISAl0ACgkQrh+Cd8S0
17aRhBAAnLTTOJoUyMgjF4aFm+ly40Tw5q+qVOfnLyHgjYwwkBg4ND6LyShVbELA
UQidQZWjTwOCaYdrc9/PzyoE/0nz6yYvatrs7EY7DaJeFV10EKOm9vLnKUcc7ya9
YDaQhWS8KNhnkyQXHLJatvr2McHHHSABOH315dZInDkazrzL/wCuwRikv6AvFXAN
iQ5kwYf7BfHvzbn2/onkkoaotc2eaWrbaey5i2xZMbA+z8Oluiw3a7Wzf9MU9OcD
SgZFipmpGjZQB+Qrm0saTAQxcHsIwySMzGdQDoClhj0Ylc8WXsu0N8ZStODdjad/
99zSRZKQEggkB8ge41PRlBCH+eeDzIdMn+HNkTtSpSVvxTixoBKLJMK9FMrYbKCH
q+Mm1y1f4U3yNhAYGsVnwBqKFBnE+Hml3qCpgtUnvI7oXD/IXN4oYgshG3ON0Ux4
54g7sq7eAHGqetZTe72uo3u5T1JkZcQ0yjTT0FN2LVTdj34Mx6C/PIjYNMmEP0Vx
tRkNPQrG89zpoS2XfKmGUasFi1ln9YCnSf7wYs/O+uXfl3UJSGR5qTEZwgNc9l1O
5YrSiJXxtfvX+nPzJ3yvKwmesYXwRh0qmpXYgWtpIziIBSp5k+cBm47169fWh1Fi
hF90jJCJhIsoTETbO4TCp5Dqu6sIYcgmONzL10COFccuzz84Gas=
=XRRc
-----END PGP SIGNATURE-----

#1006164#10
Date:
2022-02-21 16:58:23 UTC
From:
To:
Reported upstream at https://github.com/htacg/tidy-html5/issues/1026
#1006164#17
Date:
2026-01-10 10:08:08 UTC
From:
To:
Es gibt eine Familienspende in Höhe von 1.850.000,00 USD von Cheng Charlie
Saephan. Bitte antworten Sie für weitere Informationen. Denken Sie daran,
Ihrer Familie und den Bedürftigen in Ihrer Umgebung Gutes zu tun.

Dies ist bereits der zweite Versuch, Sie zu erreichen. Bitte antworten Sie
für weitere Details.