io.display.code
Displays a block of code to the action user.
Usage
- TypeScript
- JavaScript
await io.display.code("Check out the source code", {
code: 'console.log("Hello world!")',
language: "javascript",
});
await io.display.code("Check out the source code", {
code: 'console.log("Hello world!")',
language: "javascript",
});
interval.com
Props
- TypeScript
- JavaScript
code
Required
string
The text for the source code to display.
language
Optional
string
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
code
Required
string
The text for the source code to display.
language
Optional
string
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
- TypeScript
- JavaScript
// 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",
});
// At top-level module scope
const fs = require("fs");
// In your action
await io.display.code("Check out the source code", {
code: fs.readFileSync("./path/to/file.ts", { encoding: "utf8" }),
language: "typescript",
});
Was this section useful?