Skip to content
Redcarpet custom renderer for code blocks with filename.
Ruby CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib
spec
.gitignore
Gemfile
Gemfile.lock
README.md
screenshot.png

README.md

Redcarpet filename extension

Redcarpet custom renderer for code blocks with filename.

Usage

renderer = BlockCodeWithFilename.new
markdown = Redcarpet::Markdown.new(renderer, fenced_code_blocks: true)
markdown.render(markdown_content)

When you add filename after language in your fenced code block, this custom renderer will recognize the filename.

Example

```rb:greeter.rb
class Greeter
  def initialize(name)
    @name = name.capitalize
  end

  def salute
    puts "Hello #{@name}!"
  end
end

# Create a new object
g = Greeter.new("world")

# Output "Hello World!"
g.salute
\```

This fenced block code is rendered like this.

screenshot

You can’t perform that action at this time.