No commit activity in last 3 years
No release in over 3 years
This Jekyll plugin generates pretty or plain Markdown and/or HTML source code pages for your Markdown docs, which you can easily link to for viewing.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 2.16
~> 10.0
~> 3.0

Runtime

~> 3.0
< 3, >= 1.7
 Project Readme

Jekyll::ViewSource

Gem Version

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

View Markdown source

View HTML source

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

  1. Fork this project: https://github.com/ibrado/jekyll-viewsource/fork
  2. Clone it (git clone git://github.com/your_user_name/jekyll-viewsource.git)
  3. cd jekyll-viewsource
  4. Create a new branch (e.g. git checkout -b my-bug-fix)
  5. Make your changes
  6. Commit your changes (git commit -m "Bug fix")
  7. Build it (gem build jekyll-viewsource.gemspec)
  8. Install and test it (gem install ./jekyll-viewsource-*.gem)
  9. Repeat from step 5 as necessary
  10. Push the branch (git push -u origin my-bug-fix)
  11. 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.