Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Count visible text when checking SVG label widths so RTL labels can isolate command-line flags at the column limit.
- Preserve the SVG manifest's byte hashes when writing files on Windows.
- Ignore footnote examples inside inline code when auditing wiki Markdown.
- Exercise Windows in CI and document a live bilingual GitHub showcase check and a Copilot CLI audit.
Expand Down
13 changes: 13 additions & 0 deletions skills/github-markdown-studio/references/multilingual.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ Never refresh hashes just to make a check green. Review the source diff, update
Use a single canonical diagram topology and translate labels into locale-specific assets. Keep theme variants derived from that locale's same layout. Prefer short labels and a text explanation outside the image. For RTL, inspect text direction, numbering, arrows, mixed Latin identifiers and alignment. Do not mirror a causal flow without checking its meaning.

The bundled SVG renderer accepts locale tags and an explicit `ltr` or `rtl` direction, but it is a fixed process-card layout, not a universal typography engine. It rejects long labels rather than silently clipping them. Browser/font review is still necessary.

In an RTL label, isolate a left-to-right command-line option so its leading
hyphens stay on the left. Write the Unicode escapes directly in the diagram
JSON. This step keeps the flag visible as `--output`.

```json
{"title":"حفظ التقرير","detail":"استخدم \u2066--output\u2069 لحفظ التقرير."}
```

`\u2066` begins the left-to-right span and `\u2069` ends it. The renderer
preserves both characters in the SVG and excludes them from the label width.
Check a rendered asset in both themes when punctuation carries meaning.
[W3C guidance on direction isolates](https://www.w3.org/International/questions/qa-bidi-unicode-controls.en)
10 changes: 7 additions & 3 deletions skills/github-markdown-studio/scripts/render_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@
"dark": {"background": "#0d1117", "surface": "#161b22", "text": "#f0f6fc", "muted": "#b7c4d5", "accent": "#5eead4", "border": "#39495c"},
}
LANGUAGE = re.compile(r"[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*\Z")
REMOVE_DIRECTION_ISOLATES = str.maketrans("", "", "\u2066\u2067\u2068\u2069")


def display_width(text: str) -> int:
return sum(0 if unicodedata.combining(c) else 2 if unicodedata.east_asian_width(c) in {"W", "F"} else 1 for c in text)


def label(value: object, maximum: int, name: str) -> str:
if not isinstance(value, str) or not value.strip() or display_width(value) > maximum:
text = value if isinstance(value, str) else ""
# Measure the visible label and keep the original isolates for SVG layout.
visible = text.translate(REMOVE_DIRECTION_ISOLATES)
if not visible.strip() or display_width(visible) > maximum:
raise ValueError(f"{name} must be non-empty text within {maximum} display columns; use shorter labels")
if any(unicodedata.category(c) in {"Cc", "Cs"} for c in value):
if any(unicodedata.category(c) in {"Cc", "Cs"} for c in text):
raise ValueError(f"{name} contains control characters")
return value.strip()
return text.strip()


def build_assets(spec: dict) -> dict[str, str]:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,25 @@ def test_rtl_smoke(self):
self.assertIn('direction="rtl"', svg)
self.assertIn('xml:lang="ar"', svg)

def test_rtl_flag_at_visible_width_limit(self):
content = copy.deepcopy(self.spec["locales"]["en"])
content["direction"] = "rtl"
detail = "استخدم \u2066--output\u2069 لحفظ التقرير في الملف، ثم راجعه قبل النشر."
content["steps"][0]["detail"] = detail
self.spec["locales"] = {"ar": content}
assets = render.build_assets(self.spec)
for theme in ("light", "dark"):
svg = ET.fromstring(assets[f"workflow.ar.{theme}.svg"])
self.assertIn(detail, [node.text for node in svg.findall(".//{*}text")])
content["steps"][0]["detail"] += "!"
with self.assertRaisesRegex(ValueError, "58 display columns"):
render.build_assets(self.spec)

def test_direction_isolates_without_label_text_are_rejected(self):
for opening in ("\u2066", "\u2067", "\u2068"):
with self.subTest(opening=ascii(opening)), self.assertRaises(ValueError):
render.label(opening + " " + "\u2069", 32, "title")

def test_no_overwrite_without_flag(self):
with tempfile.TemporaryDirectory() as directory:
output = Path(directory)
Expand Down