Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naoty/redcarpet_filename_extension
Redcarpet custom renderer for code blocks with filename.
https://github.com/naoty/redcarpet_filename_extension
Last synced: about 1 month ago
JSON representation
Redcarpet custom renderer for code blocks with filename.
- Host: GitHub
- URL: https://github.com/naoty/redcarpet_filename_extension
- Owner: naoty
- Created: 2013-12-05T17:33:35.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-28T13:22:14.000Z (over 10 years ago)
- Last Synced: 2024-10-22T14:01:26.231Z (3 months ago)
- Language: Ruby
- Size: 211 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Redcarpet filename extension
Redcarpet custom renderer for code blocks with filename.
## Usage
```rb
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
```markdown
```rb:greeter.rb
class Greeter
def initialize(name)
@name = name.capitalize
enddef 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](screenshot.png "screenshot")