11. Markdown Output
Markdown is readable for humans and parseable for machines. Use markdown when output needs to be both human-readable and processable.
Common markdown structures for structured output:
Tables for structured data:
Analyze these sales figures and return a markdown table with columns: Region, Revenue, Growth %, Top Product.
| Region | Revenue | Growth | Top Product |
|--------|---------|--------|-------------|
Lists for enumerated items:
Extract key points from this article and return them as a markdown list:
- Point 1
- Point 2
Code blocks for formatted text:
Format the API response as a markdown code block with syntax highlighting:
```json
{
"status": "success"
}
**Headings** for hierarchical output:
```text
Summarize this research paper using headings:
# Summary
[2-3 sentences]
# Methodology
[1-2 sentences]
# Key Findings
[bullet list]
# Limitations
[bullet list]
To prevent markdown escaping issues:
Return markdown only. Do not wrap in code fences. Do not escape characters inside the markdown.
If you need raw markdown without rendering artifacts, specify:
Output raw markdown text. Do not include backticks, code fences, or HTML. Do not escape special characters.
For outputs that will be rendered by a markdown processor, be careful with special characters:
In the output, if text contains pipes (|), escape them as \| so table parsing works correctly.
Local verification checkpoint
Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.
Rewrite a prompt that produces unstructured output to produce markdown with specific structure (table, list, or headings). Validate the markdown parses correctly.