{"version":"2.1.265","anchor":"code-block-renderer-gains-a-diff-format-with-unified-diff","canonical_anchor":"code-block-renderer-gains-a-diff-format-with-unified-diff","heading":"Code blocks can now render as unified diffs","tier":"use","area":"UI Components","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.265\/e\/code-block-renderer-gains-a-diff-format-with-unified-diff","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.265","markdown":"### Code blocks can now render as unified diffs\n\nA new diff format for code blocks parses and validates unified-diff\/patch text before displaying it\n\n**What**\n\nA new self-contained unified-diff parser reads `Index:`\/`diff`\/`---`\/`+++`\/`@@` headers and hunks into structured objects, validating that the added\/removed line counts match what the hunk header claims.\n\nThe `Code` component gained a new `format` value, `\"diff\"`, alongside the existing `\"source\"` format. When set, the text is validated and parsed through this new parser, and anything with a malformed `@@ -a,b +c,d @@` header (missing, non-numeric, or out-of-bound numbers) is rejected with a specific error such as \"no @@ hunk header found\" or \"header is not @@ -a,b +c,d @@ within N lines\". A companion `wrap` prop accepts `\"wrap\"` or `\"truncate-end\"` to control how long diff lines are displayed.\n\n**Why**\n\nThis lets diff\/patch text be rendered as a properly parsed, validated diff view instead of plain text, catching malformed diffs before they're displayed.\n\n- Area: UI Components\n- Names: `diff`\n- Tier: Use it now\n- Useful: 3\/5\n- Signal: 2\/5"}