Keep a description's headings, bullets and paragraphs, and draw them in the reader

The readers flattened a posting's HTML into one line with strip_html, so
sections and bullets ran together. _shared.html_text gives a line per
paragraph, '• ' before a list item and '## ' before a heading; every
reader's description goes through it, sections read per role get their
own headings, and the reader pane draws the lines as h3, ul and p.
Excerpts leave the marks out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 21:40:12 +02:00
1 parent 17e7615599
commit c497fe965d
44 files changed
+300 -147

No files matched your search

+4 -5
View File
@@ -15,8 +15,8 @@ ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from desk.sources import strip_html # noqa: E402
from plugins.readers import Ask, _runner, workable # noqa: E402
from plugins.readers._shared import html_text # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "ats"
@@ -86,9 +86,8 @@ def test_detail_reads_description_requirements_and_benefits() -> None:
assert set(found) == {"description"} and set(found) <= set(_runner.DETAIL_FIELDS)
text, data = found["description"], json.loads(body)
for key in ("description", "requirements", "benefits"):
assert strip_html(data[key])[:40] in text
assert text.index(strip_html(data["description"])[:40]) < \
text.index(strip_html(data["benefits"])[:40])
assert html_text(data[key]) in text
assert text.index(html_text(data["description"])) < text.index(html_text(data["benefits"]))
assert "<" not in text and " " not in text and len(text) > 1500
@@ -96,7 +95,7 @@ def test_detail_joins_what_is_there_and_unescapes() -> None:
body = json.dumps({"description": "<p>Build &amp; run</p>", "requirements": None,
"benefits": "<ul><li>Pension</li></ul>"}).encode()
assert workable.detail(lambda url, **_: body, "acme", {"shortcode": "AAA111"}) == \
{"description": "Build & run Pension"}
{"description": "Build & run\n## Benefits\n\u2022 Pension"}
@pytest.mark.parametrize("body", [b"{}", b"[]", b'{"title": "x"}'])