commit 1216ea53db1a98add06f0f5274a53561667e3763
parent 9ae432d440e35a18fdef9b70fb4172fd481c8e93
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 12:32:39 -0500
umtool: edge masks for the slur filter -- render.posts.slurs.edges masks every form of a named slur as its first letter, stars and its last letter, in the case written (n***a, n****s, f****t, f*****s, N***A), so a form is told apart
One mask per hit (post-slurs.mjs maskOfHit) is what the card's pill, Play,
the bench, a chapter line, a caption, a take's refusal and `posts slurs ls`
show. A slur's word, id or any form names the whole slur (a listed one or the
project's own). `umtool posts slurs <p> edges <word> [--off]` through the one
writer (updatePostSlurs edge/unedge); ls says "edges: ..." by mask, never the
word; the Cut tab's Slur filter has Edge mask / First letter only beside a
word. A cut without edges is unchanged: no entry carries `edge`, so its masks,
render key and card PNG are byte-identical to main. The read's stand-in is
unchanged.
Operator, 5 Nov: a censored cut where the "-a" form shows as n***a, "to
specify it's not -er", and the f-slur the same.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
12 files changed, 256 insertions(+), 34 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **umtool: a slur can be masked by its first and last letter, so its form is told apart.** The slur filter's pill showed one mask per slur for every form ("n*****" for the "-a" form as for the "-er" one). `umtool posts slurs <p> edges <word>` (a slur's word, id or any form names it; `--off` takes it back) now masks every form of that slur as its first letter, stars and its last letter, in the case the post wrote it -- "n***a", "n****s", "f****t", "f*****s", "N***A" (`render.posts.slurs.edges`). The one mask per word is what the card's pill, Play, the bench, a chapter line, a caption and `posts slurs ls` show (`ls` says `edges: …`, by mask); the Cut tab's Options → Reads and voices → Slur filter has **Edge mask** and **First letter only** beside a word. A cut without `edges` renders exactly as before; the read's stand-in ("n-word") is unchanged.
- **umtool: the post bench's attachment lanes are back on the take-only bench, and a GIF has one.** On `?inTake=<t>` (the only bench of an item a take carries and the cut does not) the bench showed a note where the lanes were, so a video's in and out could only be typed; and the lane covered the first video only. Now every video and GIF of the item has a lane under the player: its whole length as a waveform (a flat line for a GIF or a silent video, which still drags), the in and out as its two handles (never closer than 0.5 s, never past the file), the part the item plays dashed and the playhead, with the bench's clock following a moving edge so the player shows its frame. A handle moves the same draft the **in / out** fields do (they follow at once, as the plan's seconds do) and **Save** writes it -- into the take's patch on a take-only bench, the project's manifest untouched; focused, `[ ]` and `, .` nudge the in and out (Shift coarser) and `← →` the edge last moved. The read's lane (its lead dragged) and **Re-pick best** write the take there too (`/api/report/post-narration` takes `inTake` for set and fit); recording, re-takes and the mix stay on the cut's bench. umtool/docs/knobs.md.
- **A reply that is only a picture is drawn as its message, and a long post on a card alone keeps large text.** A post whose words are only @mentions and links with an attachment (an "@ObviousRises" and a GIF, a reply that is a screenshot of another post) is now picture-only in a report video: its picture is drawn inside its own card where its words would be, at the card's width, with the mention drawn small as a reply-to line, never in the side slot. The GIF that showed beside Mr. Obvious's reply while he was being read now has its own beat first: shown alone in its card for its own length (an image for 2 s, between 1.5 and 4 s), then the read. The read's start moves and the take is not re-made, so word zooms, captions, slams and beeps stay on their words. The render plays the GIF over its place in the card, Play plays it in the card, and the post bench has a **picture-only** block with an auto, on or off setting for the item and for each post it answers or quotes (`umtool posts set-item <p> <item> pictureOnly=on|off|auto`, `parent.<i>.pictureOnly=`, `quoted.pictureOnly=`). `render.posts.pictureReply` sets the beat's length or turns the rule off. A long post on a card alone is now drawn at a reading size and scrolled with the read, where it used to shrink to read-follow's minimum to fit (operator, 5 Nov: "bigger text for the novel"). Posts that are not picture-only, and posts whose words fit their card, render exactly as before.
- **umtool: a pause can be put in after words of an approved read, without reading it again.** A countdown read as "20 10 4 0" in one breath could only be spaced by synthesizing a new read, losing a delivery that was liked. `umtool posts reread <p> <item> --pause "20=0.45,10=0.45,4=0.45"` now cuts the picked take just after each word named (found in its word timings as a word zoom finds one: case and punctuation aside, `#2` its second time, `--target linked:0` one piece's words) and puts that much silence in (0.05–3 s), moving everything after it on -- its words, its parts and its length, so zooms, captions, slams, beeps and the read-follow stay on their words. It is a new take, picked in one undoable write; on a paused take it re-cuts from the take before (`=0` takes a pause away), `--dry-run` shows each cut and the new length, `--in-take <t>` puts it in a take's read, and a take with no word timings is refused naming `umtool posts narrate <p> <item> --words`. The post bench's Options → Re-join the read has **pause after** with Preview and Apply, on the take-only bench too. umtool/docs/cli.md, knobs.md.
diff --git a/umtool/app/api/report/pronunciation/route.ts b/umtool/app/api/report/pronunciation/route.ts
@@ -22,7 +22,7 @@ export const dynamic = "force-dynamic";
// { project, op: "mix-cut", key, value } posts narrate <p> --cut <key>=<value> (render.postNarration)
// { project, op: "redact-add", term, substring?, note? } posts redact <p> add "<term>" [--substring] [--note]
// { project, op: "redact-remove", n } posts redact <p> remove <n>
-// { project, op: "slurs", verb: on|off|level|visual|voice|add|except|remove, value? } posts slurs <p> <verb> [value]
+// { project, op: "slurs", verb: on|off|level|visual|voice|add|except|remove|edges, value?, off? } posts slurs <p> <verb> [value] [--off]
// { project, op: "queue-narrate", what: "scripts" | "takes" | "context" | "threads" } QUEUED (lib/queue/, /jobs): posts narrate <p> --all
// --draft-scripts | --all --take -- long, so a step of
// the queue, never a request held open; the argv is built
@@ -88,8 +88,8 @@ export async function POST(request: Request) {
else if (b.op === "redact-remove") r = await posts(["redact", project.id, "remove", String(Number(b.n))]);
else if (b.op === "slurs") {
const verb = s("verb");
- if (!["on", "off", "level", "visual", "voice", "add", "except", "remove"].includes(verb)) return Response.json({ error: "slurs: on, off, level, visual, voice, add, except or remove" }, { status: 400 });
- r = await posts(["slurs", project.id, verb, ...(verb === "on" || verb === "off" ? [] : [s("value")])]);
+ if (!["on", "off", "level", "visual", "voice", "add", "except", "remove", "edges"].includes(verb)) return Response.json({ error: "slurs: on, off, level, visual, voice, add, except, remove or edges" }, { status: 400 });
+ r = await posts(["slurs", project.id, verb, ...(verb === "on" || verb === "off" ? [] : [s("value")]), ...(verb === "edges" && b.off === true ? ["--off"] : [])]);
} else if (b.op === "queue-narrate") {
// Also the cut-wide post passes that are terminal-only otherwise: fill each item's context from its capture
// (posts context), gather each conversation together (timeline threads --write).
diff --git a/umtool/components/projects/PronunciationPanel.tsx b/umtool/components/projects/PronunciationPanel.tsx
@@ -21,7 +21,7 @@ type View = {
stale: { json: { reads?: { id: string; take: string; entries: { word: string; say: string }[]; fix: string }[] } | null };
redact?: { json: { redact?: (string | { term: string; substring?: boolean; note?: string })[]; corpusTerms?: number; markedPosts?: number } | null; error?: string };
mix?: Record<string, unknown>;
- slurs?: { json: { on?: boolean; level?: string; visual?: string; voice?: string; listed?: number; add?: number; except?: number; total?: number } | null; error?: string };
+ slurs?: { json: { on?: boolean; level?: string; visual?: string; voice?: string; listed?: number; add?: number; except?: number; edges?: string[]; total?: number } | null; error?: string };
};
export default function PronunciationPanel({ project }: { project: string }) {
@@ -235,8 +235,23 @@ export default function PronunciationPanel({ project }: { project: string }) {
{v === "add" ? "Mask it" : v === "except" ? "Never mask it" : "Back to the list"}
</button>
))}
+ {/* An EDGE mask (posts slurs edges): that slur's every form first letter, stars, last letter ("n***a"). */}
+ {([false, true] as const).map((off) => (
+ <button
+ key={String(off)}
+ type="button"
+ data-slurs-word-op={off ? "edges-off" : "edges"}
+ disabled={busy || !slurWord.trim()}
+ onClick={() => void post({ op: "slurs", verb: "edges", value: slurWord, off }).then((ok) => ok && setSlurWord(""))}
+ className={buttonVariants({ variant: "quiet", size: "sm" })}
+ title={off ? "back to the first-letter mask" : "every form of that slur masked first letter, stars, last letter, in the case written"}
+ >
+ {off ? "First letter only" : "Edge mask"}
+ </button>
+ ))}
<span className="text-muted">
{view?.slurs?.json?.add ?? 0} added · {view?.slurs?.json?.except ?? 0} excepted
+ {view?.slurs?.json?.edges?.length ? <span data-slurs-edges=""> · edges: {view.slurs.json.edges.join(", ")}</span> : null}
</span>
</div>
</section>
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -107,7 +107,7 @@ Inbox cannot disagree about what is wrong with one.
| `posts fit <project> [--all \| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]` | narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is |
| `posts avatar <project> [<handle> <image-file> \| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]` | the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one |
| `posts redact <project> ls \| add "<term>" [--substring] [--note "…"] \| remove <n> [--json]` | **REDACTED WORDS** ([knobs.md](knobs.md#redacted-words-blanked-from-what-is-published)): the project's list (`render.posts.redact`, `updatePostRedact`) of words or phrases blanked from everything the cut publishes -- a solid bar on the rendered card, left out of a synthesized read, a post's chapter line and an attachment's captions; matched without case, as whole words (`--substring`: inside words too), a phrase across any spaces or punctuation. The posts' words and the scripts are never rewritten. `ls` numbers the terms as `remove` takes them, and counts the corpus's (`transcripts/redactions.json`) and the posts marked up in the cut's channels (`posts-markup.json`). A term already listed is refused (**exit 1**) |
-| `posts slurs <project> [ls] \| on \| off \| level strong\|all \| visual blackout\|placeholder \| voice skip\|beep\|placeholder \| add <word> \| except <word> \| remove <word> [--json]` | **THE SLUR FILTER** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): `render.posts.slurs` (`updatePostSlurs`, one undo point each), on by default -- the slurs of the shipped list (`report-to-video/slurs.json`; `level strong`: only the strong ones) and the project's own (`add`; `except` never masks one) masked in everything the cut publishes: a dark pill with its mask (`visual placeholder`, the default, "f*****") or a bar (`blackout`) on the card; said and beeped by the take's word timings (`voice beep`, the default), left out of a synthesized read (`skip`), or its stand-in said (`placeholder`). `ls` counts what the cut masks per slur and per post -- masks only, never the word -- and names each narrated post whose take says one with no word timings (a censored build refuses it; `posts narrate <p> <item> --words`). `off` is the uncensored cut (the redaction stays). A word already on a list, or on neither for `remove`, is refused (**exit 1**); an unknown verb or value (**exit 2**) |
+| `posts slurs <project> [ls] \| on \| off \| level strong\|all \| visual blackout\|placeholder \| voice skip\|beep\|placeholder \| add <word> \| except <word> \| remove <word> \| edges <word> [--off] [--json]` | **THE SLUR FILTER** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): `render.posts.slurs` (`updatePostSlurs`, one undo point each), on by default -- the slurs of the shipped list (`report-to-video/slurs.json`; `level strong`: only the strong ones) and the project's own (`add`; `except` never masks one) masked in everything the cut publishes: a dark pill with its mask (`visual placeholder`, the default, "f*****") or a bar (`blackout`) on the card; said and beeped by the take's word timings (`voice beep`, the default), left out of a synthesized read (`skip`), or its stand-in said (`placeholder`). `edges <word>` EDGE-masks that slur (its word, id or a form names it; `render.posts.slurs.edges`): every form first letter, stars, last letter, in the case written ("n***a", "f****t"), `--off` back to the first letter; a word naming no slur is refused (**exit 2**). `ls` counts what the cut masks per slur and per post -- masks only, never the word -- and names each narrated post whose take says one with no word timings (a censored build refuses it; `posts narrate <p> <item> --words`). `off` is the uncensored cut (the redaction stays). A word already on a list, or on neither for `remove`, is refused (**exit 1**); an unknown verb or value (**exit 2**) |
| `posts context <project> [--dry-run] [--json]` | every **post item's context from its capture** (`postContext.mjs`): the post it quotes and the post it answers, as its page showed them (`capture.json`'s `context`, read by the editor's `capture-posts` -- `"contextOnly": true` reads it alone), filled where the archive row lacks them -- `quoted` where the entry has none (or a named one with no words, the same post), `parents` where it has none (a thread shot stays on the entry; the card draws the parents). An x.com/twitter.com **status link** in its words (or its row's links) is a quote: the post it names, from any channel's archive, fills `quoted` (`via: "link"`) when it has none; the row's `threadId` is snapshotted as the item's `conversation` (the thread walk reads it). What the archive gave is never replaced. ONE write for every entry (`setPostItemsContext`: one undo point, refused whole in the build's words); a re-run with nothing new writes nothing. A post whose capture read no context is listed with the call that reads it (`pnpm ops capture-posts --json '{"slug":…,"ids":[…],"contextOnly":true}' --wait`). The card's blur of other authors is unchanged ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)) |
| `posts repeats <project> [--match id\|file\|audio] [--json]` | the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only |
| `posts attach <project> [<item> … \| --all] [--dry-run] [--json]` | a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -749,7 +749,7 @@ and the word spelt out letter by letter with ONE space, dot, dash or underscore
snapshot and every script keep their words.
- **The card** (`visual`): `placeholder` (the default), a dark pill holding the mask (`data-post-slur`), the first letter in the case the post wrote it -- the same mask for the same
- slur across the cut, and never the word in the card's HTML; `blackout`, the redaction's solid bar (no letters in the page). Its words, the authors' names, the repost line, the
+ slur across the cut, and never the word in the card's HTML -- or, for a slur named in `edges`, its **edge mask**: every form its first letter, an asterisk for each letter between and its LAST letter, each end in the case the post wrote it ("n***a", "n****s", "f****t", "N***A"; a look-alike at an end read back as its letter), so a form is told apart from another (the operator, 5 Nov: the "-a" form shown as it is, not as "-er"). One mask per hit (`post-slurs.mjs` `maskOfHit`) is what the pill, Play, the bench, a chapter line, a caption and `ls` all show; `blackout`, the redaction's solid bar (no letters in the page). Its words, the authors' names, the repost line, the
posts it answers and quotes, a paraphrase; a video attachment's burnt-in captions (left out under blackout, the mask
under placeholder) and a chapter line (the mask). A slur spelt apart keeps its tokens, so a word zoom's indices hold;
a zoom on a masked word is refused, as on a redacted one.
@@ -775,7 +775,8 @@ snapshot and every script keep their words.
| `render.posts.slurs.visual` — `placeholder` (default) \| `blackout` | the Cut tab's Options → **Reads and voices** → Slur filter, **visual**; Play, **As published** | `umtool posts slurs <p> visual blackout\|placeholder` | — |
| `render.posts.slurs.voice` — `beep` (default) \| `skip` \| `placeholder` | the Cut tab's Options → **Reads and voices** → Slur filter, **voice** | `umtool posts slurs <p> voice skip\|beep\|placeholder` | — |
| `render.posts.slurs.add` — the project's own words (always masked; a word, or `{word, forms?, mask?, say?}`) · `.except` — never masked here (a form, a slur's word or its id) | the Cut tab's Options → **Reads and voices** → Slur filter: a word, **Mask it** · **Never mask it** · **Back to the list** | `umtool posts slurs <p> add <word>` · `except <word>` · `remove <word>` (one writer, `updatePostSlurs`) | — |
-| what the cut masks | the Cut tab's Options → **Reads and voices** → Slur filter (how many masked) | `umtool posts slurs <p> ls [--json]`: per slur (its mask, never the word) and per post, and each read that needs word timings | — |
+| `render.posts.slurs.edges` — the slurs EDGE-masked (a slur's word, its id or any of its forms names the whole slur, a listed one or the project's own): every form first letter, stars, last letter, in the case written ("n***a", "f****t"); absent, the first-letter mask | the Cut tab's Options → **Reads and voices** → Slur filter: a word, **Edge mask** · **First letter only** (the edges listed by mask) | `umtool posts slurs <p> edges <word>` · `edges <word> --off` (one writer, `updatePostSlurs`; a word naming no slur is refused, exit 2) · `ls` says `edges: n***a, f-slur` | — |
+| what the cut masks | the Cut tab's Options → **Reads and voices** → Slur filter (how many masked) | `umtool posts slurs <p> ls [--json]`: per slur (its mask, never the word; an edged slur each form's mask, "/" between) and per post, and each read that needs word timings | — |
## Pronunciation and voices (the lexicon, the voice map, a thread read)
diff --git a/umtool/e2e/post-items.spec.ts b/umtool/e2e/post-items.spec.ts
@@ -161,6 +161,18 @@ test("the slur filter: As published (censored) draws the placeholder pill and ne
expect(dom.toLowerCase()).not.toContain("video.");
expect(dom.toLowerCase()).not.toContain("here is");
if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-items-slurs-censored.png") });
+ // An EDGE mask (posts slurs edges; knobs.md): the same pill, its first letter, stars and its last letter.
+ umtool(["posts", "slurs", PROJECT, "edges", "video"]);
+ expect(umtool(["posts", "slurs", PROJECT, "ls"])).toContain("edges: v***o");
+ await page.reload();
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-vid");
+ await expect(page.locator("[data-play-as-published]")).toBeChecked();
+ await expect(card.locator("[data-post-slur]")).toHaveText("v***o");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-items-slurs-edge.png") });
+ umtool(["posts", "slurs", PROJECT, "edges", "video", "--off"]);
+ await page.reload();
+ await expect(page.locator("[data-play-as-published]")).toBeChecked();
+ await expect(card.locator("[data-post-slur]")).toHaveText("*****");
// UNCENSORED: the word as posted; the redaction is not part of the switch.
await page.locator("[data-play-uncensored]").check();
await expect(page.locator("label:has([data-play-as-published])")).toContainText("As published (uncensored)");
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -3159,16 +3159,19 @@ export async function updatePostProgressRender(dir, mode, { token = null } = {})
* visual?, voice? } }` sets its knobs (a null: back to the default), `{ add:
* "<word>" }` masks a word of the project's own, `{ except: "<word>" }` never
* masks one (a form, a slur's word or its id), `{ remove: "<word>" }` takes a
- * word off both lists. A word already on the list it is added to is refused.
- * The posts' words are never touched. Validated with the build's check.
+ * word off both lists. `{ edge: "<word>" }` EDGE-masks a slur (`edges`: a
+ * word, id or form naming it -- every form drawn first letter, stars, last
+ * letter), `{ unedge: "<word>" }` takes it off. A word already on the list it
+ * is added to is refused. The posts' words are never touched. Validated with
+ * the build's check.
*
* @param {string} dir
- * @param {{ set?: Record<string, unknown>, add?: string, except?: string, remove?: string }} change
+ * @param {{ set?: Record<string, unknown>, add?: string, except?: string, remove?: string, edge?: string, unedge?: string }} change
* @param {{ token?: string | null }} [opts]
*/
export async function updatePostSlurs(dir, change, { token = null } = {}) {
- const ops = ["set", "add", "except", "remove"].filter((k) => isObj(change) && change[k] !== undefined);
- if (ops.length !== 1) throw new Error("say set, add, except or remove");
+ const ops = ["set", "add", "except", "remove", "edge", "unedge"].filter((k) => isObj(change) && change[k] !== undefined);
+ if (ops.length !== 1) throw new Error("say set, add, except, remove, edge or unedge");
return structural(dir, "post-slurs", token, (m) => {
if (!isObj(m.render)) m.render = {};
const posts = isObj(m.render.posts) ? m.render.posts : {};
@@ -3190,12 +3193,18 @@ export async function updatePostSlurs(dir, change, { token = null } = {}) {
// A word is added or excepted, never both.
const other = key === "add" ? "except" : "add";
if (Array.isArray(sl[other])) sl[other] = sl[other].filter((x) => word(typeof x === "string" ? x : x?.word) !== w);
+ } else if (change.edge !== undefined || change.unedge !== undefined) {
+ const w = word(change.edge ?? change.unedge);
+ const on = has(sl.edges, w);
+ if (change.edge !== undefined && on) throw new Error("that word is already on the edges list");
+ if (change.unedge !== undefined && !on) throw new Error("that word is not on the edges list");
+ sl.edges = change.edge !== undefined ? [...(Array.isArray(sl.edges) ? sl.edges : []), w] : sl.edges.filter((x) => word(x) !== w);
} else {
const w = word(change.remove);
if (!has(sl.add, w) && !has(sl.except, w)) throw new Error("that word is on neither list (add, except)");
for (const k of ["add", "except"]) if (Array.isArray(sl[k])) sl[k] = sl[k].filter((x) => word(typeof x === "string" ? x : x?.word) !== w);
}
- for (const k of ["add", "except"]) if (Array.isArray(sl[k]) && !sl[k].length) delete sl[k];
+ for (const k of ["add", "except", "edges"]) if (Array.isArray(sl[k]) && !sl[k].length) delete sl[k];
if (Object.keys(sl).length) posts.slurs = sl;
else delete posts.slurs;
if (Object.keys(posts).length) m.render.posts = posts;
diff --git a/umtool/lib/report/postSlurs.test.mjs b/umtool/lib/report/postSlurs.test.mjs
@@ -72,6 +72,41 @@ test("posts slurs ls: what the cut would mask, per slur and per post, masks only
assert.match((await cli(["slurs", "ls", "ls"])).out, /p-3 +beeped \(1 span\(s\)\)/);
});
+test("posts slurs edges <word> [--off]: one writer; ls says the edges and the masks, never the word", async () => {
+ const NA = LIST.entries.find((e) => e.id === "n-word").forms.find((f) => f.length === 5 && f.endsWith("a"));
+ const p = await project("edges", [item("1", { text: `you ${F}, ${NA}` })]);
+ const run = async (...a) => {
+ const r = await cli(["slurs", "edges", ...a]);
+ for (const w of [F, NA]) assert.ok(!(r.out + r.err).toLowerCase().includes(w), "no line prints a slur");
+ return r;
+ };
+ let r = await run("edges", NA);
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /n\*\*\*a: edge-masked/);
+ assert.deepEqual(JSON.parse((await run("edges", "f-slur", "--json")).out).slurs.edges, ["n***a", "f-slur"], "a write's JSON shows the edges by mask");
+ assert.deepEqual((await manifest(p)).render.posts.slurs, { edges: [NA, "f-slur"] });
+ r = await run("ls");
+ assert.match(r.out, /edges: n\*\*\*a, f-slur \(first letter, stars, last letter\)/);
+ assert.match(r.out, /f\*{4}t +f-slur +×1/);
+ assert.match(r.out, /n\*{3}a +n-word +×1/);
+ const j = JSON.parse((await run("ls", "--json")).out);
+ assert.deepEqual(j.edges, ["n***a", "f-slur"]);
+ assert.equal(j.bySlur["n-word"].mask, "n***a");
+ assert.equal((await run("edges", NA)).code, 1, "already on the edges list");
+ assert.equal((await run("edges", "zorbo")).code, 2, "names no slur");
+ assert.equal((await run("edges")).code, 2);
+ r = await run("edges", NA, "--off");
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /n\*\*\*a: back to the first-letter mask/);
+ assert.equal((await run("edges", NA, "--off")).code, 1, "not on the edges list");
+ await run("edges", "f-slur", "--off");
+ assert.equal((await manifest(p)).render.posts, undefined, "no edges, no key");
+ // The project's own word may be edged too (added first).
+ await run("add", "zorbo");
+ assert.match((await run("edges", "zorbo")).out, /z\*\*\*o: edge-masked/);
+ assert.equal((await manifest(p)).timeline[0].text, `you ${F}, ${NA}`, "the snapshot is never rewritten");
+});
+
test("posts slurs on|off|level|visual|voice|add|except|remove: one writer, refused in the build's words, the posts untouched", async () => {
const p = await project("w", [item("1", { text: `a ${F} and a zorbo` })]);
const ok = async (...a) => {
diff --git a/umtool/lib/report/postSlursCli.mjs b/umtool/lib/report/postSlursCli.mjs
@@ -8,21 +8,23 @@
// umtool posts slurs <p> visual blackout|placeholder
// umtool posts slurs <p> voice skip|beep|placeholder
// umtool posts slurs <p> add <word> | except <word> | remove <word>
+// umtool posts slurs <p> edges <word> [--off] that slur EDGE-masked ("n***a"): its word, id or a form names it
//
// Every write goes through updatePostSlurs (one undo point each). Nothing
// here prints a slur: a word is shown as its mask.
//
// Plain ESM: the CLI runs under bare node.
import { isNarrated, pickedTake, rootTakeOf } from "umtool-report-to-video/post-narration";
-import { SLURS_DEFAULTS, SLUR_LEVELS, SLUR_VISUALS, SLUR_VOICES, maskOfOwnWord, slurReport, takeBleeps } from "umtool-report-to-video/post-slurs";
-import { cutSlurs } from "umtool-report-to-video/post-redact-files";
+import { SLURS_DEFAULTS, SLUR_LEVELS, SLUR_VISUALS, SLUR_VOICES, edgeMask, maskOfOwnWord, slurReport, takeBleeps } from "umtool-report-to-video/post-slurs";
+import { cutSlurs, defaultSlurList } from "umtool-report-to-video/post-redact-files";
import { readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
import { manifestToken, updatePostSlurs } from "./manifest.mjs";
export const SLURS_USAGE = [
" umtool posts slurs <project> [ls] | on | off | level strong|all | visual blackout|placeholder",
- " | voice skip|beep|placeholder | add <word> | except <word> | remove <word> [--json]",
+ " | voice skip|beep|placeholder | add <word> | except <word> | remove <word>",
+ " | edges <word> [--off] [--json]",
" THE SLUR FILTER (render.posts.slurs; on by default): every slur on the list (umtool/report-to-video/slurs.json,",
" strong and mild; `level strong` masks only the strong) masked in what the cut PUBLISHES -- matched whole-word,",
" without case, through look-alike letters and a word spelt out. visual: placeholder (default: a dark pill with",
@@ -32,6 +34,8 @@ export const SLURS_USAGE = [
" a censored build refuses one with none. `ls` counts what the cut would mask (masks only, never the word), per",
" slur and per post, and says which reads still need word timings. off -- or `umtool take … --uncensored` -- is",
" the uncensored cut; the redaction and censored attachments stay on. add/except/remove: the project's own words.",
+ " edges <word>: that slur (its word, id or any form names it) EDGE-masked -- every form its first letter, stars and",
+ " its LAST letter, in the case written (\"n***a\", \"f****t\": the form is told apart); --off back to the first letter.",
].join("\n");
export class SlursError extends Error {
@@ -42,6 +46,23 @@ export class SlursError extends Error {
}
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const lc = (v) => String(v ?? "").trim().toLowerCase();
+
+/** The slur an edge names (a listed slur's id, word or form, or the project's own word), or null. */
+function edgeEntryOf(name, cfg) {
+ const w = lc(name);
+ const listed = (defaultSlurList()?.entries ?? []).find((e) => e.id === w || e.word === w || (e.forms ?? []).includes(w));
+ if (listed) return listed;
+ const own = (Array.isArray(cfg?.add) ? cfg.add : []).find((a) => [lc(typeof a === "string" ? a : a?.word), ...(Array.isArray(a?.forms) ? a.forms.map(lc) : [])].includes(w));
+ return own ? { forms: [lc(typeof own === "string" ? own : own.word), ...(Array.isArray(own?.forms) ? own.forms.map(lc) : [])] } : null;
+}
+
+/** An edge as shown (never the word): a slur's id as it is, else the word's edge mask. */
+export const edgeShown = (name, cfg) => {
+ const w = lc(name);
+ const e = edgeEntryOf(w, cfg);
+ return e?.id === w ? w : edgeMask(e ?? { forms: [w] }, w);
+};
/** What a cut's filter would mask, and the state of each read that holds a slur. */
export function slursListing(manifest) {
@@ -69,12 +90,14 @@ export function slursListing(manifest) {
const reportHas = (report, id, where) => report.posts.some((p) => p.id === id && p.where.includes(where));
/** `umtool posts slurs <p> …` */
-export async function slursCommand(project, rest, { json = false, out = (s) => console.log(s) } = {}) {
+export async function slursCommand(project, rest, { json = false, off = false, out = (s) => console.log(s) } = {}) {
const [sub = "ls", arg] = rest;
const write = async (change) => withEditNotes(project, async () => updatePostSlurs(project.dir, change, { token: await manifestToken(project.dir) }));
const said = async (change, line) => {
const { result } = await write(change);
- out(json ? JSON.stringify({ ok: true, slurs: result.slurs, token: result.token }, null, 2) : `${project.id}: ${line}`);
+ // The edges by their masks (edgeShown): a write's JSON never prints a slur it edged.
+ const shown = Array.isArray(result.slurs?.edges) ? { ...result.slurs, edges: result.slurs.edges.map((w) => edgeShown(w, result.slurs)) } : result.slurs;
+ out(json ? JSON.stringify({ ok: true, slurs: shown, token: result.token }, null, 2) : `${project.id}: ${line}`);
return 0;
};
const one = (list, what) => {
@@ -91,19 +114,29 @@ export async function slursCommand(project, rest, { json = false, out = (s) => c
const what = sub === "add" ? "masked in this cut" : sub === "except" ? "never masked in this cut" : "off the project's lists";
return said({ [sub]: arg }, `${maskOfOwnWord(arg)} is ${what}`);
}
- if (sub !== "ls") throw new SlursError(`posts slurs: ls, on, off, level, visual, voice, add, except or remove (not ${sub})`);
+ if (sub === "edges") {
+ if (!arg || !/^[A-Za-z][A-Za-z-]{1,39}$/.test(arg)) throw new SlursError("posts slurs edges takes a word, a slur's id or one of its forms (letters, 2–40)");
+ const m = await readManifest(project.dir);
+ if (!m) throw new SlursError(`${project.id} has no manifest`);
+ const cfg = isObj(m.render?.posts?.slurs) ? m.render.posts.slurs : {};
+ if (!off && !edgeEntryOf(arg, cfg)) throw new SlursError(`posts slurs edges: ${maskOfOwnWord(arg)} names no slur on the list or of the project's own (add it first)`);
+ const shown = edgeShown(arg, cfg);
+ return said(off ? { unedge: arg } : { edge: arg }, off ? `${shown}: back to the first-letter mask` : `${shown}: edge-masked -- every form its first letter, stars and its last letter, in the case written`);
+ }
+ if (sub !== "ls") throw new SlursError(`posts slurs: ls, on, off, level, visual, voice, add, except, remove or edges (not ${sub})`);
const manifest = await readManifest(project.dir);
if (!manifest) throw new SlursError(`${project.id} has no manifest`);
const { slurs: s, report, reads } = slursListing(manifest);
const cfg = isObj(manifest.render?.posts?.slurs) ? manifest.render.posts.slurs : {};
if (json) {
- out(JSON.stringify({ ok: true, on: s.on, level: s.level, visual: s.visual, voice: s.voice, listed: s.entries.length, add: (cfg.add ?? []).length, except: (cfg.except ?? []).length, total: report.total, bySlur: report.bySlur, posts: report.posts, reads }, null, 2));
+ out(JSON.stringify({ ok: true, on: s.on, level: s.level, visual: s.visual, voice: s.voice, listed: s.entries.length, add: (cfg.add ?? []).length, except: (cfg.except ?? []).length, edges: (cfg.edges ?? []).map((w) => edgeShown(w, cfg)), total: report.total, bySlur: report.bySlur, posts: report.posts, reads }, null, 2));
return 0;
}
out(
`${project.id}: the slur filter is ${s.on ? "ON" : "OFF (the uncensored cut)"} -- level ${s.level}, visual ${s.visual}, voice ${s.voice}` +
` (${s.entries.length} slur(s) listed${cfg.add?.length ? `, ${cfg.add.length} of its own` : ""}${cfg.except?.length ? `, ${cfg.except.length} excepted` : ""})`,
);
+ if (cfg.edges?.length) out(` edges: ${cfg.edges.map((w) => edgeShown(w, cfg)).join(", ")} (first letter, stars, last letter)`);
if (!report.total) {
out(" no post item of the cut holds a slur on the list");
return 0;
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -60,10 +60,12 @@ const REREAD_LINES = [
// `umtool posts slurs` (postSlursCli.mjs SLURS_USAGE): its lines, kept here so the usage is one block.
const SLURS_USAGE_LINES = [
" umtool posts slurs <project> [ls] | on | off | level strong|all | visual blackout|placeholder",
- " | voice skip|beep|placeholder | add <word> | except <word> | remove <word> [--json]",
+ " | voice skip|beep|placeholder | add <word> | except <word> | remove <word>",
+ " | edges <word> [--off] [--json]",
" THE SLUR FILTER (render.posts.slurs, on by default): the list's slurs masked in what the cut publishes (a bar or",
" a placeholder pill on the card; left out, beeped or a stand-in in the read); `ls` counts what it masks (masks",
- " only), off or `umtool take … --uncensored` is the uncensored cut. umtool posts slurs --help: the whole story.",
+ " only), off or `umtool take … --uncensored` is the uncensored cut; edges <word>: that slur first+last letter",
+ " (\"n***a\"). umtool posts slurs --help: the whole story.",
];
// `umtool posts say` / `posts voices` (postSay.mjs SAY_USAGE, VOICES_USAGE): its lines, kept here so the usage is one block.
@@ -589,7 +591,7 @@ export async function postsCommand(args, { root = REPORTS_ROOT, out = (s) => con
err(SLURS_USAGE);
return 2;
}
- return await slursCommand(await projectOf(projectArg, root), words.slice(2), { json, out }).catch((e) => {
+ return await slursCommand(await projectOf(projectArg, root), words.slice(2), { json, off: flags.has("--off"), out }).catch((e) => {
throw e?.name === "SlursError" ? new CliError(e.message) : e;
});
}
diff --git a/umtool/report-to-video/post-slurs.mjs b/umtool/report-to-video/post-slurs.mjs
@@ -19,6 +19,8 @@
// level?: "all" (default) | "strong" strong: only the strong slurs
// add?: ["<word>" | {word, forms?, mask?, say?}] the project's own (always masked)
// except?: ["<form or word>"] never masked in this project
+// edges?: ["<word, id or form>"] those slurs EDGE-masked: every form its first letter, stars, its
+// last letter, in the case written ("n***a" is not "-er")
// visual?: "placeholder" (default) a dark pill with the masked form ("f*****")
// | "blackout" the redaction's solid bar
// voice?: "beep" (default) said, and a tone laid over it at its time
@@ -41,7 +43,7 @@ export const SLUR_VOICES = Object.freeze(["skip", "beep", "placeholder"]);
export const SLURS_DEFAULTS = Object.freeze({ on: true, level: "all", visual: "placeholder", voice: "beep" });
export const SLUR_LIST_LEVELS = Object.freeze(["strong", "mild"]);
export const SLURS_ADD_MAX = 100;
-export const SLUR_KEYS = Object.freeze(["on", "level", "add", "except", "visual", "voice", "note"]);
+export const SLUR_KEYS = Object.freeze(["on", "level", "add", "except", "edges", "visual", "voice", "note"]);
/** The redaction's mark (post-redact.mjs REDACT_MARK): a blacked-out slur is drawn as its bar. */
export const BLACKOUT_MARK = "";
@@ -103,11 +105,14 @@ export function resolveSlurs(cfg, list, { uncensored = false } = {}) {
const c = isObj(cfg) ? cfg : {};
const level = SLUR_LEVELS.includes(c.level) ? c.level : SLURS_DEFAULTS.level;
const ex = new Set((Array.isArray(c.except) ? c.except : []).map(lc).filter(Boolean));
+ const edges = new Set((Array.isArray(c.edges) ? c.edges : []).map(lc).filter(Boolean));
+ // An edge names a slur by its word, its id or any of its forms: the whole slur is edge-masked.
+ const edged = (e) => edges.size > 0 && (edges.has(e.id) || edges.has(e.word) || e.forms.some((f) => edges.has(f)));
const base = (Array.isArray(list?.entries) ? list.entries : []).filter((e) => level === "all" || e.level === "strong");
const added = (Array.isArray(c.add) ? c.add : []).filter((a) => WORD_RE.test(lc(typeof a === "string" ? a : a?.word))).map(addedEntry);
const entries = [...base, ...added]
.filter((e) => !ex.has(e.id) && !ex.has(e.word))
- .map((e) => ({ id: e.id, level: e.level, word: e.word, forms: e.forms.filter((f) => !ex.has(f)), mask: e.mask ?? maskOfWord(e.word), say: e.say, ...(e.added ? { added: true } : {}) }))
+ .map((e) => ({ id: e.id, level: e.level, word: e.word, forms: e.forms.filter((f) => !ex.has(f)), mask: e.mask ?? maskOfWord(e.word), say: e.say, ...(e.added ? { added: true } : {}), ...(edged(e) ? { edge: true } : {}) }))
.filter((e) => e.forms.length);
return {
on: !uncensored && c.on !== false,
@@ -125,7 +130,7 @@ export const slursOn = (s) => !!s && s.on === true && Array.isArray(s.entries) &
/** Every reason `render.posts.slurs` is refused. */
export function validateSlursRender(s, where = "render.posts.slurs") {
if (s === undefined) return [];
- if (!isObj(s)) return [`${where} must be {on?, level?, add?, except?, visual?, voice?}`];
+ if (!isObj(s)) return [`${where} must be {on?, level?, add?, except?, edges?, visual?, voice?}`];
const errors = [];
for (const k of Object.keys(s)) if (!SLUR_KEYS.includes(k)) errors.push(`${where}.${k} is not a knob of the slur filter (${SLUR_KEYS.join(", ")})`);
if (s.on !== undefined && typeof s.on !== "boolean") errors.push(`${where}.on must be true or false`);
@@ -133,7 +138,7 @@ export function validateSlursRender(s, where = "render.posts.slurs") {
if (s.visual !== undefined && !SLUR_VISUALS.includes(s.visual)) errors.push(`${where}.visual must be one of ${SLUR_VISUALS.join(", ")}`);
if (s.voice !== undefined && !SLUR_VOICES.includes(s.voice)) errors.push(`${where}.voice must be one of ${SLUR_VOICES.join(", ")}`);
if (s.note !== undefined && typeof s.note !== "string") errors.push(`${where}.note must be words`);
- for (const key of ["add", "except"]) {
+ for (const key of ["add", "except", "edges"]) {
const list = s[key];
if (list === undefined) continue;
if (!Array.isArray(list) || list.length > SLURS_ADD_MAX) {
@@ -142,7 +147,7 @@ export function validateSlursRender(s, where = "render.posts.slurs") {
}
list.forEach((a, i) => {
const w = `${where}.${key}[${i}]`;
- if (key === "except" || typeof a === "string") {
+ if (key !== "add" || typeof a === "string") {
if (typeof a !== "string" || !/^[a-z0-9-]{2,40}$/.test(lc(a))) errors.push(`${w} must be a word (letters, 2–40)`);
return;
}
@@ -216,14 +221,56 @@ export const slurEntryOf = (s, id) => (Array.isArray(s?.entries) ? s.entries.fin
export const maskOfOwnWord = (word) => "*".repeat(Math.max(1, str(word).length));
export const maskOfWord = (word) => (str(word) ? `${str(word)[0]}${"*".repeat(Math.max(1, str(word).length - 1))}` : "*");
-/** The masked form a hit is drawn as: the slur's mask, its first letter in the case the text wrote it. */
-export function maskFor(s, hit, matched) {
- const e = slurEntryOf(s, hit.id);
- const mask = e?.mask ?? "*****";
+/** A slur as written with a spelt-apart word's separators gone: one character per letter (a look-alike is one too). */
+const lettersOf = (matched) => str(matched).replace(/[\s.\-_]/g, "");
+const isUpper = (c) => /\p{L}/u.test(c) && c !== c.toLowerCase();
+const isLower = (c) => /\p{L}/u.test(c) && c !== c.toUpperCase();
+
+/**
+ * An EDGE mask (`render.posts.slurs.edges`): the form as written, its first
+ * letter, an asterisk for each letter between, its last letter -- each end the
+ * form's own letter (a look-alike, "@" or "0", read back as the letter it
+ * stands for) in the case the text wrote it; a look-alike at an end follows
+ * the word's case (upper only when every letter is). Two letters: the first
+ * and one asterisk.
+ *
+ * @param {{ forms?: string[], mask?: string } | null | undefined} entry
+ * @param {string} matched the slur as the text wrote it
+ */
+export function edgeMask(entry, matched) {
+ const w = lettersOf(matched);
+ if (w.length < 2) return entry?.mask ?? "*****";
+ const forms = Array.isArray(entry?.forms) ? entry.forms : [];
+ const form = forms.find((f) => f.length === w.length && new RegExp(`^${[...f].map(letterRe).join("")}$`, "iu").test(w)) ?? w.toLowerCase();
+ const letters = [...w].filter((c) => /\p{L}/u.test(c));
+ const allUpper = letters.length > 1 && letters.every(isUpper);
+ const at = (i) => {
+ const c = form[i];
+ const as = w[i];
+ return isUpper(as) || (!isLower(as) && !isUpper(as) && allUpper) ? c.toUpperCase() : c.toLowerCase();
+ };
+ return w.length === 2 ? `${at(0)}*` : `${at(0)}${"*".repeat(w.length - 2)}${at(w.length - 1)}`;
+}
+
+/**
+ * THE MASK A HIT IS DRAWN AS -- the one source for every place a mask is
+ * shown (the card's pill, Play, the bench, a chapter line, a burnt-in
+ * caption, `posts slurs ls`): an edged slur's edge mask (edgeMask); else the
+ * slur's mask, its first letter in the case the text wrote it.
+ *
+ * @param {{ mask?: string, edge?: boolean, forms?: string[] } | null | undefined} entry the slur's entry in the filter (resolveSlurs)
+ * @param {string} matched the slur as the text wrote it
+ */
+export function maskOfHit(entry, matched) {
+ if (entry?.edge && lettersOf(matched).length >= 2) return edgeMask(entry, matched);
+ const mask = entry?.mask ?? "*****";
const first = str(matched)[0] ?? "";
return first && first !== first.toLowerCase() && /\p{L}/u.test(first) ? mask[0].toUpperCase() + mask.slice(1) : mask;
}
+/** The masked form a hit is drawn as (maskOfHit, its entry found in the filter). */
+export const maskFor = (s, hit, matched) => maskOfHit(slurEntryOf(s, hit.id), matched);
+
/** The words a read says in a hit's place (voice placeholder). */
export const sayFor = (s, hit) => slurEntryOf(s, hit.id)?.say ?? "slur";
@@ -318,7 +365,7 @@ export function takeBleeps(take, s, { script = undefined, state = undefined } =
if (!hits.length) return null;
const words = Array.isArray(take.words) ? take.words : [];
const toks = scriptTokens(text);
- const masks = [...new Set(hits.map((h) => maskFor(s, h, "")))].join(", ");
+ const masks = [...new Set(hits.map((h) => maskFor(s, h, text.slice(h.start, h.end).toLowerCase())))].join(", ");
if (!words.length) return { error: `its take ${take.file ?? ""} says ${hits.length} slur(s) (${masks}) and has no word timings to ${s.voice === "skip" ? "silence" : "beep"} them by` };
if (words.length !== toks.length) return { error: `its take ${take.file ?? ""}'s word timings are not of its script (${words.length} timed, ${toks.length} in the script)` };
const spans = [];
@@ -389,6 +436,7 @@ export function slurReport(timeline, s) {
const on = { ...s, on: true };
const posts = [];
const bySlur = {};
+ const edgeMasks = {};
let total = 0;
for (const e of Array.isArray(timeline) ? timeline : []) {
if (e?.type !== "post") continue;
@@ -400,7 +448,14 @@ export function slurReport(timeline, s) {
where.add(w.replace(/\[\d+\]/, ""));
total += 1;
const se = slurEntryOf(on, h.id);
- const b = (bySlur[h.id] ??= { mask: se?.mask ?? "*", n: 0, posts: [], ...(se?.added ? { added: true } : {}) });
+ const b = (bySlur[h.id] ??= { mask: se?.mask ?? "*", n: 0, posts: [], ...(se?.added ? { added: true } : {}), ...(se?.edge ? { edge: true } : {}) });
+ // An edged slur's masks are its forms' (maskOfHit, lower case): each one the cut draws, "/" between.
+ if (se?.edge) {
+ const m = maskOfHit(se, text.slice(h.start, h.end).toLowerCase());
+ const seen = (edgeMasks[h.id] ??= []);
+ if (!seen.includes(m)) seen.push(m);
+ b.mask = seen.join("/");
+ }
b.n += 1;
if (!b.posts.includes(e.id)) b.posts.push(e.id);
}
diff --git a/umtool/report-to-video/post-slurs.test.mjs b/umtool/report-to-video/post-slurs.test.mjs
@@ -183,6 +183,65 @@ test("slurReport counts what the cut would mask, per slur and per post; cutSlurS
assert.equal(cutSlurs({ render: { posts: { slurs: { level: "strong" } } } }).level, "strong");
});
+// EDGE MASKS (render.posts.slurs.edges; operator, 5 Nov): the n-word's "-a" form and the f-slur told apart by
+// their last letter. The forms are taken from the list by shape, never spelt here.
+const NA = byId("n-word").forms.find((f) => f.length === 5 && f.endsWith("a"));
+const NAS = byId("n-word").forms.find((f) => f.length === 6 && f.endsWith("s") && f.startsWith(NA.slice(0, 4)));
+const NER = byId("n-word").forms.find((f) => f.endsWith("r") && f.length === 6);
+const star = (w) => `${w[0]}${"*".repeat(w.length - 2)}${w.at(-1)}`;
+
+test("edge masks: every form of an edged slur its first letter, stars, its last letter, in the case written", () => {
+ const E = resolveSlurs({ edges: [NA, F] }, LIST);
+ const shown = (t, s = E) => decodePlaceholder(maskSlurs(t, s).text);
+ // The operator's examples, by shape: n***a, n****s, f****t, f*****s, N***A.
+ assert.equal(star(NA), "n***a");
+ assert.equal(shown(NA), "n***a");
+ assert.equal(shown(NAS), "n****s");
+ assert.equal(shown(F), "f****t");
+ assert.equal(shown(FS), "f*****s");
+ assert.equal(shown(NA.toUpperCase()), "N***A");
+ assert.equal(shown(`${NA[0].toUpperCase()}${NA.slice(1)}`), "N***a", "each end in its own case");
+ // A form names the WHOLE slur: its other forms are edge-masked too (the "-er" one is told apart as well).
+ assert.equal(shown(NER), "n****r");
+ // By its id, or its word, the same.
+ assert.equal(shown(F, resolveSlurs({ edges: ["f-slur"] }, LIST)), "f****t");
+ assert.equal(shown(NA, resolveSlurs({ edges: [byId("n-word").word] }, LIST)), "n***a");
+ // A look-alike at an end is read back as its letter; spelt apart, one pill, the rest gaps (the indices hold).
+ assert.equal(shown(leet(F)), "f****t");
+ assert.equal(shown(`${NA.slice(0, 4)}@`), "n***a");
+ assert.equal(shown(`${NA.slice(0, 4)}@`.toUpperCase()), "N***A", "a look-alike end follows an all-caps word");
+ const sp = maskSlurs(`a ${spaced(F)} b`, E).text;
+ assert.equal(sp.split(/\s+/).length, `a ${spaced(F)} b`.split(/\s+/).length);
+ assert.equal(placeholdersHtml(sp), `a <span class="slur" data-post-slur="">f****t</span>${" ".repeat(F.length - 1)} b`);
+ // Only the slurs named: another keeps its first-letter mask.
+ assert.equal(shown(R), `${R[0]}${"*".repeat(R.length - 1)}`);
+ // The card's pill, a caption, the chapter line: all through the one mask.
+ const html = postCardHtml(post(`you ${F}, ${NA.toUpperCase()}`), { width: 1280, height: 720, redaction: { terms: [], slurs: E } });
+ assert.ok(html.includes('data-post-slur="">f****t</span>') && html.includes('data-post-slur="">N***A</span>'));
+ for (const w of [F, NA]) assert.ok(!html.toLowerCase().includes(w));
+ assert.equal(shownLine(`you ${F}`, post("x"), { terms: [], slurs: E }), "you f****t");
+ // ls / slurReport: each form's mask the cut draws, "/" between.
+ const r = slurReport([post(`${F} ${FS} ${F.toUpperCase()}`, { id: "a" })], E);
+ assert.deepEqual(r.bySlur["f-slur"], { mask: "f****t/f*****s", n: 3, posts: ["a"], edge: true });
+ // A take's refusal names the edge mask too.
+ assert.match(takeBleeps({ file: "t.wav", script: `said ${NA}` }, E).error, /\(n\*\*\*a\)/);
+ // The read is not a mask: the stand-in is said as before.
+ assert.deepEqual(spokenRead(`a ${NA}`, post("x"), { terms: [], slurs: resolveSlurs({ edges: [NA], voice: "placeholder" }, LIST) }), { text: "a n-word", slurs: "placeholder" });
+});
+
+test("edge masks: refused when not words; a cut without edges is unchanged (no key on an entry, the same masks)", () => {
+ assert.deepEqual(validateSlursRender({ edges: [NA, "f-slur"] }), []);
+ const errs = validateSlursRender({ edges: "x" }).concat(validateSlursRender({ edges: [3, ""] })).join(" | ");
+ assert.match(errs, /edges must be a list/);
+ assert.match(errs, /edges\[0\]/);
+ assert.match(errs, /edges\[1\]/);
+ // Without edges: no entry carries `edge`, so the render key and every mask are as before.
+ assert.ok(ON.entries.every((e) => !("edge" in e)));
+ assert.deepEqual(resolveSlurs({ edges: [] }, LIST), ON);
+ assert.equal(decodePlaceholder(maskSlurs(`${NA} ${F.toUpperCase()}`, ON).text), `n***** F*****`);
+ assert.equal(slurReport([post(`${F} ${FS}`, { id: "a" })], ON).bySlur["f-slur"].mask, `${F[0]}*****`);
+});
+
test("barsHtml draws placeholders and gaps with the redaction's bars", () => {
const html = barsHtml(`${REDACT_MARK.repeat(3)} ${encodePlaceholder("k***")}${SLUR_GAP}`);
assert.equal(html, `<span class="rbar" data-post-blanked="" style="width:1.56em"></span> <span class="slur" data-post-slur="">k***</span>`);