Testing Syntax Highlighting

2 min read

Testing Syntax Highlighting

This is a test post to verify that our syntax highlighting is working correctly with rehype-pretty-code.

JavaScript Example

Here's a simple JavaScript function:

function greet(name) {
  console.log(`Hello, ${name}!`);
  return true;
}
 
const user = {
  name: "John",
  age: 30,
  isActive: true
};

TypeScript Example

Here's a TypeScript interface and class:

interface User {
  name: string;
  age: number;
  isActive: boolean;
}
 
class UserService {
  private users: User[] = [];
 
  addUser(user: User): void {
    this.users.push(user);
  }
 
  getUsers(): User[] {
    return this.users;
  }
}

Bash Example

Here's a bash script example:

#!/bin/bash
 
# Variables
name="World"
count=0
 
# Function
greet() {
  echo "Hello, $1!"
}
 
# Loop
for i in {1..5}; do
  greet $name
  ((count++))
done
 
echo "Greeted $count times"

Python Example

Here's a Python example:

def fibonacci(n):
    """Generate Fibonacci sequence up to n terms."""
    sequence = []
    a, b = 0, 1
    
    for _ in range(n):
        sequence.append(a)
        a, b = b, a + b
    
    return sequence
 
# Generate first 10 Fibonacci numbers
fib_numbers = fibonacci(10)
print(fib_numbers)

Inline Code

You can also use inline code like console.log("Hello World") or const x = 5; for small snippets.

Conclusion

This post demonstrates various syntax highlighting features for different programming languages.