Bug 33780 - Multi-line TT comment: [%% item.object.itemnotes.replace('\n','
Summary: Multi-line TT comment: [%% item.object.itemnotes.replace('\n','
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial (vote)
Assignee: Owen Leonard
QA Contact: Katrin Fischer
URL:
Keywords: Academy
Depends on:
Blocks:
 
Reported: 2023-05-19 07:22 UTC by Katrin Fischer
Modified: 2023-06-13 15:00 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 33780: Use TT html_line_break filter to format itemnotes (2.04 KB, patch)
2023-05-25 13:17 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 33780: Use TT html_line_break filter to format itemnotes (2.09 KB, patch)
2023-05-25 16:49 UTC, Lucas Gass
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2023-05-19 07:22:13 UTC
TT comments broken on multiple lines will lead to artifacts in the po files. Better to use a format that keeps them on one line or enclose each line in [%% ... %%]

koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt:581
[%% item.object.itemnotes.replace('\n','
Comment 1 Jonathan Druart 2023-05-24 07:11:58 UTC
This line?

594                         <td><div class="itemnotes">[% item.object.itemnotes.replace('\n','<br />') | $raw %]</div></td>
Comment 2 Owen Leonard 2023-05-25 12:01:25 UTC
(In reply to Katrin Fischer from comment #0)

> [%% item.object.itemnotes.replace('\n','

I don't see this string anywhere but in Koha-staff-prog.pot
Comment 3 Owen Leonard 2023-05-25 12:04:06 UTC
(In reply to Owen Leonard from comment #2)
> I don't see this string anywhere but in Koha-staff-prog.pot

Sorry, scratch that, I was on the wrong branch
Comment 4 Owen Leonard 2023-05-25 13:17:15 UTC
Created attachment 151677 [details] [review]
Bug 33780: Use TT html_line_break filter to format itemnotes

This patch removes a snippet of TT code which was causing problems with
translation. Putting HTML inside a TT replace() method resulted in TT
code being processed for translation.

To test, apply the patch and edit an item record's public note field so
that it contains line breaks ("\n"). Since the notes field in the editor
is a text field, you might want to update the record in the database:

update items set itemnotes = "Line 1\nLine 2\n\n\n\nLine 3" where
biblionumber = 228;

View the bibliographic details page in the staff interface. The note in
the holdings table should have the correct line breaks. If you inspect
the HTML you should see that each "\n" has been replaced with "<br />"
Comment 5 Jonathan Druart 2023-05-25 13:28:39 UTC
I am not sure this is about what was reporting Katrin.
Comment 6 Lucas Gass 2023-05-25 16:49:15 UTC
This is an improvement so I will sign-off. Will let Katrin decide if this was  what she initially reported.
Comment 7 Lucas Gass 2023-05-25 16:49:41 UTC
Created attachment 151703 [details] [review]
Bug 33780: Use TT html_line_break filter to format itemnotes

This patch removes a snippet of TT code which was causing problems with
translation. Putting HTML inside a TT replace() method resulted in TT
code being processed for translation.

To test, apply the patch and edit an item record's public note field so
that it contains line breaks ("\n"). Since the notes field in the editor
is a text field, you might want to update the record in the database:

update items set itemnotes = "Line 1\nLine 2\n\n\n\nLine 3" where
biblionumber = 228;

View the bibliographic details page in the staff interface. The note in
the holdings table should have the correct line breaks. If you inspect
the HTML you should see that each "\n" has been replaced with "<br />"

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 8 David Cook 2023-06-02 01:48:01 UTC
The effect of the patch is different to the issue description.

Note that before the patch, you could include HTML in the item note field. After the patch, the HTML is escaped.