{}OPF
DocsObject referenceEdit on GitHub

Code

Code content with optional rendering metadata. Use 'source' for the code text, 'language' for syntax highlighting, and 'filename' when the rendered block should show a file label. A string value in a code fiel…

Metadata

Definition

#/$defs/Code

Type

object

Source

spec/schemas/opf.schema.json

Fields

FieldTypeReqDescription
sourcestringyesSource code text to display.
languagestringLanguage identifier used for syntax highlighting.
filenamestringOptional file label shown with the code block.

source

Type: string · Required · Default:

Source code text to display.

source.json
{
  "source": "def greet(name: str) -> str:\n    return f\"Hello, {name}!\""
}

language

Type: string · Optional · Default:

Language identifier used for syntax highlighting.

language.json
{
  "language": "python"
}

filename

Type: string · Optional · Default:

Optional file label shown with the code block.

filename.json
{
  "filename": "app.py"
}