2017-03-09 13:16:08 -05:00
---
layout: default
title: Code
parent: UI Components
2018-11-16 11:47:14 -05:00
nav_order: 6
2017-03-09 13:16:08 -05:00
---
2017-03-24 09:47:37 -04:00
# Code
2019-01-14 14:18:09 -05:00
{: .no_toc }
2017-03-24 09:47:37 -04:00
## Table of contents
{: .no_toc .text-delta }
1. TOC
{:toc}
---
## Inline code
2019-01-14 14:32:41 -05:00
Code can be rendered inline by wrapping it in single back ticks.
2017-03-24 09:47:37 -04:00
< div class = "code-example" markdown = "1" >
Lorem ipsum dolor sit amet, `<inline code snippet>` adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
< / div >
```markdown
Lorem ipsum dolor sit amet, `<inline code snippet>` adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
```
---
## Syntax highlighted code blocks
2019-01-14 14:32:41 -05:00
Use Jekyll's built-in syntax highlighting with Rouge for code blocks by using three backticks, followed by the language name:
2017-03-24 09:47:37 -04:00
< div class = "code-example" markdown = "1" >
```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l)
return true;
}
```
< / div >
{% highlight markdown %}
```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l)
return true;
}
```
{% endhighlight %}
---
## Code blocks with rendered examples
2019-01-14 14:32:41 -05:00
To demonstrate front end code, sometimes it's useful to show a rendered example of that code. After including the styles from your project that you'll need to show the rendering, you can use a `<div>` with the `code-example` class, followed by the code block syntax. If you want to render your output with Markdown instead of HTML, use the `markdown="1"` attribute to tell Jekyll that the code you are rendering will be in Markdown format... This is about to get meta...
2017-03-24 09:47:37 -04:00
< div class = "code-example" markdown = "1" >
< div class = "code-example" markdown = "1" >
[Link button ](http://example.com/ ){: .btn }
< / div >
```markdown
[Link button ](http://example.com/ ){: .btn }
```
< / div >
{% highlight markdown %}
< div class = "code-example" markdown = "1" >
[Link button ](http://example.com/ ){: .btn }
< / div >
```markdown
[Link button ](http://example.com/ ){: .btn }
```
{% endhighlight %}