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
+6
-2
@@ -1020,14 +1020,18 @@ class ScoredRole(Role):
|
||||
#: carries more of a role's text than a row draws.
|
||||
EXCERPT_LIMIT = 200
|
||||
|
||||
#: The marks `html_text` starts a heading and a list item with.
|
||||
_LINE_MARK = re.compile("^(## |\u2022 )", re.M)
|
||||
|
||||
|
||||
def excerpt(text: str, limit: int = EXCERPT_LIMIT) -> str:
|
||||
"""`text` (a role's summary, or the opening of its description) with its
|
||||
whitespace collapsed, cut to `limit` characters at a word boundary with
|
||||
an ellipsis. What `Store.roles_page` builds `RoleRow.excerpt` with, off a
|
||||
`SUBSTR` of the source column rather than the whole of it, so the feed's
|
||||
list never carries what only the reader needs."""
|
||||
collapsed = " ".join((text or "").split())
|
||||
list never carries what only the reader needs. A description's heading
|
||||
and bullet marks (`plugins.readers._shared.html_text`) are left out."""
|
||||
collapsed = " ".join(_LINE_MARK.sub("", text or "").split())
|
||||
if len(collapsed) <= limit:
|
||||
return collapsed
|
||||
cut = collapsed[:limit]
|
||||
|
||||
Reference in new issue
Block a user