code.md 1.44 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
Mark Otto's avatar
Mark Otto committed
3
title: Code
Mark Otto's avatar
Mark Otto committed
4
group: content
Mark Otto's avatar
Mark Otto committed
5
---
Mark Otto's avatar
Mark Otto committed
6
7
8

Styles for inline code snippets and longer, multiline blocks of code.

Mark Otto's avatar
Mark Otto committed
9
10
11
12
13
## Contents

* Will be replaced with the ToC, excluding the "Contents" header
{:toc}

Mark Otto's avatar
Mark Otto committed
14
15
## Inline code

Patrick H. Lauke's avatar
Patrick H. Lauke committed
16
Wrap inline snippets of code with `<code>`. Be sure to escape HTML angle brackets.
Mark Otto's avatar
Mark Otto committed
17
18
19
20
21

{% example html %}
For example, <code>&lt;section&gt;</code> should be wrapped as inline.
{% endexample %}

22
## Code blocks
Mark Otto's avatar
Mark Otto committed
23

24
Use `<pre>`s for multiple lines of code. Once again, be sure to escape any angle brackets in the code for proper rendering. You may optionally add the `.pre-scrollable` class, which will set a max-height of 350px and provide a y-axis scrollbar.
Mark Otto's avatar
Mark Otto committed
25
26

{% example html %}
Patrick H. Lauke's avatar
Patrick H. Lauke committed
27
28
29
<pre><code>&lt;p&gt;Sample text here...&lt;/p&gt;
&lt;p&gt;And another line of sample text here...&lt;/p&gt;
</code></pre>
Mark Otto's avatar
Mark Otto committed
30
31
32
33
34
35
36
37
38
39
{% endexample %}

## Variables

For indicating variables use the `<var>` tag.

{% example html %}
<var>y</var> = <var>m</var><var>x</var> + <var>b</var>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
40
41
42
43
44
45
46
47
48
## User input

Use the `<kbd>` to indicate input that is typically entered via keyboard.

{% example html %}
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
49
50
## Sample output

51
For indicating sample output from a program use the `<samp>` tag.
Mark Otto's avatar
Mark Otto committed
52
53
54
55

{% example html %}
<samp>This text is meant to be treated as sample output from a computer program.</samp>
{% endexample %}