Bug 38664: The tidy script - tidy tt twice

For an unknown reason the script is not idempotent (!)
Decided to run it twice for now, and have a look at this problem later.
It might be related to the length of the line

Version 0

<div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]<span>Withdrawn</span>[% END %]
                    [% IF ITEM_DAT.bookable == 1 %] Yes [% ELSIF ITEM_DAT.bookable == 0 %] No [% ELSE %] Follow item type [% END %]

                    [% IF ITEM_DAT.bookable == 1 %] [% t('Yes') %] [% ELSIF ITEM_DAT.bookable == 0 %] [% t('No') %] [% ELSE %] [% t('Follow item type') %] [% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Version 1
<div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]<span
                        >Withdrawn</span
                    >[% END %]
                    [% IF ITEM_DAT.bookable == 1 %]Yes[% ELSIF ITEM_DAT.bookable == 0 %]No[% ELSE %]Follow
                    item type[% END %]

                    [% IF ITEM_DAT.bookable == 1 %][% t('Yes') %][% ELSIF ITEM_DAT.bookable == 0 %][% t('No') %][% ELSE %][% t('Follow item type') %][% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Version 2
div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]
                        <span>Withdrawn</span>
                    [% END %]
                    [% IF ITEM_DAT.bookable == 1 %]
                        Yes
                    [% ELSIF ITEM_DAT.bookable == 0 %]
                        No
                    [% ELSE %]
                        Follow item type
                    [% END %]

                    [% IF ITEM_DAT.bookable == 1 %][% t('Yes') %][% ELSIF ITEM_DAT.bookable == 0 %][% t('No') %][% ELSE %][% t('Follow item type') %][% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-01-08 14:35:06 +01:00 committed by Katrin Fischer
parent 2c6f9d31b6
commit 0cdaf9935f
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 12 additions and 9 deletions

View File

@ -132,16 +132,19 @@ sub tidy_vue {
sub tidy_tt {
my ($file) = @_;
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) =
run( command => sprintf q{yarn --silent run prettier --write %s}, $file );
if ($success) {
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf );
for ( 1 .. 2 ) {
( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) =
run( command => sprintf q{yarn --silent run prettier --write %s}, $file );
if ($success) {
# Revert the substitutions done by the prettier plugin
edit_file sub {
s#<!--</head>-->#</head>#g;
s#<!--<body(.*)-->#<body$1#g;
s#<!--</body>-->#</body>#g;
}, $file;
# Revert the substitutions done by the prettier plugin
edit_file sub {
s#<!--</head>-->#</head>#g;
s#<!--<body(.*)-->#<body$1#g;
s#<!--</body>-->#</body>#g;
}, $file;
}
}
return ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf );
}