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:
1 parent
17e7615599
commit
c497fe965d
44 files changed
+300
-147
No files matched your search
@@ -28,17 +28,15 @@ any other site's, so the host is given by hand.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import html
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._contract import Ask, Fields, Place, Reads, Row
|
||||
from ._shared import Get, Page, add_place, only, parse_dt, place
|
||||
from ._shared import Get, Page, add_place, html_text, only, parse_dt, place
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -103,10 +101,6 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
return rows(json.loads(body), slug)
|
||||
|
||||
|
||||
def _plain(markup: Any) -> str:
|
||||
return " ".join(html.unescape(strip_html(str(markup or ""))).split())
|
||||
|
||||
|
||||
def _places(j: dict[str, Any]) -> list[Place]:
|
||||
"""`full_location` names every place of the role, "; " apart, each as
|
||||
"City, Country"; the site's `city` and `country` stand in when it is
|
||||
@@ -136,8 +130,8 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
|
||||
if not title or not role:
|
||||
continue
|
||||
categories = j.get("categories") or []
|
||||
text = "\n\n".join(p for p in (_plain(j.get("description")),
|
||||
_plain(j.get("qualifications"))) if p)
|
||||
text = "\n".join(p for p in (html_text(j.get("description")),
|
||||
html_text(j.get("qualifications"))) if p)
|
||||
places = _places(j)
|
||||
row: Row = {
|
||||
"source_id": role,
|
||||
|
||||
Reference in new issue
Block a user