Skip to content

Commit 8ace755

Browse files
committed
improvements to cheatsheet.
Signed-off-by: Grant Skinner <[email protected]>
1 parent d71e1e5 commit 8ace755

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = function (grunt) {
7979
run: {
8080
options: {
8181
compass: true,
82-
// In prep-tasks, we change the style for a build, to compressed;
82+
// In prep-tasks, we change the style for a build, to nested;
8383
style: "nested", // Can be nested, compact, compressed, expanded
8484
"line-numbers": true,
8585
precision: 2,
@@ -190,7 +190,7 @@ module.exports = function (grunt) {
190190
}
191191
});
192192
}
193-
193+
194194
if (missing.length) {
195195
// \x07 == beep sound in the terminal.
196196
grunt.log.warn("\x07Missing ", missing.length + " scripts.\n\t" + missing.join("\n\t"));

index.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,31 @@ <h1 class="substitution-title">Substitution</h1>
163163
</div>
164164
<div id="cheatsheet">
165165
<table class="cheatsheet">
166-
<tr><td>.</td><td>any char except newline</td></tr>
167-
<tr><td>\w \d \s</td><td>word, digit, space char</td></tr>
168-
<tr><td>\W \D \S</td><td>NOT word, digit, space char</td></tr>
166+
<tr><th colspan="2" onclick="regexr.libView.show('charclasses')">Character classes</th></tr>
167+
<tr><td>.</td><td>any except newline</td></tr>
168+
<tr><td>\w \d \s</td><td>word, digit, space</td></tr>
169+
<tr><td>\W \D \S</td><td>NOT word, digit, space</td></tr>
169170
<tr><td>[abc]</td><td>any of a, b, or c</td></tr>
170171
<tr><td>[^abc]</td><td>NOT a, b, or c</td></tr>
171-
<tr><td>[a-g]</td><td>a char between a & g</td></tr>
172+
<tr><td>[a-g]</td><td>between a & g</td></tr>
172173

174+
<tr><th colspan="2" onclick="regexr.libView.show('anchors')">Anchors</th></tr>
173175
<tr><td>^ $</td><td>start / end of the string</td></tr>
174176
<tr><td>\b</td><td>word boundary</td></tr>
175177

176-
<tr><td>\. \* \\</td><td>escaped special chars</td></tr>
178+
<tr><th colspan="2" onclick="regexr.libView.show('escchars')">Escaped characters</th></tr>
179+
<tr><td>\. \* \\</td><td>escaped special characters</td></tr>
180+
<tr><td>\t \n \r</td><td>tab, linefeed, carriage return</td></tr>
177181
<tr><td>\u00A9</td><td>unicode escaped &copy;</td></tr>
178182

183+
<tr><th colspan="2" onclick="regexr.libView.show('groups')">Groups & Lookaround</th></tr>
179184
<tr><td>(abc)</td><td>capture group</td></tr>
180-
<tr><td>\1 \2</td><td>backreference to capture group</td></tr>
185+
<tr><td>\1</td><td>backreference (group 1)</td></tr>
181186
<tr><td>(?:abc)</td><td>non-capturing group</td></tr>
182187
<tr><td>(?=abc)</td><td>positive lookahead</td></tr>
183188
<tr><td>(?!abc)</td><td>negative lookahead</td></tr>
184189

190+
<tr><th colspan="2" onclick="regexr.libView.show('quants')">Quantifiers & Alternation</th></tr>
185191
<tr><td>a+</td><td>one or more</td></tr>
186192
<tr><td>a*</td><td>zero or more</td></tr>
187193
<tr><td>a?</td><td>zero or one</td></tr>

js/documentation.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var library = {
7575
kids: [
7676
{
7777
label: "Character classes",
78+
id: "charclasses",
7879
desc: "Character classes match a character from a specific set. There are a number of predefined character classes and you can also define your own sets.",
7980
kids: [
8081
{
@@ -160,6 +161,7 @@ var library = {
160161

161162
{
162163
label:"Anchors",
164+
id:"anchors",
163165
desc:"Anchors are unique in that they match a position within a string, not a character.",
164166
kids:[
165167
{
@@ -198,6 +200,7 @@ var library = {
198200
},
199201
{
200202
label: "Escaped characters",
203+
id:"escchars",
201204
desc: "Some characters have special meaning in regular expressions and must be escaped. All escaped characters begin with the <code>\\</code> character.<br/><br/> Within a character set, only <code>\\</code>, <code>-</code>, and <code>]</code> need to be escaped.",
202205
kids: [
203206
{
@@ -233,6 +236,7 @@ var library = {
233236
},
234237
{
235238
label: "Groups & Lookaround",
239+
id:"groups",
236240
desc: "Groups allow you to combine a sequence of tokens to operate on them together. Capture groups can be referenced by a backreference and accessed separately in the results."+
237241
"<hr/>Lookaround lets you match a group without including it in the result.",
238242
kids: [
@@ -288,6 +292,7 @@ var library = {
288292
},
289293
{
290294
label: "Quantifiers & Alternation",
295+
id:"quants",
291296
desc: "Quantifiers indicate that the preceding token must be matched a certain number of times. By default, quantifiers are greedy, and will match as many characters as possible."+
292297
"<hr/>Alternation acts like a boolean OR, matching one sequence or another.",
293298
kids: [
@@ -419,7 +424,7 @@ var library = {
419424
},
420425
{
421426
id:"cheatsheet",
422-
label: "Cheat Sheet",
427+
label: "Cheatsheet",
423428
max:true,
424429
kids:[],
425430
icon: "&#xE072;",

js/index.template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ SOFTWARE.
3434
var p = s.prototype = {};
3535
p._ctaAnimation = null;
3636
p.docView = null;
37+
p.libView = null;
3738

3839
p.init = function () {
3940

@@ -77,6 +78,7 @@ SOFTWARE.
7778
docView.resetHistory();
7879

7980
var libView = new LibView($.el("#libview"), Docs.content.library);
81+
this.libView = libView;
8082

8183
libView.docView = docView;
8284
docView.libView = libView;

js/views/LibView.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ SOFTWARE.
128128

129129
if (item.max) {
130130
$.addClass(this.content, "maximized");
131-
console.log("max");
132131
} else {
133132
$.removeClass(this.content, "maximized");
134133
}

scss/views/libView.scss

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,21 @@ table.cheatsheet {
144144
position: relative;
145145
border-spacing: 0;
146146

147-
td {
148-
margin:0;
149-
padding:0;
150-
border:0;
147+
th {
148+
@extend %user-select-none;
149+
cursor: pointer;
150+
background: rgba(255,255,255,0.06);
151+
text-align: left;
152+
padding: 0.25rem 0.25rem 0.25rem 0.375rem;
153+
154+
&:hover {
155+
color:$white;
156+
}
151157
}
152158

153159
td:first-child {
154160
font-family: $monospace;
155161
color: $white;
156-
padding-right: 0.5em;
157-
}
158-
159-
tr:nth-child(odd) {
160-
background: rgba(255,255,255,0.02);
162+
padding-right: 0.25em;
161163
}
162164
}

0 commit comments

Comments
 (0)