-
Notifications
You must be signed in to change notification settings - Fork 316
WWW Displaying Code with Code Fences and Code Helper Method
You can define markdown code fences as you would normally or use a code helper within slim/HAML. These code fences / code helper function supports all the languages defined in rouge. There is also additional support added to support a language called 'Studio' which is essentially the same as 'shell' but has been updated to have additional keywords and support for Habitat Studio related functionality (found in lib/lexer_habitat_studio.rb
.
Define a code fence with a language.
```shell
$ cd ~/sample-rails-app
```
Define a code fence for a language with the addition of a title.
```shell ~/sample-rails-app
$ hab studio enter
```
Define a code fence for a language with additional metadata
```lang title:"~/sample-rails-app/docker-compose.yml" linenos:true start:7 mark:8
[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 |
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