Jekyll::ViewSource
Jekyll:ViewSource is a plugin for Jekyll that generates plain or pretty Markdown and HTML source code pages from your content.
What's new?
v1.0.1 Improvements to lexer; cache location; inclusion in _config.yml
Installation
Add the gem to your application's Gemfile:
group :jekyll_plugins do
# other plugins here
gem 'jekyll-viewsource'
end
And then execute:
$ bundle
Or install it yourself:
$ gem install jekyll-viewsource
Configuration
No configuration is required to run Jekyll::ViewSource. If you want to tweak its behavior, you may set the following options in _config.yml
:
viewsource:
#enabled: false # Default: true
debug: true # Show additional messages during run; default: false
#collection: pages, "articles" # Which collections to paginate; default: pages and posts
collections: # Ditto, just a different way of writing it
- pages # Quotes are optional if collection names are obviously strings
- posts
- articles
options: pretty # Options that normally go in a doc's front matter
Usage
Just add a viewsource: true
entry to the front-matter of the content for you want to create source files:
Plain Markdown
---
viewsource: true
---
(or viewsource: md
or viewsource: markdown
)
Plain HTML
viewsource: html
Plain Markdown and HTML
viewsource: markdown, html
Prettified
Add pretty[="<rouge_template|css_path>"]
, e.g.
viewsource: markdown, html, pretty
viewsource: markdown, html, pretty="thankful_eyes"
viewsource: markdown, html, pretty="/url/path/to/syntax.css"
You may show the themes currently supported by Rouge via the command line:
$ rougify help style
As of this writing, these are:
- base16, base16.dark, base16.light
- base16.monokai, base16.monokai.dark, base16.monokai.light
- base16.solarized, base16.solarized.dark, base16.solarized.light
- colorful
- github
- gruvbox, gruvbox.dark, gruvbox.light
- igorpro
- molokai
- monokai, monokai.sublime
- thankful_eyes
- tulip
The default is github
Source file links
To link to your source files, use the following:
{{ page.source_url }}
: The plain or pretty Markdown source URL
{{ page.html_source_url }}
: The plain or pretty HTML source URL
e.g.
[View Markdown source]({{ page.source_url }})
[View HTML source]({{ page.html_source_url }})
Demo
Cache
ViewSource maintains a cache in a hidden folder inside your home directory: .jekyll-plugins/jekyll-viewsource
. If you encounter problems that you think may be related to the cache, you may remove this.
Contributing
- Fork this project: https://github.com/ibrado/jekyll-viewsource/fork
- Clone it (
git clone git://github.com/your_user_name/jekyll-viewsource.git
) cd jekyll-viewsource
- Create a new branch (e.g.
git checkout -b my-bug-fix
) - Make your changes
- Commit your changes (
git commit -m "Bug fix"
) - Build it (
gem build jekyll-viewsource.gemspec
) - Install and test it (
gem install ./jekyll-viewsource-*.gem
) - Repeat from step 5 as necessary
- Push the branch (
git push -u origin my-bug-fix
) - Create a Pull Request, making sure to select the proper branch, e.g.
my-bug-fix
(via https://github.com/your_user_name/jekyll-viewsource)
Bug reports and pull requests are welcome on GitHub at https://github.com/ibrado/jekyll-viewsource. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Jekyll::ViewSource project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Also by the Author
Jekyll Stickyposts Plugin - Move/pin posts tagged sticky: true
before all others. Sorting on custom fields supported; collection and paginator friendly.
Jekyll Tweetsert Plugin - Turn tweets into Jekyll posts. Multiple timelines, filters, hashtags, automatic category/tags, and more!
Jekyll::Paginate::Content - Split your Jekyll pages, posts, etc. into multiple pages automatically. Single-page view, pager, SEO support, self-adjusting links, multipage-aware Table Of Contents.