mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
* fix(ui): keep line breaks in the game summary Normalize CRLF and bare CR to LF and render the summary with white-space: pre-line so multi-line summaries keep their structure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(metadata): turn HTML in provider summaries into plain text Add utils.html_text.html_to_text, a parser-based helper that drops known HTML tags, maps paragraphs, line breaks and list items to newlines, and unescapes entities. Unknown tags such as "<Start>" stay as literal text. Moby, ScreenScraper, Steam, Flashpoint and LaunchBox summaries go through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(metadata): separate table cells and keep bullets on their text Addresses Greptile review on #5413: adjacent td/th cells now get a space between them, and a list item wrapping its text in a paragraph keeps the bullet on the same line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import pytest
|
|
|
|
from utils.html_text import html_to_text
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("value", "expected"),
|
|
[
|
|
(None, ""),
|
|
("", ""),
|
|
(" Plain summary. ", "Plain summary."),
|
|
("Line one\nLine two", "Line one\nLine two"),
|
|
("Tom "Big" Jones & co", 'Tom "Big" Jones & co'),
|
|
("<p>One.</p>\n<p>Two<br/>three</p>", "One.\n\nTwo\nthree"),
|
|
("<b>Bold</b> and <i>italic</i>", "Bold and italic"),
|
|
('<a href="https://x">link</a> text', "link text"),
|
|
("<ul><li>a</li><li>b</li></ul><p>after</p>", "• a\n• b\n\nafter"),
|
|
("<p>a</p><p></p><p></p><p>b</p>", "a\n\nb"),
|
|
(
|
|
"<table><tr><td>Single player</td><td>Co-op</td></tr>"
|
|
"<tr><th>A</th><th>B</th></tr></table>",
|
|
"Single player Co-op\nA B",
|
|
),
|
|
(
|
|
"<ul><li><p>Save Hyrule</p></li><li>\n <p>Again</p></li></ul>",
|
|
"• Save Hyrule\n\n• Again",
|
|
),
|
|
("<script>alert(1)</script>Safe", "Safe"),
|
|
("Non breaking", "Non breaking"),
|
|
],
|
|
)
|
|
def test_html_to_text(value: str | None, expected: str):
|
|
assert html_to_text(value) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"value",
|
|
[
|
|
"Press <Start> to begin",
|
|
"1 < 2 and 3 > 2",
|
|
"Enter <Your Name> here",
|
|
"Ends with <unterminated",
|
|
],
|
|
)
|
|
def test_html_to_text_keeps_literal_angle_brackets(value: str):
|
|
assert html_to_text(value) == value
|