diff --git a/src/anatomy/svgConvention.ts b/src/anatomy/svgConvention.ts index e5b3f2c9..529842da 100644 --- a/src/anatomy/svgConvention.ts +++ b/src/anatomy/svgConvention.ts @@ -53,6 +53,10 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { const opensDetail = el.getAttribute('data-anno-opens-detail') ?? undefined const special = el.getAttribute('data-anno-special') ?? undefined + const lateral = (el.getAttribute('data-anno-lateral') ?? undefined) as + | 'bilateral' + | 'unpaired' + | undefined const existing = map.get(id) if (existing) { @@ -63,6 +67,9 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { if (special && !existing.special) { existing.special = special } + if (lateral && !existing.lateral) { + existing.lateral = lateral + } if (!existing.fr && fr) existing.fr = fr if (!existing.en && en) existing.en = en } else { @@ -73,6 +80,7 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { category, opensDetail, special, + lateral, els: [el], }) } diff --git a/src/anatomy/types.ts b/src/anatomy/types.ts index acb4b7a2..8b3c983c 100644 --- a/src/anatomy/types.ts +++ b/src/anatomy/types.ts @@ -33,6 +33,8 @@ export interface Bone { * Opaque to the parser; new values are accepted without code changes. */ special?: string + /** Laterality hint from data-anno-lateral — bilateral or unpaired */ + lateral?: 'bilateral' | 'unpaired' /** All DOM elements carrying this annotation (used for colorization) */ els: Element[] } diff --git a/tests/unit/anatomy.svgConvention.test.ts b/tests/unit/anatomy.svgConvention.test.ts index d81b44ff..c21e8c29 100644 --- a/tests/unit/anatomy.svgConvention.test.ts +++ b/tests/unit/anatomy.svgConvention.test.ts @@ -22,6 +22,8 @@ const FIXTURE = ` + ` describe('parseSvgBones', () => { @@ -59,6 +61,16 @@ describe('parseSvgBones', () => { 'something-new-the-parser-has-never-seen', ) }) + + it('captures data-anno-lateral when present', () => { + const map = parseSvgBones(svgFromString(FIXTURE)) + expect(map.get('point-knee')?.lateral).toBe('bilateral') + }) + + it('leaves lateral undefined when attribute absent', () => { + const map = parseSvgBones(svgFromString(FIXTURE)) + expect(map.get('point-shoulder')?.lateral).toBeUndefined() + }) }) describe('parseSvgBones validation', () => {