Skip to content

STML: syntax highlighting for <code> blocks in agent notes #1219

Open

Description

@jezhou

What do you want to change?

A lang attribute on STML <code> / <pre> so the block body is syntax highlighted, e.g. <code title="suggestion" lang="ts">. A diff language (or an opt-in that colors -/+ lines) would cover the "here is the suggested change" shape too.

Today lang is ignored (only title is read), and <c color="..."> inside <code> or <pre> prints literally, since both are raw-text roles.

Repro (0.22.0, --experimental):

printf '%s' '<code title="t" lang="ts">const x: number = 1;</code>' | hunk markup render - --width 40
printf '%s' '<code title="t"><c color="success">+ added</c></code>' | hunk markup render - --width 40

The first prints the line unhighlighted; the second prints the <c> tag as text.

Why?

I use agent notes to carry suggested changes and before/after snippets next to the diff, when reviewing TS code. Syntax highlighting makes reviewing code and certain parts I don't understand easier for me. The <code> box is the right container, but a 15-line TypeScript suggestion sits unhighlighted directly under a fully highlighted diff pane, so it reads as a wall of text. The workaround is a box of <text> lines with <c> tags for color, which loses indentation and the code-block frame.

How? (optional)

Run the body through the Shiki highlighter the diff pane already uses, with the active theme, when lang is present. Unknown languages fall back to today's plain rendering.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions