Skip to content

Commit 8e1f38f

Browse files
Website: Updated and improved guide on "Extending Prism" page (#2586)
1 parent 00bf00e commit 8e1f38f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

extending.html

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h1>Creating a new language definition</h1>
129129

130130
<p>This will make your language available to the <a href="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>
131131

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>
133133
</li>
134134
<li>
135135
<p>Write the language definition.</p>
@@ -172,7 +172,7 @@ <h1>Creating a new language definition</h1>
172172
}</code></pre>
173173
</li>
174174
<li>
175-
<p>Add some tests.</p>
175+
<p>Adding tests.</p>
176176

177177
<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 <a href="test-suite.html">here</a>.</p>
178178

@@ -184,8 +184,6 @@ <h1>Creating a new language definition</h1>
184184

185185
----------------------------------------------------
186186

187-
[ "JSON of the simplified token stream. We will add this later." ]
188-
189187
----------------------------------------------------
190188

191189
Brief description.</code></pre>
@@ -197,30 +195,30 @@ <h1>Creating a new language definition</h1>
197195
<p>Add the code to test and a brief description.</p>
198196
</li>
199197
<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>
201199
<em>Note:</em> Using the <em>Show tokens</em> options, you see the token stream your language definition created.</p>
202200
</li>
203201
<li>
204202
<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-
<code class="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+
<code class="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 <a href="test-suite.html#writing-tests-explaining-the-simplified-token-stream">simplified version of the token stream</a>.</p>
207205
</li>
208206
<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>
210208
</li>
211-
<li>Re-run <code class="language-bash">npm run test:languages -- --language=foo-bar --pretty</code> to verify that the test passes.</li>
209+
<li>Re-run <code class="language-bash">npm run test:languages -- --language=foo-bar</code> to verify that the test passes.</li>
212210
</ol>
213211
</li>
214-
<li>
215-
<p>Run <code class="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>
218212
<li>
219213
<p>Add an example page.</p>
220214

221215
<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>
222216
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>
223217
</li>
218+
<li>
219+
<p>Run <code class="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>
224222
<li>
225223
<p>Run <code class="language-bash">npm run build</code> again.</p>
226224

0 commit comments

Comments
 (0)