From c15e21490c2dad6e473a4342f4cf2fbc24399d63 Mon Sep 17 00:00:00 2001 From: Jane Chu <7559015+janechu@users.noreply.github.com> Date: Fri, 29 May 2026 10:58:48 -0700 Subject: [PATCH] feat: auto-escape code samples inside `` elements Mirrors the auto-escape behavior of Microsoft WebUI's `webui-press` markdown renderer so that code samples embedded inside `` blocks render as literal text instead of being interpreted by the FAST template parser. The escape runs as a two-stage pipeline split between the server-side renderer (`escape_code_sample_elements` in `microsoft-fast-build`) and the client-side `` parser (`escapeBracesInCodeElements` in `@microsoft/fast-element`): * Curly braces (`{` / `}`) inside every `` element (text and attribute values of any descendant) are replaced with their HTML numeric character references (`{` / `}`) on **both** server and client, so binding delimiters (`{{...}}`, `{{{...}}}`, `{...}`) inside `` render literally. The split is necessary because the DOM serializer used by `.innerHTML` decodes the numeric references back to literal braces and does not re-encode them, so the brace escape has to be re-applied client-side before the binding scan runs. * Angle brackets of FAST directive tags (``, ``, ``, ``, case-insensitive) inside `` are entity-escaped to `<` / `>` on the **server only**. The DOM serializer re-encodes `<` / `>` in text content automatically, so the client never sees a raw directive tag inside `` regardless of what the page source contained. * Real HTML elements (`