Skip to content

proposal: x/tools/cmd/present: add syntax highlighting support via Prism.js #76720

@iamrajiv

Description

@iamrajiv

Proposal Details

I would like to propose adding optional syntax highlighting to the present tool.

The Problem

Currently, .code and .play blocks in presentations render as plain text inside <pre> tags. This works fine for small snippets, but for larger blocks of code, the lack of highlighting makes it harder for the audience to parse the logic quickly.

Proposed Solution

I propose integrating Prism.js into the default templates.

I suggest Prism because:

  1. It's minimal: We can vendor a build containing only Core + Go support, which is very small (~2KB).
  2. No dependencies: It's just a JS file and a CSS file; no complex build pipeline is needed.
  3. Progressive enhancement: If the script fails to load or JS is disabled, the code renders as plain text, preserving the current behavior exactly.

Implementation Plan

If accepted, I can submit a CL that:

  1. Adds a minified prism.js and a minimal prism.css to the static/ directory.
  2. Updates templates/action.tmpl to add the standard class="language-%s" attribute to the <pre> block based on the file extension.
  3. Includes the script/css links in the header/footer templates.

This would be a strictly client-side change with no impact on the Go code logic in the server.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.Proposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions