Syntax Highlighting Examples

This post demonstrates syntax highlighting for Ruby, Bash, and Markdown using Rouge.

Ruby

class Greeter
  def initialize(name)
    @name = name
  end

  def greet
    puts "Hello, #{@name}!"
  end
end

greeter = Greeter.new("World")
greeter.greet

Bash

#!/bin/bash

# Create a new Jekyll site
gem install jekyll
jekyll new my-site
cd my-site

# Serve it locally
bundle exec jekyll serve --livereload

echo "Site is running at http://localhost:4000"

Markdown

# Heading

A paragraph with **bold** and *italic* text.

- List item one
- List item two

```ruby
puts "nested code block"
```

| Column A | Column B |
|----------|----------|
| Data 1   | Data 2   |

Each language gets its own color scheme thanks to Rouge and the syntax CSS theme.