Skip to content

[BREAKINGCHANGE] Markdown: add option to enable HTML rendering - #905

Open
Gladorme wants to merge 3 commits into
perses:mainfrom
Gladorme:agents/add-html-rendering-panel-option
Open

Gladorme wants to merge 3 commits into
perses:mainfrom
Gladorme:agents/add-html-rendering-panel-option

Conversation

@Gladorme

@Gladorme Gladorme commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Description

Close issue: perses/perses#4684

Raw HTML in Markdown panels is now escaped and displayed as plain text unless the new enableHtml option is set, so placeholders such as : are no longer stripped by the sanitizer. DOMPurify is kept as a second layer in both modes. Grafana text panels in html mode are migrated with enableHtml: true. The option is available in the panel editor, the CUE schema, the Go SDK (RenderHTML) and the docs. Aligning with panel description (perses/shared#380).

Breaking change

Raw HTML render is disabled by default, if necessary you can re-enable it with renderHtml: true

Screenshots

Render disabled:
image

Render enabled:
image

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Gladorme and others added 2 commits October 30, 2026 16:52
…led by default

Raw HTML in Markdown panels is now escaped and displayed as plain text unless the new enableHtml option is set, so placeholders such as <host>:<port> are no longer stripped by the sanitizer. DOMPurify is kept as a second layer in both modes. Grafana text panels in html mode are migrated with enableHtml: true. The option is available in the panel editor, the CUE schema, the Go SDK (EnableHTML) and the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Align the option name with perses/perses#4684. The Go SDK option is renamed from EnableHTML to RenderHTML. HTML rendering stays disabled by default, and Grafana text panels in html mode are still migrated with renderHtml: true.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
@Gladorme
Gladorme marked this pull request as ready for review October 30, 2026 16:24
@Gladorme
Gladorme requested review from a team, AntoineThebaud and Nexucis as code owners October 30, 2026 16:24
@Gladorme
Gladorme requested review from jgbernalp and removed request for a team October 30, 2026 16:24
Comment thread markdown/src/MarkdownPanel.tsx Resolved
@jgbernalp

Copy link
Copy Markdown
Contributor

Is this a breaking change? it seems the renderHTML in the schema is optional, so this should be backwards compatible

@Gladorme

Gladorme commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Is this a breaking change? it seems the renderHTML in the schema is optional, so this should be backwards compatible

I would like to have the same behavior of perses/shared#380. I find Markdown content different between two components is strange 👀

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the opt-in HTML rendering change.

No open issues 🎉

What changed in this PR

This PR makes raw HTML rendering opt-in for Markdown panels, preserving literal placeholders such as <host>:<port> by default while retaining sanitization in both modes.

Changes:

  • Adds renderHtml across the panel runtime, editor, TypeScript model, CUE schema, Go SDK, and documentation.
  • Preserves HTML rendering when migrating Grafana text panels in HTML mode.
  • Adds rendering, editor, schema-validation, and migration coverage.
File Description
markdown/​src/​MarkdownPanelOptionsEditor.tsx Adds the Render HTML toggle and preserves options during edits.
markdown/​src/​MarkdownPanelOptionsEditor.test.tsx Tests the toggle default and option preservation.
markdown/​src/​MarkdownPanel.tsx Escapes raw HTML by default and supports opt-in rendering.
markdown/​src/​MarkdownPanel.test.ts Tests escaping, Markdown rendering, and HTML sanitization.
markdown/​src/​markdown-panel-model.ts Defines the optional renderHtml field.
markdown/​sdk/​go/​options.go Adds the RenderHTML builder option.
markdown/​sdk/​go/​markdown.go Adds HTML-rendering configuration to the serialized spec.
markdown/​schemas/​tests/​valid/​markdown-with-html.json Adds a valid HTML-enabled configuration fixture.
markdown/​schemas/​tests/​invalid/​markdown-invalid-render-html.json Adds an invalid non-boolean configuration fixture.
markdown/​schemas/​migrate/​tests/​text/​expected.json Expects HTML rendering for the HTML-mode migration fixture.
markdown/​schemas/​migrate/​tests/​text-markdown/​input.json Adds a Grafana Markdown-mode migration input.
markdown/​schemas/​migrate/​tests/​text-markdown/​expected.json Expects Markdown-mode migration without HTML opt-in.
markdown/​schemas/​migrate/​migrate.cue Enables HTML rendering when migrating HTML-mode text panels.
markdown/​schemas/​markdown.cue Accepts the optional boolean renderHtml field.
docs/​markdown/​model.md Documents the option, default, and sanitization behavior.
docs/​markdown/​go-sdk.md Documents the RenderHTML builder option.

Review effort: Balanced

… the renderer

Overriding the html renderer did not escape everything: content following a raw <code>, <kbd> or <pre> tag was kept as HTML, so e.g. an <img> nested in <code> was still rendered and loaded when renderHtml is disabled. Raw HTML is now not tokenized at all, so it is escaped as plain text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants