📝 Edit page
➕ Add page
Basics
Backticks vs highlight tag
Markdown code blocks
This works in Jekyll and plain markdown too.
Code:
```ruby
def foo
puts 'foo'
end
```
Result:
def foo
puts 'foo'
end
Highlight tag
This works in Jekyll only.
Code:
{% highlight ruby %}
def foo
puts 'foo'
end
{% endhighlight %}
Result:
With line numbers
Add linenos
to the highlight
tag.
Code:
{% highlight ruby linenos %}
def foo
puts 'foo'
end
{% endhighlight %}
Result:
1
2
3
def foo
puts 'foo'
end
Here is the HTML result:
<table class="rouge-table"><tbody><tr><td class="gutter gl"><pre class="lineno">1
2
3
</pre></td><td class="code"><pre><span class="k">def</span> <span class="nf">foo</span>
<span class="nb">puts</span> <span class="s1">'foo'</span>
<span class="k">end</span>
</pre></td></tr></tbody></table>
Warning: You may need to add or update your CSS so that the result displays as you expect. For example, in Minima, the width must be reduced to not be 100% and the borders must be removed:
Code:
<style>
.rouge-table {
width: initial;
}
table {
border: none;
}
table td {
border: none;
}
td pre {
border: none;
}
</style>
Bullet or numbered points
Using code indented 3 spaces inside a point just for YAML. Otherwise use 4.
Code:
1. Create a new logical volume group
```yaml
- name: Create a volume group on top of /dev/sdb
community.general.lvg:
vg: vg.storage
pvs: /dev/sdb1
pesize: 32
- Create a logical volume in your logical volume group
```yaml
- name: create logical volume
community.general.lvol:
vg: vg.storage
lv: data
size: 10g
- name: create logical volume
community.general.lvol:
vg: vg.storage
lv: data
size: 10g
Result:
- Create a new logical volume group
```yaml
- name: Create a volume group on top of /dev/sdb community.general.lvg: vg: vg.storage pvs: /dev/sdb1 pesize: 32 ```
- Create a logical volume in your logical volume group
```yaml
- name: create logical volume community.general.lvol: vg: vg.storage lv: data size: 10g ```
Escape
Add backslash before backticks.
Code:
\`\`\`
Result:
```
Or indent 4 spaces.
Code:
```sh
$ echo 'Hello'
```
Result:
```sh
$ echo 'Hello'
```