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
@@ -929,6 +929,9 @@ body[data-reader="open"] .company-strip { display: none; }
|
||||
margin-top: 1.3rem; font-size: 1.06rem; line-height: 1.7;
|
||||
}
|
||||
.prose p { margin: 0 0 1.05rem; }
|
||||
/* A description's headings and bullets (roles.js `paragraphs`), newsdesk's rules. */
|
||||
.prose h2, .prose h3, .prose h4 { line-height: 1.3; margin: 1.4rem 0 .7rem; }
|
||||
.prose ul, .prose ol { padding-left: 1.5rem; }
|
||||
.reader-out { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
|
||||
.reader-note a { color: var(--accent); }
|
||||
.reader-copy { margin-top: .8rem; }
|
||||
|
||||
+20
-5
@@ -861,13 +861,17 @@
|
||||
return role.excerpt || "";
|
||||
}
|
||||
|
||||
/* The heading and bullet marks of a description line, see `paragraphs`. */
|
||||
const LINE_MARK = /^(## |\u2022 )/gm;
|
||||
|
||||
/* The same cut, run here instead: for the one row `merge` refreshes after
|
||||
a fetch or a summarise, off the full role that call answers with, which
|
||||
is the only time this page ever sees a role's `summary` or
|
||||
`description` directly. */
|
||||
function excerptOf(role) {
|
||||
/* The server's order (`_EXCERPT_SOURCE`): summary, description, teaser. */
|
||||
const text = (role.summary || role.description || role.teaser || "").replace(/\s+/g, " ").trim();
|
||||
const text = (role.summary || role.description || role.teaser || "")
|
||||
.replace(LINE_MARK, "").replace(/\s+/g, " ").trim();
|
||||
if (text.length <= 200) return text;
|
||||
const cut = text.slice(0, 200);
|
||||
const space = cut.lastIndexOf(" ");
|
||||
@@ -1291,11 +1295,22 @@
|
||||
try { return new URL(url).host.replace(/^www\./, ""); } catch (e) { return ""; }
|
||||
}
|
||||
|
||||
/* Plain text in paragraphs: a fetched page keeps its line breaks, and a
|
||||
board's description is one long line, which stays one paragraph. */
|
||||
/* A description is a line per paragraph (`plugins.readers._shared.html_text`):
|
||||
"## " starts a heading and "• " a list item, which is how a board's HTML
|
||||
keeps its sections and bullets (`LINE_MARK`). A fetched page keeps its
|
||||
line breaks, and an older description is one long line, which stays one
|
||||
paragraph. */
|
||||
function paragraphs(text) {
|
||||
return text.split(/\n+/).map((p) => p.trim()).filter(Boolean)
|
||||
.map((p) => `<p>${esc(p)}</p>`).join("");
|
||||
let html = "";
|
||||
let list = false;
|
||||
for (const line of text.split(/\n+/).map((p) => p.trim()).filter(Boolean)) {
|
||||
const item = line.startsWith("\u2022 ");
|
||||
if (item !== list) { html += item ? "<ul>" : "</ul>"; list = item; }
|
||||
html += item ? `<li>${esc(line.slice(2))}</li>`
|
||||
: line.startsWith("## ") ? `<h3>${esc(line.slice(3))}</h3>`
|
||||
: `<p>${esc(line)}</p>`;
|
||||
}
|
||||
return list ? `${html}</ul>` : html;
|
||||
}
|
||||
|
||||
function renderReader({ loading = false, error = "" } = {}) {
|
||||
|
||||
Reference in new issue
Block a user