Strip all angle brackets in PF2e attack traits and damage
All checks were successful
CI / check (push) Successful in 2m23s
CI / build-image (push) Successful in 17s

Broaden stripDiceBrackets to stripAngleBrackets to handle all
PF2e tools angle-bracket formatting (e.g. <10 feet>, <15 feet>),
not just dice notation. Also strip in damage text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-07 15:34:28 +02:00
parent 12a089dfd7
commit 3e62e54274
2 changed files with 36 additions and 6 deletions

View File

@@ -114,8 +114,8 @@ describe("normalizePf2eBestiary", () => {
});
});
describe("attack traits formatting", () => {
it("strips angle-bracket dice notation from traits", () => {
describe("attack formatting", () => {
it("strips angle brackets from traits", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
@@ -140,6 +140,34 @@ describe("normalizePf2eBestiary", () => {
}),
);
});
it("strips angle brackets from reach values in traits", () => {
const [creature] = normalizePf2eBestiary({
creature: [
minimalCreature({
attacks: [
{
name: "tentacle",
range: "Melee",
attack: 18,
traits: ["agile", "chaotic", "magical", "reach <10 feet>"],
damage: "2d8+6 piercing",
},
],
}),
],
});
const attack = creature.attacks?.[0];
expect(attack).toBeDefined();
expect(attack?.segments[0]).toEqual(
expect.objectContaining({
type: "text",
value: expect.stringContaining(
"(agile, chaotic, magical, reach 10 feet)",
),
}),
);
});
});
describe("resistances formatting", () => {