You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extending.html
+11-13Lines changed: 11 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ <h1>Creating a new language definition</h1>
129
129
130
130
<p>This will make your language available to the <ahref="test.html">test page</a>, or more precise: your local version of it. You can open your local <code>test.html</code> page in any browser, select your language, and see how your language definition highlights any code you input.</p>
131
131
132
-
<p><em>Note:</em> You have to reload the test page to apply changes made to <code>prism-foo-bar.js</code> but you don't have to rebuild Prism itself. However, if you change <code>components.json</code> (e.g. because you added a dependency) then these changes will not show up until you rebuild Prism.</p>
132
+
<p><em>Note:</em> You have to reload the test page to apply changes made to <code>prism-foo-bar.js</code> but you don't have to rebuild Prism itself. However, if you change <code>components.json</code> (e.g. because you added a dependency) then these changes will not show up on the test page until you rebuild Prism.</p>
133
133
</li>
134
134
<li>
135
135
<p>Write the language definition.</p>
@@ -172,7 +172,7 @@ <h1>Creating a new language definition</h1>
172
172
}</code></pre>
173
173
</li>
174
174
<li>
175
-
<p>Add some tests.</p>
175
+
<p>Adding tests.</p>
176
176
177
177
<p>Create a folder <code>tests/languages/foo-bar/</code>. This is where your test files will live. The test format and how to run tests is described <ahref="test-suite.html">here</a>.</p>
178
178
@@ -184,8 +184,6 @@ <h1>Creating a new language definition</h1>
@@ -197,30 +195,30 @@ <h1>Creating a new language definition</h1>
197
195
<p>Add the code to test and a brief description.</p>
198
196
</li>
199
197
<li>
200
-
<p>Verify that your language definition correctly highlights the test code. This can be done using the test page. <br>
198
+
<p>Verify that your language definition correctly highlights the test code. This can be done using your local version of the test page. <br>
201
199
<em>Note:</em> Using the <em>Show tokens</em> options, you see the token stream your language definition created.</p>
202
200
</li>
203
201
<li>
204
202
<p>Once you <strong>carefully checked</strong> that the test case is handled correctly (i.e. by using the test page), run the following command:</p>
205
-
<codeclass="language-bash">npm run test:languages -- --language=foo-bar --pretty</code>
206
-
<p>This command will check only your test files. The new test will fail because the specified JSON is incorrect but the error message of the failed test will also include the JSON of the simplified token stream Prism created. This is what we're after. Replace the current incorrect JSON with the output labeled <em>Token Stream</em>. (Please also adjust the indentation. We use tabs.)</p>
203
+
<codeclass="language-bash">npm run test:languages -- --language=foo-bar --accept</code>
204
+
<p>This command will take the token stream your language definition currently produces and inserted into the test file. The empty space between the two lines separating the code and the description of test case will be replaced with a <ahref="test-suite.html#writing-tests-explaining-the-simplified-token-stream">simplified version of the token stream</a>.</p>
207
205
</li>
208
206
<li>
209
-
<p><strong>Carefully check</strong> that the token stream JSON you just inserted is what you expect.</p>
207
+
<p><strong>Carefully check</strong> that the inserted token stream JSON is what you expect.</p>
210
208
</li>
211
-
<li>Re-run <codeclass="language-bash">npm run test:languages -- --language=foo-bar --pretty</code> to verify that the test passes.</li>
209
+
<li>Re-run <codeclass="language-bash">npm run test:languages -- --language=foo-bar</code> to verify that the test passes.</li>
212
210
</ol>
213
211
</li>
214
-
<li>
215
-
<p>Run <codeclass="language-bash">npm test</code> to check that <em>all</em> tests pass, not just your language tests.<br>
216
-
This will usually pass without problems. If you can't get all the tests to pass, skip this step.</p>
217
-
</li>
218
212
<li>
219
213
<p>Add an example page.</p>
220
214
221
215
<p>Create a new file <code>examples/prism-foo-bar.html</code>. This will be the template containing the example markup. Just look at other examples to see how these files are structured. <br>
222
216
We don't have any rules as to what counts as an example, so a single <em>Full example</em> section where you present the highlighting of the major features of the language is enough.</p>
223
217
</li>
218
+
<li>
219
+
<p>Run <codeclass="language-bash">npm test</code> to check that <em>all</em> tests pass, not just your language tests.<br>
220
+
This will usually pass without problems. If you can't get all the tests to pass, skip this step.</p>
221
+
</li>
224
222
<li>
225
223
<p>Run <codeclass="language-bash">npm run build</code> again.</p>
0 commit comments