diff --git a/plugins/g4b_ai/skills/markdown-embedded-svg/SKILL.md b/plugins/g4b_ai/skills/markdown-embedded-svg/SKILL.md index bbc9a2c..e7c4773 100644 --- a/plugins/g4b_ai/skills/markdown-embedded-svg/SKILL.md +++ b/plugins/g4b_ai/skills/markdown-embedded-svg/SKILL.md @@ -7,7 +7,7 @@ description: Use when authoring or editing a Markdown file that contains (or sho Markdown renderers diverge dramatically on what SVG they allow. The safe default is **not** to embed SVG inline — it's to **save the SVG as a separate `.svg` file and reference it with image-link syntax**. Inline SVG should be treated as a special case the user explicitly asks for, not as the default. -This skill encodes the reasoning behind that choice plus the per-renderer rules for when inline SVG is what's wanted. +This skill encodes the reasoning behind that choice, layout and legibility rules for readable output, and the per-renderer rules for when inline SVG is what's wanted. ## Default approach: external `.svg` file + image link @@ -37,64 +37,20 @@ Inline SVG fails silently and inconsistently across renderers. From source-code The **strict cross-renderer intersection for inline SVG is effectively empty** — there is no inline-SVG recipe that produces a rendered diagram on GitHub, Gitea, and Obsidian alike. This is why the default has to be the external file. -## When the user does ask for inline SVG +## Layout and legibility -If the user explicitly says "embed it inline", "put the SVG directly in the markdown", or similar, follow these rules. Pick the rule set that matches the target renderer. If the target is unknown, ask. +Renderer compatibility is only half the problem — the other half is producing SVG that's actually readable. Agent-generated SVGs commonly fail on text overflow, poor contrast, and missing margins. **Read `references/layout-legibility.md` before generating any non-trivial SVG** (charts, matrices, diagrams with labels). It covers: -### Rule 1: Embed as a raw HTML block, never as a fenced code block +- Estimating text width before sizing containers (SVG doesn't clip text) +- Contrast contracts for text over colored backgrounds (aim for 4.5:1) +- Background rects or halos for text on data-dependent surfaces +- Margin reservation for rotated labels +- The sparse-cells-plus-legend pattern for dense categorical charts +- Palette selection with declared text-color roles -The two paths look similar but produce completely different output. +## When the user asks for inline SVG -- **Embed SVG as a raw HTML block.** Place `` directly in the Markdown source, with a blank line before and after. CommonMark / GFM treat that as a raw HTML block and pass it through verbatim; the browser then parses what survives the sanitizer as real SVG. -- **Never wrap renderable content in ` ```svg ` (or ` ```html `, ` ```xml `) fences.** Fenced code blocks are *by definition* "display this as text". The renderer wraps the contents in `
`, HTML-escapes every `<`, `>`, and `&`, and hands the escaped text to a syntax highlighter. The browser sees a string, not markup — no SVG ever gets parsed.
-- **Don't assume non-standard "render this code block" extensions exist.** Some renderers (GitLab, certain Obsidian plugins, custom static-site setups) special-case ` ```mermaid ` or ` ```svg ` to render. This is non-standard. GitHub, VS Code's default preview, and CommonMark do not. Default to the raw-HTML-block path.
-- **Same rule applies to other inline-renderable HTML.** `
`/``, ``, `