Skip to content

Commit 7e84a14

Browse files
docs: syntax highlight from markdown
1 parent aa71a71 commit 7e84a14

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

docs/authorization.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ With `gcloud-node` it's incredibly easy to get authorized and start using Google
44

55
If you are running this client on Google Compute Engine, we handle authorization for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
66

7-
``` js
7+
```js hljs-class
88
var config = {
99
projectId: 'grape-spaceship-123'
1010
};
@@ -26,7 +26,7 @@ If you are not running this client on Google Compute Engine, you need a Google D
2626
* If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authorize your requests.
2727
* If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
2828

29-
``` js
29+
``` js hljs-class
3030
var config = {
3131
projectId: 'grape-spaceship-123',
3232
keyFilename: '/path/to/keyfile.json'

docs/site/components/authorization/authorization.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
<div subpage
1616
header-templateUrl="authorization-header.html"
1717
title="Authorization">
18-
<btf-markdown ng-include="'authorization.md'"></btf-markdown>
18+
<btf-markdown highlight-markdown ng-include="'authorization.md'"></btf-markdown>
1919
</div>

docs/site/components/subpage/subpage-directive.js

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
angular
2-
.module('gcloud.subpage', ['gcloud.header'])
2+
.module('gcloud.subpage', ['gcloud.header', 'hljs'])
3+
34
.directive('subpage', function($rootScope, $location, $http, $parse, getLinks, versions) {
45
'use strict';
56

@@ -34,4 +35,44 @@ angular
3435
}
3536
}
3637
};
38+
})
39+
40+
.directive('hljsClass', function() {
41+
'use strict';
42+
43+
return {
44+
priority: 1500.1,
45+
restrict: 'C',
46+
compile: function(element, attrs) {
47+
attrs._contents = element.text();
48+
}
49+
};
50+
})
51+
52+
.directive('hljsClass', function() {
53+
'use strict';
54+
55+
return {
56+
priority: 1500,
57+
restrict: 'C',
58+
transclude: true,
59+
template: '<div hljs language="javascript" source="contents"></div>',
60+
compile: function(element) {
61+
return function($scope, element, attrs) {
62+
$scope.contents = attrs._contents;
63+
};
64+
}
65+
}
66+
})
67+
68+
.directive('highlightMarkdown', function($compile) {
69+
'use strict';
70+
71+
return {
72+
link: function(scope, element, attrs) {
73+
scope.$watch(attrs.ngInclude, function() {
74+
$compile(element.contents())(scope);
75+
}, true);
76+
}
77+
};
3778
});

docs/site/css/main.css

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ pre {
141141
line-height: 1.6em;
142142
}
143143

144+
[hljs] > pre {
145+
margin: 0 !important;
146+
font-size: 1em;
147+
}
148+
144149
pre,
145150
code {
146151
font-family: Monaco, 'Droid Sans Mono', monospace !important;

0 commit comments

Comments
 (0)