chore(docs): add code prettification

Closes #285
This commit is contained in:
Peter Bacon Darwin 2014-12-06 11:24:55 +00:00
parent 83a6a1cc0b
commit 94b541a3e8
6 changed files with 164 additions and 41 deletions

View File

@ -39,45 +39,6 @@ pre {
word-wrap: break-word;
}
pre > code.highlight {
padding: 10px;
font-weight: 400;
-webkit-user-select: initial;
-moz-user-select: initial;
-ms-user-select: initial;
user-select: initial;
}
pre, code {
margin: 0;
padding: 0;
overflow-wrap: break-word;
font-family: monospace, serif;
}
pre > code.highlight {
padding: 10px;
font-weight: 400;
}
code {
font-size: 14px;
background: #f6f6f6;
}
code.highlight {
display: block;
overflow-wrap: break-word;
}
code:not(.highlight) {
color: #4285f4;
margin-left: 1px;
margin-right: 1px;
}
.md-sidenav-inner {
background: #fff;
}

View File

@ -0,0 +1,142 @@
/* GitHub Theme */
.prettyprint {
background: white;
font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
font-size: 12px;
line-height: 1.5;
}
.lang-text * {
color: #333333!important;
}
.pln {
color: #333333;
}
@media screen {
.str {
color: #dd1144;
}
.kwd {
color: #333333;
}
.com {
color: #999988;
}
.typ {
color: #445588;
}
.lit {
color: #445588;
}
.pun {
color: #333333;
}
.opn {
color: #333333;
}
.clo {
color: #333333;
}
.tag {
color: navy;
}
.atn {
color: teal;
}
.atv {
color: #dd1144;
}
.dec {
color: #333333;
}
.var {
color: teal;
}
.fun {
color: #990000;
}
}
@media print, projection {
.str {
color: #006600;
}
.kwd {
color: #006;
font-weight: bold;
}
.com {
color: #600;
font-style: italic;
}
.typ {
color: #404;
font-weight: bold;
}
.lit {
color: #004444;
}
.pun, .opn, .clo {
color: #444400;
}
.tag {
color: #006;
font-weight: bold;
}
.atn {
color: #440044;
}
.atv {
color: #006600;
}
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}
/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */
}
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */
}

View File

@ -5,9 +5,12 @@
<base href="/">
<link rel="stylesheet" type="text/css" href="/lib/angular-material/angular-material.css">
<link rel="stylesheet" type="text/css" href="/css/prettify-theme.css">
<link rel="stylesheet" type="text/css" href="/css/app.css">
<script src="/lib/hammerjs/hammer.js"></script>
<script src="/lib/google-code-prettify/src/prettify.js"></script>
<script src="/lib/google-code-prettify/src/lang-css.js"></script>
<script src="/lib/angular/angular.js"></script>
<script src="/lib/angular-animate/angular-animate.js"></script>
<script src="/lib/angular-aria/angular-aria.js"></script>
@ -15,6 +18,7 @@
<script src="/js/navigation-modules.js"></script>
<script src="/js/navigation-guides.js"></script>
<script src="/js/app.js"></script>
<script src="/js/code.js"></script>
</head>
<body ng-app="app" ng-controller="NavController as nav" layout="column">

View File

@ -1,4 +1,4 @@
angular.module('app', ['ngMaterial', 'navigation-modules', 'navigation-guides'])
angular.module('app', ['ngMaterial', 'navigation-modules', 'navigation-guides', 'code'])
.config(function($locationProvider) {
$locationProvider.html5Mode(true);

15
docs/app/js/code.js Normal file
View File

@ -0,0 +1,15 @@
angular.module('code', [])
.directive('code', function() {
return {
restrict: 'E',
terminal: true,
compile: function(element) {
var linenums = element.hasClass('linenum');// || element.parent()[0].nodeName === 'PRE';
var match = /lang-(\S+)/.exec(element[0].className);
var lang = match && match[1];
var html = element.html();
element.html(window.prettyPrintOne(html, lang, linenums));
}
};
});

View File

@ -14,6 +14,7 @@
"tests"
],
"dependencies": {
"angular-material": "~0.6.0"
"angular-material": "~0.6.0",
"google-code-prettify": "~1.0.3"
}
}