Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbellamy committed Dec 19, 2014
0 parents commit 3363e4b
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.gem
Gemfile.lock
2 changes: 2 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
11 changes: 11 additions & 0 deletions jekyll-mermaid.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Gem::Specification.new do |s|
s.name = 'jekyll-mermaid'
s.version = '1.0.0'
s.summary = 'A Jekyll plugin for mermaid.'
s.description = 'A Jekyll plugin to simplify the creation of mermaid diagrams and flowcharts in your posts and pages.'
s.authors = ['Jason Bellamy']
s.email = 'j@sonbellamy.com'
s.files = ['lib/jekyll-mermaid.rb']
s.homepage = 'https://github.com/jasonbellamy/jekyll-mermaid'
s.license = 'MIT'
end
16 changes: 16 additions & 0 deletions lib/jekyll-mermaid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Jekyll
class Mermaid < Liquid::Block

def initialize(tag_name, markup, tokens)
super
end

def render(context)
@config = context.registers[:site].config['mermaid']
"<script src=\"#{@config['src']}\"></script>"\
"<div class=\"mermaid\">#{super}</div>"
end
end
end

Liquid::Template.register_tag('mermaid', Jekyll::Mermaid)
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Jason Bellamy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 54 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Jekyll-mermaid

A [Jekyll](http://jekyllrb.com/) plugin to simplify the creation of [mermaid](https://github.com/knsv/mermaid) diagrams and flowcharts in your posts and pages.


## Installation

1. Install the gem:
```bash
gem install jekyll-mermaid
```

2. Add the gem to your Jekyll `_config.yml`:
```ruby
gems: [jekyll-mermaid]
```

Please see the [Jekyll documentation](http://jekyllrb.com/docs/plugins/#installing-a-plugin) for more installation options.


## Config

You'll need to update your `_config.yml` with the location of the [mermaid](https://github.com/knsv/mermaid) source javascript file you want to use.
```ruby
mermaid:
src: 'path/to/mermaid.js'
```
## Usage
Simply include the [jekyll-mermaid](https://github.com/jasonbellamy/jekyll-mermaid) block helper in any of your templates.
```liquid
{% mermaid %}
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
{% endmermaid %}
```
Please see the [mermaid documentation](https://github.com/knsv/mermaid/wiki) for more examples.
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
## License
Copyright (c) 2014 [Jason Bellamy ](http://jasonbellamy.com)
Licensed under the MIT license.

0 comments on commit 3363e4b

Please sign in to comment.