Skip to content

fix(website): render code config examples as code blocks - #25958

Merged
pront merged 1 commit into
masterfrom
website-pront-fix-config-example-newlines
Jul 28, 2026
Merged

fix(website): render code config examples as code blocks#25958
pront merged 1 commit into
masterfrom
website-pront-fix-config-example-newlines

Conversation

@pront

@pront pront commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

Component reference pages render each field's example through jsonify, which escapes newlines
to a literal \n. Fields whose value is a program — VRL (remap's source) or Lua (the lua
transform's hooks) — therefore showed their multi-line examples as one run-together escaped
string. This drives example rendering off the field's declared syntax: code syntaxes render as
a highlighted code block with newlines intact, everything else stays inline. Doing it declaratively
via syntax avoids brittle content-sniffing and extends to any code-valued field with a single
map entry.

Changes

  • config-examples renders a field's examples as a highlighted code block when its syntax is a
    source-code type, via a syntax → lexer map (vrl_program → coffee, lua → lua, yaml,
    toml); every other syntax renders inline as JSON.
  • Renamed the remap_program syntax to vrl_program (the language is VRL, not "remap").
  • Marked the lua transform's program and hook fields with syntax: lua so their examples render
    as code too.

How did you test this PR?

  • Built the docs locally and confirmed the remap source (VRL) and the lua hook examples now
    render as multi-line code blocks, while non-code examples — e.g. the file source's \r\n
    delimiter — stay inline.

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

@datadog-vectordotdev

datadog-vectordotdev Bot commented Jul 28, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c34c237 | Docs | Datadog PR Page | Give us feedback!

@pront
pront force-pushed the website-pront-fix-config-example-newlines branch from 6802cdc to a4f6513 Compare July 28, 2026 14:32
@github-actions github-actions Bot added domain: transforms Anything related to Vector's transform components domain: external docs Anything related to Vector's external, public documentation docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels Jul 28, 2026
@pront
pront marked this pull request as ready for review July 28, 2026 14:34
@pront
pront requested review from a team as code owners July 28, 2026 14:34
@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Jul 28, 2026
@pront
pront enabled auto-merge July 28, 2026 14:36
Field examples were rendered via jsonify, which escapes newlines to a literal \n,
so multi-line VRL and Lua programs displayed as a single run-together escaped
string. Render examples as a highlighted code block for fields whose declared
`syntax` denotes source code, driven by a syntax -> lexer map
(vrl_program -> coffee, lua -> lua, yaml -> yaml, toml -> toml); every other
syntax stays inline JSON.

Also rename the `remap_program` syntax to `vrl_program` and mark the lua
transform's program/hook fields as `lua` so their examples render as code too.
@pront
pront force-pushed the website-pront-fix-config-example-newlines branch from a4f6513 to c34c237 Compare July 28, 2026 14:44
@pront pront changed the title fix(website): preserve newlines in VRL config examples fix(website): render code config examples as code blocks Jul 28, 2026
@github-actions github-actions Bot removed the docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. label Jul 28, 2026
@thomasqueirozb thomasqueirozb added the preview: website Deploy a vector.dev preview site for this PR label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Your preview sites will be ready in a few minutes, please allow time for them to build.

@pront
pront added this pull request to the merge queue Jul 28, 2026
Merged via the queue into master with commit bc344bc Jul 28, 2026
87 checks passed
@pront
pront deleted the website-pront-fix-config-example-newlines branch July 28, 2026 15:31
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

domain: external docs Anything related to Vector's external, public documentation domain: transforms Anything related to Vector's transform components no-changelog Changes in this PR do not need user-facing explanations in the release changelog preview: website Deploy a vector.dev preview site for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants