nokyotsu / krampygs

Kramdown + Pygments + Typogruby for Jekyll
The Unlicense
11 stars 2 forks source link

krampygs

Unleash the power of Kramdown with Pygments and Typogruby in Jekyll.

If you want to know, read why it is such a good idea to use Kramdown with Pygments.

Usage

Add krampygs.rb to your _plugins directory, and the following lines

markdown_ext: foo
markdown: kramdown
pygments: true

to your _config.yml. The bogus foo extension is a workaround to get Jekyll ignore its own Markdown converters and use instead the custom converter provided (which explicitly looks for .md files).

Code in your pages can now be syntax highlighted using the power of Pygments.

For example fenced code

~~~ ruby
print "Hello World"
~~~

Or inline code like this: `\section{foo}`{:.language-latex}

You can also define a global default for a whole site adding

kramdown:
  default_lang: python

to your _config.yml; or, for a single page, by adding something like

{::options coderay_default_lang="fortran" /}

near the top of a page. (No, coderay is not being used, but that was the easiest hack I could find to get the value of the option into Kramdown.)

Github flavor markdown syntax is also supported by adding

kramdown:
  input: GFM

to your _config.yml. For example GFM code

```ruby
print "Hello World"
```

Tested with

Thanks

To Matthias for his initial plugin idea, and his help getting it fixed to work with Jekyll 1.x.

Contributors