{"record":{"id":"b47093e41393fe8a","repo":"subframe7536/maple-font","slug":"all-tag-content-must-be-in-ascii-letters-or-list","errorCode":null,"errorMessage":"All tag content must be in ASCII letters or {list(__map.keys())}, current is {target[1:-1]}","messagePattern":"All tag content must be in ASCII letters or (.+?), current is (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/py/feature/calt/tag.py","lineNumber":189,"sourceCode":"        for g in glyphs:\n            if g.isalpha():\n                source_list.append(f\"@{g.upper()}\")\n            else:\n                source_list.append(ast.gly(g))\n\n        # Parse target\n        target_list = []\n        for target_gly in target:\n            if target_gly in __map:\n                target_list.append(f\"{__map[target_gly]}.bg\")\n            elif target_gly.isalpha():\n                up = target_gly.upper()\n                if up in bg_cls_dict:\n                    target_list.append(bg_cls_dict[up])\n                else:\n                    target_list.append(f\"{up}.bg\")\n            else:\n                raise Exception(\n                    f\"All tag content must be in ASCII letters or {list(__map.keys())}, current is {target[1:-1]}\"\n                )\n\n        # Generate substitutions in reverse order (from last glyph to first)\n        subst_list = []\n        for i in range(glyphs_len, 0, -1):\n            before = target_list[: i - 1]\n            glyph = source_list[i - 1]\n            after = source_list[i:] if i < glyphs_len else None\n            replace = target_list[i - 1]\n            if isinstance(replace, ast.Clazz):\n                replace = replace.glyphs[0]\n            subst_list.append(ast.subst(before, glyph, after, replace))\n\n        desc = []\n        for item in source_list:\n            if isinstance(item, str):\n                desc.append(item.replace(\"@\", \"\"))","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/subframe7536/maple-font/blob/c08fda97fef73d68c1755219852150770f6e6578/source/py/feature/calt/tag.py#L171-L207","documentation":"Inside tag_custom(), after the first and last bracket glyphs, every middle character of the target must be an ASCII letter that can be rendered as a background glyph class (looked up in bg_cls_dict or rendered as '{LETTER}.bg'). Middle characters that are digits, symbols, or non-ASCII letters cannot map to any background class, so an Exception is raised showing the offending middle substring target[1:-1].","triggerScenarios":"Calling tag_custom with a target like '(T0D0)' or '(TODO✓)' where characters between the brackets are not A–Z/a–z letters, or where an uppercase letter lacks an entry in bg_cls_dict at a code path that requires it.","commonSituations":"Designing tags with numbers or symbols in the middle (e.g. '404', 'v1.0'); using accented or non-Latin letters; building bg_cls_dict incompletely so letters are missing from it.","solutions":["Restrict target middle characters to ASCII letters only, e.g. '(TODO)' instead of '(T0D0)'.","Ensure bg_cls_dict contains a Clazz for every uppercase letter used in the target.","Spell numbers/symbols as words (FOUR, DOT) if you need them visually.","Pre-validate with `all(c.isascii() and c.isalpha() for c in target[1:-1])` before calling."],"exampleFix":"// before\ntag_custom([('_404_', '(404)')], bg_cls_dict)\n// after\ntag_custom([('_TODO_', '(TODO)')], bg_cls_dict)","handlingStrategy":"validation","validationCode":"def validate_middle_ascii(tgt):\n    middle = tgt[1:-1]\n    if not all(c.isascii() and c.isalpha() for c in middle):\n        raise ValueError(f'target middle {middle!r} must be ASCII letters only')\n\nfor _, tgt in content_list:\n    validate_middle_ascii(tgt)\ntag_custom(content_list, bg_cls_dict)","typeGuard":"def is_ascii_letter_middle(tgt: str) -> bool:\n    return all(c.isascii() and c.isalpha() for c in tgt[1:-1])","tryCatchPattern":"try:\n    lookup = tag_custom(content_list, bg_cls_dict)\nexcept Exception as e:\n    if 'must be in ASCII letters' in str(e):\n        content_list = [(s, t) for s, t in content_list if is_ascii_letter_middle(t)]\n        lookup = tag_custom(content_list, bg_cls_dict)\n    else:\n        raise","preventionTips":["Spell out numbers and symbols (FOUR, DOT) instead of using digits/punctuation in targets.","Avoid accented or non-Latin letters in tag names.","Ensure bg_cls_dict covers every uppercase letter you use in targets."],"tags":["python","exception","custom-tags","ascii-validation","background-glyphs"],"backgroundTag":"invalid-tag-content","analyzedSha":"c08fda97fef73d68c1755219852150770f6e6578","analyzedAt":"2026-08-28T22:07:29.503Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}