This brings the great styles and metadata support found in the Octopress Code Highlighter to Middleman.
You can define code fences as you would normally. These code fences have support for the languages defined in rouge.
Define a code fence with a language.
```lang
[code]
```
Define a code fence for a language with the addition of a title.
```lang title
[code]
```
Define a code fence for a language with additional metadata
```lang [metadata]
[code]
```
The additional metadata that can be specified:
Metadata | Example | Description |
---|---|---|
lang |
ruby |
Used by the syntax highlighter. Passing ‘plain’ disables highlighting. |
title |
title:"Figure 1.A" |
Add a figcaption title to your code block. |
url |
url:"https://github.com" |
No default value |
link_text |
link_text:"Download" |
Text for the link, default: "link"
|
linenos |
linenos:true |
Enables line numbering |
start |
start:5 |
Start the line numbering at the given value. |
mark |
mark:1-4,8 |
Highlight lines of code. This example marks lines 1,2,3,4 and 8 |
class |
class:"css example" |
Add CSS class names to the code <figure> element |
Code Method Helper
Define a code fence with a language.
= code(:shell) do
|
$ cd ~/sample-rails-app
Define a code fence for a language with the addition of a title.
= code(:studio, title: 'Habitat Studio') do
| [1][default:/src:0]#
Define a code fence for a language with additional metadata
= code(:yaml, title: '~/sample-rails-app/docker-compose.yml', linenos: true, start: 7, marks: [8]) do
|
railsapp:
image: <myorg>/sample-rails-app