ustyle 1.15.3 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.nvmrc +1 -1
- data/Gruntfile.js +104 -82
- data/README.md +45 -21
- data/dist/ustyle-content.css +1 -1
- data/dist/ustyle-latest.css +1 -1
- data/dist/ustyle.js +148 -97
- data/dist/ustyle.json +1 -1
- data/dist/ustyle.min.js +1 -1
- data/grunt/modules/dss-helper.js +103 -105
- data/grunt/modules/file.js +11 -13
- data/grunt/modules/html-parser.js +12 -14
- data/grunt/modules/templates.js +38 -40
- data/grunt/tasks/browser-sync.js +20 -16
- data/grunt/tasks/builder.js +43 -48
- data/grunt/tasks/styleguide.js +187 -182
- data/index.js +31 -0
- data/lib/ustyle/version.rb +1 -1
- data/package-lock.json +9261 -0
- data/package.json +20 -22
- data/styleguide/assets/javascripts/app.js +83 -56
- data/styleguide/assets/javascripts/modules/stats.js +23 -24
- data/styleguide/assets/javascripts/vendor/highlight.js +1 -1
- data/styleguide/assets/javascripts/vendor/svg4everybody.js +1 -1
- data/styleguide/partials/_footer.tpl +1 -1
- data/styleguide/partials/_sidebar.tpl +1 -1
- data/vendor/assets/javascripts/ustyle/tabs.js +153 -102
- data/vendor/assets/stylesheets/ustyle/mixins/_media-query.scss +0 -2
- metadata +4 -5
- data/JAVASCRIPT_STANDARDS.md +0 -88
- data/config/.jscsrc +0 -76
- data/styleguide/assets/javascripts/modules/cleanWhiteSpace.js +0 -34
@@ -1,120 +1,171 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
var
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
|
1
|
+
window.Tabs = (function(Utils) {
|
2
|
+
|
3
|
+
var addClass = Utils.addClass;
|
4
|
+
var hasClass = Utils.hasClass;
|
5
|
+
var removeClass = Utils.removeClass;
|
6
|
+
var setOptions = Utils.setOptions;
|
7
|
+
|
8
|
+
Tabs.prototype.defaults = {
|
9
|
+
tabContainer: ".us-tabs",
|
10
|
+
tabLinks: ".us-tabs-nav-mainlink",
|
11
|
+
tabNav: ".us-tabs-nav",
|
12
|
+
changeUrls: true,
|
13
|
+
activeClass: "active",
|
14
|
+
collapsible: false,
|
15
|
+
autoScroll: true
|
16
|
+
};
|
17
|
+
|
18
|
+
function Tabs(options) {
|
19
|
+
var ref = this.options = setOptions(options, this.defaults);
|
20
|
+
var tabContainer = ref.tabContainer;
|
21
|
+
var tabLinks = ref.tabLinks;
|
22
|
+
|
23
|
+
this.activeTabEvent = new CustomEvent('ustyle.tab.active');
|
24
|
+
this.tabs = document.querySelectorAll(tabContainer + ' ' + tabLinks);
|
25
|
+
if(!this.tabs.length) return;
|
26
|
+
this.filter = this.tabs.item(0).getAttribute("data-target") ? "data-target" : "href";
|
27
|
+
this.init();
|
28
|
+
|
29
|
+
var handleClick = (function (_this) {
|
30
|
+
return function (e) {
|
31
|
+
var target = e.currentTarget;
|
32
|
+
if (_this.isAccordion() && _this.options.collapsible && _this.isActive(target)) {
|
33
|
+
_this.collapse(target);
|
34
|
+
_this.hashClear();
|
35
|
+
} else {
|
36
|
+
_this.navigateTo(target);
|
37
|
+
_this.scrollToTab(target);
|
38
|
+
_this.hashChange(target);
|
39
|
+
}
|
40
|
+
|
41
|
+
return e.preventDefault();
|
42
|
+
}
|
43
|
+
})(this);
|
44
|
+
|
45
|
+
forEach(this.tabs, function (index, tab) {
|
46
|
+
tab.addEventListener('click', handleClick);
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
Tabs.prototype.init = function() {
|
51
|
+
var activeTab = this.activeTab();
|
52
|
+
var initialHash = this.tabFromHash();
|
53
|
+
|
54
|
+
if (initialHash) {
|
55
|
+
return this.navigateTo(initialHash);
|
56
|
+
} else if (activeTab) {
|
57
|
+
return this.navigateTo(activeTab);
|
58
|
+
} else if (!this.options.collapsible || !this.isAccordion()) {
|
59
|
+
return this.navigateTo(this.tabs.item(0));
|
41
60
|
}
|
61
|
+
};
|
62
|
+
|
63
|
+
Tabs.prototype.hashChange = function(target) {
|
64
|
+
if (!this.options.changeUrls) return;
|
65
|
+
|
66
|
+
return window.location.replace("#!" + (getSelector(target).replace(/#/, "")));
|
67
|
+
};
|
68
|
+
|
69
|
+
Tabs.prototype.hashClear = function() {
|
70
|
+
if (!this.options.changeUrls) return;
|
42
71
|
|
43
|
-
|
44
|
-
|
45
|
-
|
72
|
+
var url = window.location.pathname + window.location.search;
|
73
|
+
return typeof history.replaceState === "function" ? history.replaceState("", document.title, url) : void 0;
|
74
|
+
};
|
46
75
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
76
|
+
Tabs.prototype.navigateTo = function(target) {
|
77
|
+
var selector = getSelector(target);
|
78
|
+
var selected = document.querySelector(selector);
|
79
|
+
var activeClass = this.options.activeClass;
|
80
|
+
var filter = this.filter;
|
81
|
+
|
82
|
+
forEach(this.tabs, function (index, tab) {
|
83
|
+
removeClass(tab, activeClass);
|
84
|
+
});
|
85
|
+
|
86
|
+
forEach(this.tabs, function (index, tab) {
|
87
|
+
if (tab.getAttribute(filter) === selector) {
|
88
|
+
return addClass(tab, activeClass);
|
53
89
|
}
|
54
|
-
};
|
90
|
+
});
|
55
91
|
|
56
|
-
|
57
|
-
if (
|
58
|
-
|
92
|
+
forEach(selected.parentNode.children, function (index, child) {
|
93
|
+
if (child !== selected) {
|
94
|
+
removeClass(child, activeClass);
|
59
95
|
}
|
96
|
+
});
|
97
|
+
|
98
|
+
addClass(selected, activeClass);
|
99
|
+
return selected.dispatchEvent(this.activeTabEvent);
|
100
|
+
};
|
101
|
+
|
102
|
+
Tabs.prototype.collapse = function(target) {
|
103
|
+
var selected = document.querySelector(getSelector(target));
|
104
|
+
var activeClass = this.options.activeClass;
|
60
105
|
|
61
|
-
|
62
|
-
|
106
|
+
forEach(this.tabs, function (index, tab) {
|
107
|
+
removeClass(tab, activeClass);
|
108
|
+
});
|
63
109
|
|
64
|
-
|
65
|
-
|
66
|
-
|
110
|
+
return removeClass(selected, activeClass);
|
111
|
+
};
|
112
|
+
|
113
|
+
Tabs.prototype.scrollToTab = function(target) {
|
114
|
+
if (!(this.isAccordion() && this.options.autoScroll)) {
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
|
118
|
+
var selected = document.querySelector(getSelector(target));
|
119
|
+
return selected.scrollIntoView();
|
120
|
+
};
|
121
|
+
|
122
|
+
Tabs.prototype.activeTab = function() {
|
123
|
+
var activeTab = null;
|
124
|
+
var activeClass = this.options.activeClass;
|
125
|
+
var matchingTab = null;
|
126
|
+
|
127
|
+
forEach(this.tabs, function (index, tab) {
|
128
|
+
if (hasClass(tab, activeClass)) {
|
129
|
+
return matchingTab = tab;
|
67
130
|
}
|
131
|
+
});
|
132
|
+
|
133
|
+
return matchingTab;
|
134
|
+
};
|
68
135
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
this.tabs.filter("[" + this.filter + "='" + selector + "']").addClass(this.options.activeClass);
|
78
|
-
$selected.siblings("." + this.options.activeClass).removeClass(this.options.activeClass).end().addClass(this.options.activeClass);
|
79
|
-
return $selected.trigger("ustyle.tab.active");
|
80
|
-
};
|
81
|
-
|
82
|
-
Tabs.prototype.collapse = function(target) {
|
83
|
-
var $selected = $(getSelector(target));
|
84
|
-
this.tabs.removeClass(this.options.activeClass).end();
|
85
|
-
return $selected.removeClass(this.options.activeClass);
|
86
|
-
};
|
87
|
-
|
88
|
-
Tabs.prototype.scrollToTab = function(target) {
|
89
|
-
if (!(this.isAccordion() && this.options.autoScroll)) {
|
90
|
-
return;
|
136
|
+
Tabs.prototype.tabFromHash = function() {
|
137
|
+
var tabId = window.location.hash.replace("!", "");
|
138
|
+
var filter = this.filter;
|
139
|
+
var matchingTab = null;
|
140
|
+
|
141
|
+
forEach(this.tabs, function (index, tab) {
|
142
|
+
if (tab.getAttribute(filter) === tabId) {
|
143
|
+
return matchingTab = tab;
|
91
144
|
}
|
145
|
+
});
|
92
146
|
|
93
|
-
|
94
|
-
|
95
|
-
};
|
147
|
+
return matchingTab;
|
148
|
+
};
|
96
149
|
|
97
|
-
|
98
|
-
|
99
|
-
|
150
|
+
Tabs.prototype.isActive = function(target) {
|
151
|
+
return getSelector(target) === getSelector(this.activeTab());
|
152
|
+
};
|
100
153
|
|
101
|
-
|
102
|
-
|
103
|
-
return this.tabs.filter("[" + this.filter + "='" + tabId + "']");
|
104
|
-
};
|
154
|
+
Tabs.prototype.isAccordion = function() {
|
155
|
+
var tabNav = document.querySelector(this.options.tabNav);
|
105
156
|
|
106
|
-
|
107
|
-
|
108
|
-
};
|
157
|
+
return !(tabNav.offsetWidth > 0 || tabNav.offsetHeight > 0);
|
158
|
+
};
|
109
159
|
|
110
|
-
|
111
|
-
|
112
|
-
|
160
|
+
var getSelector = function(clicked) {
|
161
|
+
return clicked.getAttribute("data-target") || clicked.getAttribute("href");
|
162
|
+
};
|
113
163
|
|
114
|
-
|
115
|
-
|
116
|
-
|
164
|
+
var forEach = function (array, callback, scope) {
|
165
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
166
|
+
callback.call(scope, i, array[i]);
|
167
|
+
}
|
168
|
+
};
|
117
169
|
|
118
|
-
|
119
|
-
|
120
|
-
})();
|
170
|
+
return Tabs;
|
171
|
+
})(this.Utils);
|
@@ -99,8 +99,6 @@ $devices: ();
|
|
99
99
|
|
100
100
|
/// Output a media query block for the targeted device and a potential internet explorer fallback
|
101
101
|
///
|
102
|
-
/// @require {Variable} devices
|
103
|
-
///
|
104
102
|
/// @param {String} $device
|
105
103
|
/// The device to match up the media query with. Can be one from the list of `$min-breakpoints` (`small-tablet`, `tablet`, `desktop` etc.)
|
106
104
|
/// or `$max-breakpoints` (`mobile`, `to-small-tablet`, `to-tablet`)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ustyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uSwitch Limited
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: sass
|
@@ -142,12 +142,10 @@ files:
|
|
142
142
|
- CONTRIBUTING.md
|
143
143
|
- Gemfile
|
144
144
|
- Gruntfile.js
|
145
|
-
- JAVASCRIPT_STANDARDS.md
|
146
145
|
- LICENSE.txt
|
147
146
|
- README.md
|
148
147
|
- Rakefile
|
149
148
|
- bower.json
|
150
|
-
- config/.jscsrc
|
151
149
|
- config/autoprefixer.yml
|
152
150
|
- config/scss-lint.yml
|
153
151
|
- dist/icons.svg
|
@@ -163,6 +161,7 @@ files:
|
|
163
161
|
- grunt/tasks/browser-sync.js
|
164
162
|
- grunt/tasks/builder.js
|
165
163
|
- grunt/tasks/styleguide.js
|
164
|
+
- index.js
|
166
165
|
- lib/ustyle.rb
|
167
166
|
- lib/ustyle/deploy.rb
|
168
167
|
- lib/ustyle/engine.rb
|
@@ -175,6 +174,7 @@ files:
|
|
175
174
|
- lib/ustyle/sprockets.rb
|
176
175
|
- lib/ustyle/utils.rb
|
177
176
|
- lib/ustyle/version.rb
|
177
|
+
- package-lock.json
|
178
178
|
- package.json
|
179
179
|
- styleguide/CNAME
|
180
180
|
- styleguide/assets/images/CTAs.png
|
@@ -256,7 +256,6 @@ files:
|
|
256
256
|
- styleguide/assets/images/ux-conventions-recognition.png
|
257
257
|
- styleguide/assets/images/ux-conventions-visibility.png
|
258
258
|
- styleguide/assets/javascripts/app.js
|
259
|
-
- styleguide/assets/javascripts/modules/cleanWhiteSpace.js
|
260
259
|
- styleguide/assets/javascripts/modules/stats.js
|
261
260
|
- styleguide/assets/javascripts/vendor/highlight.js
|
262
261
|
- styleguide/assets/javascripts/vendor/svg4everybody.js
|
data/JAVASCRIPT_STANDARDS.md
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# JAVASCRIPT STANDARDS
|
2
|
-
|
3
|
-
### INTRODUCTION
|
4
|
-
|
5
|
-
We are using [JSCS](http://jscs.info/) to lint our javascript code within uStyle.
|
6
|
-
|
7
|
-
### RULES
|
8
|
-
|
9
|
-
Our preset is set to use Airbnb as the base set of options.
|
10
|
-
|
11
|
-
```javascript
|
12
|
-
{
|
13
|
-
"esnext": true,
|
14
|
-
"verbose": true,
|
15
|
-
"requireSpaceAfterKeywords": [
|
16
|
-
"if",
|
17
|
-
"else",
|
18
|
-
"for",
|
19
|
-
"while",
|
20
|
-
"do",
|
21
|
-
"switch",
|
22
|
-
"case",
|
23
|
-
"return",
|
24
|
-
"try",
|
25
|
-
"catch",
|
26
|
-
"typeof"
|
27
|
-
],
|
28
|
-
"disallowSpacesInNamedFunctionExpression": {
|
29
|
-
"beforeOpeningRoundBrace": true
|
30
|
-
},
|
31
|
-
"disallowSpacesInFunctionExpression": {
|
32
|
-
"beforeOpeningRoundBrace": true
|
33
|
-
},
|
34
|
-
"disallowSpacesInAnonymousFunctionExpression": {
|
35
|
-
"beforeOpeningRoundBrace": true
|
36
|
-
},
|
37
|
-
"disallowSpacesInFunctionDeclaration": {
|
38
|
-
"beforeOpeningRoundBrace": true
|
39
|
-
},
|
40
|
-
"disallowEmptyBlocks": true,
|
41
|
-
"disallowSpacesInsideArrayBrackets": true,
|
42
|
-
"disallowSpacesInsideParentheses": true,
|
43
|
-
"disallowSpaceAfterObjectKeys": true,
|
44
|
-
"disallowSpaceAfterPrefixUnaryOperators": true,
|
45
|
-
"disallowSpaceBeforePostfixUnaryOperators": true,
|
46
|
-
"disallowSpaceBeforeBinaryOperators": [
|
47
|
-
","
|
48
|
-
],
|
49
|
-
"disallowMixedSpacesAndTabs": true,
|
50
|
-
"disallowTrailingWhitespace": true,
|
51
|
-
"requireTrailingComma": { "ignoreSingleLine": true },
|
52
|
-
"disallowYodaConditions": true,
|
53
|
-
"disallowKeywords": [ "with" ],
|
54
|
-
"disallowKeywordsOnNewLine": ["else"],
|
55
|
-
"disallowMultipleLineBreaks": true,
|
56
|
-
"disallowMultipleLineStrings": true,
|
57
|
-
"disallowMultipleVarDecl": true,
|
58
|
-
"disallowSpaceBeforeComma": true,
|
59
|
-
"disallowSpaceBeforeSemicolon": true,
|
60
|
-
"requireSpaceBeforeBlockStatements": true,
|
61
|
-
"requireParenthesesAroundIIFE": true,
|
62
|
-
"requireSpacesInConditionalExpression": true,
|
63
|
-
"requireBlocksOnNewline": 1,
|
64
|
-
"requireCommaBeforeLineBreak": true,
|
65
|
-
"requireSpaceBeforeBinaryOperators": true,
|
66
|
-
"requireSpaceAfterBinaryOperators": true,
|
67
|
-
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
68
|
-
"requireLineFeedAtFileEnd": true,
|
69
|
-
"requireCapitalizedConstructors": true,
|
70
|
-
"requireDotNotation": true,
|
71
|
-
"requireSpacesInForStatement": true,
|
72
|
-
"requireSpaceBetweenArguments": true,
|
73
|
-
"requireCurlyBraces": [
|
74
|
-
"do"
|
75
|
-
],
|
76
|
-
"requirePaddingNewLinesBeforeLineComments": {
|
77
|
-
"allExcept": "firstAfterCurly"
|
78
|
-
},
|
79
|
-
"requirePaddingNewLinesAfterBlocks": true,
|
80
|
-
"requireSemicolons": true,
|
81
|
-
"safeContextKeyword": "_this",
|
82
|
-
"validateLineBreaks": "LF",
|
83
|
-
"validateIndentation": 2,
|
84
|
-
|
85
|
-
"validateQuoteMarks": "\"",
|
86
|
-
"requireTrailingComma": null
|
87
|
-
}
|
88
|
-
```
|
data/config/.jscsrc
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"esnext": true,
|
3
|
-
"verbose": true,
|
4
|
-
"requireSpaceAfterKeywords": [
|
5
|
-
"if",
|
6
|
-
"else",
|
7
|
-
"for",
|
8
|
-
"while",
|
9
|
-
"do",
|
10
|
-
"switch",
|
11
|
-
"case",
|
12
|
-
"return",
|
13
|
-
"try",
|
14
|
-
"catch",
|
15
|
-
"typeof"
|
16
|
-
],
|
17
|
-
"disallowSpacesInNamedFunctionExpression": {
|
18
|
-
"beforeOpeningRoundBrace": true
|
19
|
-
},
|
20
|
-
"disallowSpacesInFunctionExpression": {
|
21
|
-
"beforeOpeningRoundBrace": true
|
22
|
-
},
|
23
|
-
"disallowSpacesInAnonymousFunctionExpression": {
|
24
|
-
"beforeOpeningRoundBrace": true
|
25
|
-
},
|
26
|
-
"disallowSpacesInFunctionDeclaration": {
|
27
|
-
"beforeOpeningRoundBrace": true
|
28
|
-
},
|
29
|
-
"disallowEmptyBlocks": true,
|
30
|
-
"disallowSpacesInsideArrayBrackets": true,
|
31
|
-
"disallowSpacesInsideParentheses": true,
|
32
|
-
"disallowSpaceAfterObjectKeys": true,
|
33
|
-
"disallowSpaceAfterPrefixUnaryOperators": true,
|
34
|
-
"disallowSpaceBeforePostfixUnaryOperators": true,
|
35
|
-
"disallowSpaceBeforeBinaryOperators": [
|
36
|
-
","
|
37
|
-
],
|
38
|
-
"disallowMixedSpacesAndTabs": true,
|
39
|
-
"disallowTrailingWhitespace": true,
|
40
|
-
"requireTrailingComma": { "ignoreSingleLine": true },
|
41
|
-
"disallowYodaConditions": true,
|
42
|
-
"disallowKeywords": [ "with" ],
|
43
|
-
"disallowKeywordsOnNewLine": ["else"],
|
44
|
-
"disallowMultipleLineBreaks": true,
|
45
|
-
"disallowMultipleLineStrings": true,
|
46
|
-
"disallowMultipleVarDecl": true,
|
47
|
-
"disallowSpaceBeforeComma": true,
|
48
|
-
"disallowSpaceBeforeSemicolon": true,
|
49
|
-
"requireSpaceBeforeBlockStatements": true,
|
50
|
-
"requireParenthesesAroundIIFE": true,
|
51
|
-
"requireSpacesInConditionalExpression": true,
|
52
|
-
"requireBlocksOnNewline": 1,
|
53
|
-
"requireCommaBeforeLineBreak": true,
|
54
|
-
"requireSpaceBeforeBinaryOperators": true,
|
55
|
-
"requireSpaceAfterBinaryOperators": true,
|
56
|
-
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
57
|
-
"requireLineFeedAtFileEnd": true,
|
58
|
-
"requireCapitalizedConstructors": true,
|
59
|
-
"requireDotNotation": true,
|
60
|
-
"requireSpacesInForStatement": true,
|
61
|
-
"requireSpaceBetweenArguments": true,
|
62
|
-
"requireCurlyBraces": [
|
63
|
-
"do"
|
64
|
-
],
|
65
|
-
"requirePaddingNewLinesBeforeLineComments": {
|
66
|
-
"allExcept": "firstAfterCurly"
|
67
|
-
},
|
68
|
-
"requirePaddingNewLinesAfterBlocks": true,
|
69
|
-
"requireSemicolons": true,
|
70
|
-
"safeContextKeyword": "_this",
|
71
|
-
"validateLineBreaks": "LF",
|
72
|
-
"validateIndentation": 2,
|
73
|
-
|
74
|
-
"validateQuoteMarks": "\"",
|
75
|
-
"requireTrailingComma": null
|
76
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
function cleanWhiteSpace(codeBlocks){
|
2
|
-
if (!codeBlocks) return;
|
3
|
-
|
4
|
-
for (var i = codeBlocks.length - 1; i >= 0; i--) {
|
5
|
-
var codeBlock = codeBlocks[i],
|
6
|
-
lines, offset;
|
7
|
-
|
8
|
-
var text = codeBlock.textContent || codeBlock.innerText;
|
9
|
-
|
10
|
-
lines = text.split( '\n' );
|
11
|
-
|
12
|
-
if ( lines.length > 1 && lines[ lines.length - 1 ].trim() === '' ){
|
13
|
-
lines.pop();
|
14
|
-
}
|
15
|
-
|
16
|
-
var canClean = lines[1] != undefined;
|
17
|
-
|
18
|
-
if (canClean) {
|
19
|
-
// how much white-space do we need to remove form each line?
|
20
|
-
offset = lines[ 1 ].match( /^\s*/ )[ 0 ].length;
|
21
|
-
|
22
|
-
// remove the excess white-space from the beginning of each line
|
23
|
-
lines = lines.map( function ( line ) {
|
24
|
-
return line.slice( offset );
|
25
|
-
});
|
26
|
-
|
27
|
-
lines.shift();
|
28
|
-
|
29
|
-
codeBlock.textContent = lines.join( '\n' );
|
30
|
-
}
|
31
|
-
|
32
|
-
hljs.highlightBlock(codeBlock);
|
33
|
-
};
|
34
|
-
}
|