import json,sys,platform from html.parser import HTMLParser import re class Images(HTMLParser): def __init__(self):super().__init__();self.imgs=[];self.links=[];self.link=None def handle_starttag(self,t,a): d=dict(a) if t=='a':self.link={'href':d.get('href',''),'nameParts':[]};self.links.append(self.link) if t=='img': self.imgs.append({'hasAlt':'alt' in d,'alt':d.get('alt'),'src':d.get('src',''),'filenameLike':bool(re.fullmatch(r'(?:IMG[_-]?\d+|[^\s/]+\.(?:png|jpg|webp))',d.get('alt',''),re.I))}) if self.link is not None and d.get('alt'):self.link['nameParts'].append(d['alt']) def handle_endtag(self,t): if t=='a':self.link=None def handle_data(self,x): if self.link is not None and x.strip():self.link['nameParts'].append(x.strip()) fixtures=[ ('missing-alt','','정보가 없는 장식 잎','alt 속성 누락부터 확인'), ('decorative','','본문과 무관한 잎 장식','장식이라는 의미 판정은 사람이 수행'), ('linked-action','CSV 비교 예제 내려받기','아래쪽 화살표','링크 행동을 설명'), ('unnamed-link','','아래쪽 화살표','빈 링크 이름 확인'), ('filename-alt','IMG_0421.png','복원 완료 화면','파일명 대신 필요한 결과 설명'), ('chart','자료집 수량은 1분기 12개에서 2분기 15개로 증가

원시 수량: 12,15

','분기별 수량 그래프','요약과 근처 수치 제공'), ('link-with-text','CSV 비교 예제 내려받기','문자 옆의 화살표 장식','옆 링크 글자와 같은 내용을 반복하지 않음')] rows=[] for name,s,description,manual in fixtures: p=Images();p.feed(s);links=[{'href':a['href'],'nameProxy':' '.join(a['nameParts']),'emptyNameProxy':not a['nameParts']} for a in p.links] rows.append({'id':name,'html':s,'imageDescription':description,'manualEditorialNote':manual,'images':p.imgs,'links':links,'missingAlt':sum(not a['hasAlt'] for a in p.imgs),'filenameWarnings':sum(a['filenameLike'] for a in p.imgs),'emptyLinkWarnings':sum(a['emptyNameProxy'] for a in links)}) result={'cases':rows,'semanticDecision':'manual-context-review','nameProxyScope':'Only direct anchor text and img alt are combined; ARIA/CSS/hidden state/full accessible-name algorithm unsupported.','assistiveTechnologyTested':False,'imageRecognitionExecuted':False} assert rows[0]['missingAlt']==1 and rows[1]['missingAlt']==0 assert rows[2]['links'][0]['nameProxy']=='CSV 비교 예제 내려받기' assert rows[3]['emptyLinkWarnings']==1 and rows[4]['filenameWarnings']==1 assert rows[6]['emptyLinkWarnings']==0 from datetime import datetime as _runtime_datetime, timezone as _runtime_timezone result.update({'fixtureCreatedOn':'2026-10-15','executedAt':_runtime_datetime.now(_runtime_timezone.utc).isoformat(),'runtime':platform.python_version(),'synthetic':True}) print(json.dumps(result,ensure_ascii=False,indent=2))