UX S3: SRD copy-edit pass — sanitize jargon + curated overrides

Plumbed through the open5e importer so regen stays safe:

- New cmd/open5e-import/desc_overrides.go holds two per-ID override
  maps (spellDescOverride, magicItemDescOverride) and a regex-driven
  cleanDesc sanitizer. Override wins outright; otherwise the SRD
  first-sentence runs through cleanDesc, which strips the phrases
  the S3 acceptance criteria forbid (saving throw[s], spell slot,
  within range, 5-foot, DC <n>, "(save DC X)" parentheticals,
  "constitution score is N", "out to a range of N feet"). A small
  post-pass repairs the orphan stubs the strippers leave behind
  (" and." trailers, "must make." after the saving-throw object
  is gone).

- gen.go (spells) + magicitems.go now call spellDescription /
  magicItemDescription instead of raw firstSentence; same hand-
  authored override pattern, same cleanDesc fallthrough.

- Override coverage: the 19 SRD-only spells that show up in
  defaultKnownSpells (call_lightning, charm_person, vicious_mockery,
  …) plus ~35 high-visibility magic items (Amulet of Health, every
  Belt of Giant Strength variant, Cloak of Displacement, etc.).
  Tone is outcome-first second-person with bite — these surface
  in the spellbook and the curio shop, so they get to be funny.

- tuned.go (R21) + magicitems.go strip "(...)" from emitted Names
  via stripNameParenthetical. Slug keeps the variant; only the
  display text loses the qualifier. Two bestiary entries
  (giant_rat_diseased, deep_gnome_svirfneblin) and stone_of_good_luck
  affected.

- Regenerated all three data files. Acceptance grep is clean:
  zero hits for any banned phrase in Description/Desc fields.

- New cmd/open5e-import/desc_overrides_test.go covers the
  sanitizer regressions, orphan-repair, name-strip, and the
  override-wins-but-fallthrough-still-sanitizes path.

Conflicts: none. S4 (magic-item UX) wanted this in first so the
new curio renderer consumes clean text — ready for it now.
This commit is contained in:
prosolis
2026-05-14 21:53:06 -07:00
parent c48e12a296
commit 1512f6cc50
8 changed files with 474 additions and 169 deletions

View File

@@ -142,7 +142,7 @@ func classify(s open5eSpell, classes []string) genSpell {
School: strings.ToLower(strings.TrimSpace(s.School)),
Classes: classes,
Concentration: s.RequiresConcentration,
Description: firstSentence(desc, 200),
Description: spellDescription(strings.ReplaceAll(s.Slug, "-", "_"), desc),
Upcast: firstSentence(strings.TrimSpace(s.HigherLevel), 200),
AOE: looksAOE(low),
}
@@ -240,6 +240,16 @@ func looksAOE(low string) bool {
return false
}
// spellDescription returns the description text emitted for a spell. A
// hand-authored override in spellDescOverride wins outright; otherwise the
// SRD first-sentence is run through cleanDesc to strip jargon clauses.
func spellDescription(id, raw string) string {
if s, ok := spellDescOverride[id]; ok {
return s
}
return firstSentence(cleanDesc(raw), 200)
}
// firstSentence trims free-text fields down to a single sentence, capped at
// max runes, so generated Description/Upcast stay terminal-friendly.
func firstSentence(s string, max int) string {