angular-cn/public/docs/_includes/styleguide/_code-examples.jade

83 lines
2.9 KiB
Plaintext
Raw Normal View History

2015-04-06 07:08:11 -07:00
#sg-code.showcase.shadow-1
2015-04-06 06:41:08 -07:00
header.showcase-header
h2 Code Examples
p Below are some examples of how you can add/customize code examples in a page.
2015-05-18 06:41:26 -07:00
strong.l-space-top-3.l-space-bottom-1 ATTRIBUTES:
ul
li <strong>name</strong> Name displayed in Tab (required for tabs)
li <strong>language</strong> javascript, html, etc.
li <strong>escape</strong> html (escapes html, woot!)
li <strong>format</strong> linenums (or linenums:4 specify starting line)
2015-04-06 06:41:08 -07:00
.showcase-content
.l-sub-section
h3 Adding a code example
2015-05-18 06:41:26 -07:00
code-example(format="linenums" language="html").
code-example(format="linenums" language="javascript").
//SOME CODE
2015-04-06 06:41:08 -07:00
.l-sub-section
h3 Specify starting line number
2015-05-18 06:41:26 -07:00
code-example(language="javascript" format="linenums:4").
code-example(language="html" format="linenums:4").
var title = "This starts on line four";
2015-04-06 07:08:11 -07:00
.l-sub-section
h3 Specify a language
p.
Prettify makes a best effort to guess the language but
works best with C-like and HTML-like languages. For
others, there are special language handlers that are
chosen based on language hints. Add a class that matches
your desired language (example below uses <strong>.lang-html</strong>)
code-example(language="html" format="linenums").
h1 Title
p This is some copy...
2015-04-06 07:08:11 -07:00
2015-04-06 06:41:08 -07:00
.l-sub-section
h3 Code Highlighting
p.
There are three types of highlights avialable
<strong>Outlined</strong>, <strong>Pink</strong>, and
<strong>Black</strong>. You can see examples below and
the class names needed for each type.
2015-05-18 06:41:26 -07:00
code-example(format="linenums").
// Pink Background Version
// class="pnk"
var elephants = "The <span class='pnk'>pink</span> elephants were marching...";
// Black Background Version
// class="blk"
var night = "The night was pitch <span class='blk'>black</span>.";
// Outlined Version
// class="otl"
var match = "The <span class='otl'>bird</span> ate <span class='otl'>bird</span> seed near the <span class='otl'>bird</span> bath ";
.l-sub-section
h3 Code Tabs
p.
Code Tabs are a great way to show different languages and versions
of a particular piece of code. When using these tabs make sure the
<stron>content is always related</strong>.
2015-04-06 06:41:08 -07:00
code-tabs
code-pane(language="javascript" format="linenums" name="ES5").
// ES5
var hello = 'blah';
2015-04-06 06:41:08 -07:00
code-pane(language="javascript" format="linenums" name="TypeScript").
// TypeScript
var hello = 'blah';
2015-05-18 06:41:26 -07:00
p To create code tabs simply use the directives below
code-example(format="linenums").
code-tabs
code-pane(format="linenums" name="Tab 1").
// TAB 1 CONTENT
code-pane(format="linenums" name="Tab 2").
// TAB 2 CONTENT