Skip to main content

io.display.code

Displays a block of code to the action user.

Usage

await io.display.code("Check out the source code", {
code: 'console.log("Hello world!")',
language: "javascript",
});
interval.com

Props

code

string Required

The text for the source code to display.

language

string Optional

The language of the source code for syntax highlighing. Supported values are "bash", "c", "cpp", "csharp", "css", "diff", "go", "ini", "java", "javascript", "json", "kotlin", "less", "lua", "makefile", "markdown", "objectivec", "perl", "php", "php-template", "plaintext", "python", "python-repl", "r", "ruby", "rust", "scss", "shell", "sql", "swift", "typescript", "vbnet", "xml", and "yaml".

Returns

null

Examples

Displaying code from a file

// At top-level module scope
import fs from "fs";

// In your action
await io.display.code("Check out the source code", {
code: fs.readFileSync("./path/to/file.ts", { encoding: "utf8" }),
language: "typescript",
});
Did this section clearly explain what you wanted to learn?