Code Blocks
The Code Block widget inserts code snippets with syntax highlighting for a wide range of languages, keeping examples clear, readable, and easy to copy.
Insert a code block
- Navigate to a new line where you want the code block.
- Type
/codeto open the widget menu. - Choose Code Block.
- Select the language from the dropdown to apply syntax highlighting.
- Paste or type your code.
Here's a formatted JavaScript example:
JavaScript
function createElixir(elixirName, ingredients) {
console.log(`Creating ${elixirName} Elixir with the following ingredients:`);
ingredients.forEach((ingredient, index) => {
console.log(`${index + 1}. ${ingredient}`);
});
console.log(`${elixirName} Elixir is ready to empower your API!`);
}
Code blocks inside tabs
Python
def create_elixir(elixir_name, ingredients):
print(f"Creating {elixir_name} Elixir with the following ingredients:")
for index, ingredient in enumerate(ingredients, start=1):
print(f"{index}. {ingredient}")
print(f"{elixir_name} Elixir is ready to empower your API!")
JSON
{
"elixirName": "Documentation",
"ingredients": [
"OpenAPI spec",
"Authentication",
"Examples"
],
"message": "Documentation Elixir is ready to empower your API!"
}
C#
using System;
using System.Collections.Generic;
public class Program
{
public static void CreateElixir(string elixirName, List<string> ingredients)
{
Console.WriteLine($"Creating {elixirName} Elixir with the following ingredients:");
for (int i = 0; i < ingredients.Count; i++)
{
Console.WriteLine($"{i + 1}. {ingredients[i]}");
}
Console.WriteLine($"{elixirName} Elixir is ready to empower your API!");
}
public static void Main()
{
CreateElixir("Documentation", new List<string>
{
"OpenAPI spec",
"Authentication",
"Examples"
});
}
}
Java
import java.util.List;
public class Main {
public static void createElixir(String elixirName, List<String> ingredients) {
System.out.println("Creating " + elixirName + " Elixir with the following ingredients:");
for (int i = 0; i < ingredients.size(); i++) {
System.out.println((i + 1) + ". " + ingredients.get(i));
}
System.out.println(elixirName + " Elixir is ready to empower your API!");
}
public static void main(String[] args) {
createElixir("Documentation", List.of(
"OpenAPI spec",
"Authentication",
"Examples"
));
}
}
Was this section helpful?
On this page
- Code Blocks