Code Blocks¶
Code blocks in our theme system automatically come with language badges and elegant design. Simply use standard markdown code fences with language identifiers.
Bash Commands¶
Python Code¶
# Simple hello world
print("Hello, World!")
# Working with variables
name = "Phantom"
version = 2.0
print(f"Welcome to {name} v{version}")
# Simple function
def greet(user):
return f"Hello, {user}!"
print(greet("Developer"))
JavaScript/TypeScript¶
// Print hello world
console.log("Hello, World!");
// Simple function
function greet(name) {
return `Hello, ${name}!`;
}
// Use the function
const message = greet("Developer");
console.log(message);
// Arrow function
const add = (a, b) => a + b;
console.log(add(5, 3)); // 8
YAML Configuration¶
# Simple configuration
name: My Application
version: 1.0.0
description: A simple hello world app
# Settings
settings:
debug: true
port: 8080
# Features list
features:
- authentication
- logging
- monitoring
JSON Response¶
{
"message": "Hello, World!",
"status": "success",
"data": {
"user": "developer",
"timestamp": "2024-01-15T10:30:00Z"
}
}
Dockerfile¶
# Use lightweight base image
FROM alpine:latest
# Add greeting script
RUN echo 'echo "Hello from Docker!"' > /greet.sh
RUN chmod +x /greet.sh
# Run greeting on start
CMD ["/greet.sh"]
SQL Queries¶
-- Create simple table
CREATE TABLE greetings (
id INTEGER PRIMARY KEY,
message TEXT NOT NULL
);
-- Insert data
INSERT INTO greetings (message)
VALUES ('Hello, World!');
-- Query data
SELECT * FROM greetings;
HTML/XML¶
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>Welcome to Phantom Documentation</p>
</body>
</html>
CSS Styles¶
Usage Guide¶
```python
print("Hello, World!")
```
```bash
echo "Hello, World!"
```
```javascript
console.log("Hello, World!");
```
Language Badge Colors¶
Our documentation automatically adds colored badges to code blocks:
| Language | Badge | Color Code |
|---|---|---|
| Python | PYTHON | #3776ab |
| Bash | BASH | #4EAA25 |
| YAML | YAML | #CB171E |
| JSON | JSON | #292929 |
| JavaScript | JS | #f7df1e |
| TypeScript | TS | #3178c6 |
| Docker | DOCKER | #2496ed |
| SQL | SQL | #336791 |
| HTML | HTML | #e34c26 |
| CSS | CSS | #1572b6 |
Additional Language Badges¶
| Language | Badge | Color Code |
|---|---|---|
| Go | GO | #00ADD8 |
| Rust | RUST | #dea584 |
| Java | JAVA | #007396 |
| C++ | C++ | #00599C |
| Ruby | RUBY | #CC342D |
| PHP | PHP | #777BB4 |
| Markdown | MD | #083fa1 |
| Shell | SH | #89e051 |
| XML | XML | #e34c26 |
| Swift | SWIFT | #FA7343 |
More Languages¶
Go¶
Rust¶
Java¶
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
C++¶
Ruby¶
# Simple greeting
puts "Hello, World!"
# Method example
def greet(name)
"Hello, #{name}!"
end
puts greet("Developer")