Skip to content

Commit ec801c2

Browse files
Remove YAML from input2.html
Move YAML information into input2.html. Then we don't need to process YAML. Signed-off-by: David A. Wheeler <[email protected]>
1 parent f5f0b60 commit ec801c2

File tree

2 files changed

+89
-60
lines changed

2 files changed

+89
-60
lines changed

docs/labs/input2.html

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="stylesheet" href="checker.css">
88
<script src="js-yaml.min.js"></script>
99
<script src="checker.js"></script>
10+
<script src="input2.js"></script>
1011
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
1112

1213
<!-- Sample expected answer -->
@@ -33,66 +34,6 @@
3334
\) , \s*
3435
</script>
3536

36-
<!--
37-
The following define hints. Hints are expressed in a JSON array, so:
38-
- \ in a regex is written as \\
39-
- " in a regex is written as \"
40-
- All field names and value strings must be quoted
41-
- commas must *separate* the entries - last one must NOT have a comma.
42-
-->
43-
<script id="info" type="application/yaml">
44-
---
45-
hints:
46-
- absent: ", $"
47-
text: This is a parameter, it must end with a comma.
48-
- absent: |
49-
query \( ["'`]id["'`] \)
50-
text: "Use query() with an 'id' parameter."
51-
- present: |
52-
query \( ["'`]id["'`] \) [^. ]
53-
text: 'After query("id") use a period to invoke a verification method.'
54-
- present: |
55-
(islength|Islength|IsLength|ISLENGTH)
56-
text: >
57-
JavaScript is case-sensitive. Use isLength instead of the case you have.
58-
- absent: isLength
59-
text: "Use isLength()."
60-
- present: |
61-
isLength \( m
62-
text: "You need to pass isLength() an object within {...}."
63-
- absent: matches
64-
text: "Use matches()."
65-
- present: |
66-
matches \( /[^^]
67-
text: "Match the whole string - begin the regular expression with ^"
68-
- present: |
69-
matches \( /.*[^$]/
70-
text: "Match the whole string - end the regular expression with $"
71-
- present: |
72-
matches \( /.*[^$]/
73-
text: Match the whole string - end the regular expression with $
74-
- present: |
75-
matches \( /\^\[A-Z\]-
76-
text: That would match only one letter before the dash, you need two.
77-
- present: |
78-
matches \( /.*(\[0-9\]|\d)\*
79-
text: >
80-
You need to match one or more digits; * allows 0 or more.
81-
A + would be better suited for this task.
82-
- present: |
83-
\s*, , $
84-
text: >
85-
You have two commas at the end. Use only one. You may need to
86-
scroll or increase the text area to see both of them.
87-
successes:
88-
- - query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/),
89-
- - ' query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/ ) , '
90-
failures:
91-
- - query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ ),
92-
- - query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),
93-
- - query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ ),
94-
- - query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/)
95-
</script>
9637
</head>
9738
<body>
9839
<!-- For GitHub Pages formatting: -->

docs/labs/input2.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
info =
2+
{
3+
hints: [
4+
{
5+
absent: ", $",
6+
text: "This is a parameter, it must end with a comma."
7+
},
8+
{
9+
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)
10+
`,
11+
text: "Use query() with an 'id' parameter."
12+
},
13+
{
14+
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]
15+
`,
16+
text: "After query(\"id\") use a period to invoke a verification method."
17+
},
18+
{
19+
present: "(islength|Islength|IsLength|ISLENGTH)\n",
20+
text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n"
21+
},
22+
{
23+
absent: "isLength",
24+
text: "Use isLength()."
25+
},
26+
{
27+
present: String.raw`isLength \( m
28+
`,
29+
text: "You need to pass isLength() an object within {...}."
30+
},
31+
{
32+
absent: "matches",
33+
text: "Use matches()."
34+
},
35+
{
36+
present: String.raw`matches \( /[^^]
37+
`,
38+
text: "Match the whole string - begin the regular expression with ^"
39+
},
40+
{
41+
present: String.raw`matches \( /.*[^$]/
42+
`,
43+
text: "Match the whole string - end the regular expression with $"
44+
},
45+
{
46+
present: String.raw`matches \( /.*[^$]/
47+
`,
48+
text: "Match the whole string - end the regular expression with $"
49+
},
50+
{
51+
present: String.raw`matches \( /\^\[A-Z\]-
52+
`,
53+
text: "That would match only one letter before the dash, you need two."
54+
},
55+
{
56+
present: String.raw`matches \( /.*(\[0-9\]|\d)\*
57+
`,
58+
text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task.\n"
59+
},
60+
{
61+
present: String.raw`\s*, , $
62+
`,
63+
text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them.\n"
64+
}
65+
],
66+
successes: [
67+
[
68+
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/),"
69+
],
70+
[
71+
" query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/ ) , "
72+
]
73+
],
74+
failures: [
75+
[
76+
"query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ ),"
77+
],
78+
[
79+
"query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),"
80+
],
81+
[
82+
"query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ ),"
83+
],
84+
[
85+
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)"
86+
]
87+
]
88+
}

0 commit comments

Comments
 (0)