Jekyll - Code Blocks

 

Code Spans

Use <html> tags for this.

Here is a literal ` backtick. And here is `some` text (note the two spaces so that one is left in the output!).

(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();

markdown:

Here is a literal `` ` `` backtick.
And here is ``  `some`  `` text (note the two spaces so that one is left
in the output!).

Standard Code Blocks

Here comes some code

This text belongs to the same code block.
This one is separate.

markdown:

    Here comes some code

    This text belongs to the same code block.

^
    This one is separate.

(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();

markdown:

```
(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();
```

(() => console.log('hello, world!'))();

markdown:

```javascript
(() => console.log('hello, world!'))();
```

(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();

Highlighting Code Snippets

(() => console.log('hello, world!'))();

markdown:

{% highlight javascript %}
(() => console.log('hello, world!'))();
{% endhighlight %}

Line Numbers

1
2
3
4
var hello = 'hello';
var world = 'world';
var space = ' ';
(() => console.log(hello + space + world + space + hello + space + world + space + hello + space + world + space + hello + space + world))();

markdown:

{% highlight javascript linenos %}
var hello = 'hello';
var world = 'world';
var space = ' ';
(() => console.log(hello + space + world + space + hello + space + world + space + hello + space + world + space + hello + space + world))();
{% endhighlight %}

(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();
(() => console.log('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'))();

Fenced Code Blocks

Here comes some code.

markdown:

~~~
Here comes some code.
~~~

~~~~~~~
code with tildes
~~~~~~~~

markdown:

~~~~~~~~~~~~
~~~~~~~
code with tildes
~~~~~~~~
~~~~~~~~~~~~~~~~~~

Language of Code Blocks

def what?
  42
end

markdown:

~~~
def what?
  42
end
~~~
{: .language-ruby}

def what?
  42
end

markdown:

~~~ ruby
def what?
  42
end
~~~