Fork me on GitHub

Here’s what a basic code block looks like:

def test_validate_url_returns_an_http_url_unmodified():
    url = 'http://github.com/jimsmith'

    validated_url = validate_url(url)

    assert validated_url == 'http://github.com/jimsmith'

If a code block is too long it’ll get a horizontal scrollbar, rather than stretching the entire page:

def test_validate_url_returns_an_http_url_unmodified():
    assert validate_url('http://github.com/jimsmith') == 'http://github.com/jimsmith'

You can use bold text in code blocks:

def test_validate_url_returns_an_http_url_unmodified():
    url = 'http://github.com/jimsmith'

    validated_url = validate_url(url)

    assert validated_url == 'http://github.com/jimsmith'

Syntax Highlighting

To use Python syntax highlighting begin the code block with ```python. For example this:

```python
def test_validate_url_returns_an_http_url_unmodified():
    url = 'http://github.com/jimsmith'
    validated_url = validate_url(url)
    assert validated_url == 'http://github.com/jimsmith'
```

will render like this:

def test_validate_url_returns_an_http_url_unmodified():
    url = 'http://github.com/jimsmith'
    validated_url = validate_url(url)
    assert validated_url == 'http://github.com/jimsmith'

Here’s the full list of languages supported for syntax highlighting.

Backtick-style fenced-code blocks are preferred but you can also use Jekyll’s {% highlight %} tag for code highlighting. {% highlight %} won’t render or preview on GitHub.com, but it does allow you to turn on line numbers with the linenos option. For example: {% highlight ruby linenos %} ... {% endhighlight %}:

1
2
3
def foo
  puts 'foo'
end

Shell Scripts vs Shell Sessions

```shell (or ```sh ```bash ```ksh or ```zsh) is for highlighting shell scripts, not interactive shell sessions:

# Loop over every $python_version in the .python-version file.
while IFS= read -r python_version
do
    pyenv install --skip-existing "$python_version"
    if ! "$(pyenv root)/versions/$python_version/bin/tox" --version > /dev/null 2>&1
    then
        "$(pyenv root)/versions/$python_version/bin/pip" install --quiet --disable-pip-version-check tox > /dev/null
    fi
done < .python-version

For an interactive shell session use ```console, ```terminal, ```shell_session or ```shell-session:

$ git clone https://github.com/hypothesis/bouncer.git
Cloning into 'bouncer'...
warning: templates not found in /home/seanh/.config/git/template
remote: Enumerating objects: 1766, done.
remote: Total 1766 (delta 0), reused 0 (delta 0), pack-reused 1766
Receiving objects: 100% (1766/1766), 954.14 KiB | 2.16 MiB/s, done.
Resolving deltas: 100% (1044/1044), done.
$ cd bouncer
$ export DEBUG=yes                               # Turn on debug mode.
$ export HYPOTHESIS_URL="http://localhost:5000"  # The URL of the Hypothesis instance to use.
$ make dev
[2019-08-31 19:32:13 +0100] [17902] [INFO] Starting gunicorn 19.9.0
[2019-08-31 19:32:13 +0100] [17902] [INFO] Listening at: http://127.0.0.1:8000 (17902)
[2019-08-31 19:32:13 +0100] [17902] [INFO] Using worker: sync
[2019-08-31 19:32:13 +0100] [17905] [INFO] Booting worker with pid: 17905

Representing Variables with <var>

You can also represent the name of a variable by using the <var> tag:

The variables minSpeed and maxSpeed control the minimum and maximum speed of the apparatus in revolutions per minute (RPM).