carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
41 stars 26 forks source link

Fix spacing for callout titles #587

Closed froggleston closed 1 month ago

froggleston commented 1 month ago

This PR is a work in progress (as in it hasn't been tested anywhere near enough) to fix #562 with spacing in callout title headers. Currently, any HTML tags within the h3 title will lose any spacing due to the removal of whitespace when checking for translations.

The fix moves the trimming to inside the translation application function (apply_transformations) so leaves the tag spacing unchanged when replacing any translated elements. However, this hasn't been thoroughly checked.

froggleston commented 1 month ago

The fix is more complicated it seems as translation messes with what strings are sanitised and matched:

I've addressed this by moving the check and removal of whitespace to inside the apply_translation function, allowing us to retain knowledge of if the string did indeed have whitespace and to put it back if removed.

Similarly, I have excluded h3 titles for the translation check (and whitespace handling) which have inner tags, like <code>. Whilst this isn't optimal, I'm unsure of how to improve it without using some sophisticated matching for translation strings.

ErinBecker commented 1 month ago

I can confirm that this works for English-language lessons (tested with Foundations of Astronomical Data Science and Collaborative Lesson Development Training (screenshots below))

Screenshot 2024-05-24 at 10 43 51 AM Screenshot 2024-05-24 at 10 45 22 AM Screenshot 2024-05-24 at 10 45 05 AM

Agreed with @froggleston that this should also be tested on lessons that go through the translation process.