Bug 39202

Summary: Lots of instances of HTML closing tags being on a separate line
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: dcook, jonathan.druart, phil
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 38664, 38713    
Bug Blocks:    

Description Lucas Gass (lukeg) 2025-02-26 00:16:18 UTC
After tidying I see many instances on HTML closing tags `>` being on its own line.

I used `git grep -nP '^\s*>\s*$'` to see that there are many cases of this.
Comment 1 Lucas Gass (lukeg) 2025-02-26 00:18:58 UTC
There are other problems with HTML structure like:

<li
    ><a class="revert_recall dropdown-item" data-id="[% recall.id | html %]"><i class="fa fa-undo"></i> Revert waiting</a></li
>
 

I suspect we don't want this.
Comment 2 Jonathan Druart 2025-03-04 10:07:51 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2025-03-04 10:13:32 UTC
> I suspect we don't want this.

We wanted this. At least we did during the "tidy all" initial process.

It has been advertised and explained during the work, and is in the document 
https://koha-hedgedoc.servers.llownd.net/Bug-38664_Tidy-the-whole-codebase, section "The translation process".


After the tidy we have:
```
-                    <option value="r" selected="selected">Remote-sensing image</option>
+                    <option value="r" selected="selected">
+                        Remote-sensing image
+                    </option>
```

It will generate the following changes in the .po files:

```
+#: koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_007.tt:89
+#, fuzzy, c-format
+msgid "Remote-sensing image "
+msgstr "Image de télédétection"
```

I have tried to fix this in the translation script, see commit "WIP trim msgid". It actually fixes some problem with the current script:
```
+#. For the first occurrence,
 #. SCRIPT
-#: koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_007.tt:114
+#: koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_007.tt:139
 msgid "b- Large print"
 msgstr "b- Gros caractères"
 
-#. SCRIPT
-#: koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_field_007.tt:114
-msgid "b- Large print "
-msgstr "b- Gros caractères "
```
Was it enough?

No it was not, we were loosing important spaces in some places.

SOLUTION - we modified prettier's default behaviour: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity

Using "htmlWhitespaceSensitivity: 'strict'" in `.prettierrc.js` fixes the problem by splitting the tags themselves
```
+                                            [% IF m.version == ( mm.version ) %]
+                                                <ul
+                                                    ><li><strong>Mentor:</strong> [% INCLUDE person p=mm %]</li></ul
+                                                >
+                                            [% END %]
```

So we don't always need to split the tags. We could manually fix, but it needs to be done on a case-by-case basis.
Comment 4 Lucas Gass (lukeg) 2025-03-04 14:10:07 UTC
Thanks for taking the time to explain, I think we can resolve this.
Comment 5 Jonathan Druart 2025-03-10 09:00:51 UTC

*** This bug has been marked as a duplicate of bug 39085 ***