Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension .js
instead of .test
, you can make Prism highlight arbitrary pieces of code and check their HTML results.
Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension .html.test
instead of .test
, you can make Prism highlight arbitrary pieces of code and check their HTML results.
The language is determined by the folder containing the test file lies, as explained in the previous section.
The structure of your test file will look like this, for example:
-module.exports = {
- '➊': '<span class="token entity" title="➊">&#x278a;</span>',
- '¶': '<span class="token entity" title="¶">&#182;</span>',
-};
- The keys are the codes which will be highlighted by Prism. The values are the expected results, as HTML.
+&
+A
+
+----------------------------------------------------
+
+<span class="token entity named-entity" title="&">&amp;</span>
+<span class="token entity" title="A">&#x41;</span>
+
+----------------------------------------------------
+
+This is a comment explaining this test case.
+