Skip to content

Commit 2cc4660

Browse files
Core: Added better error message for missing grammars (#3311)
1 parent 3f8cc5a commit 2cc4660

File tree

8 files changed

+23
-14
lines changed

8 files changed

+23
-14
lines changed

components/prism-core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ var Prism = (function (_self) {
659659
language: language
660660
};
661661
_.hooks.run('before-tokenize', env);
662+
if (!env.grammar) {
663+
throw new Error('The language "' + env.language + '" has no grammar.');
664+
}
662665
env.tokens = _.tokenize(env.code, env.grammar);
663666
_.hooks.run('after-tokenize', env);
664667
return Token.stringify(_.util.encode(env.tokens), env.language);

components/prism-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Prism.hooks.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h2>
7373

7474
<dt class="tag-source">Source:</dt>
7575
<dd class="tag-source"><ul class="dummy"><li>
76-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line714">line 714</a>
76+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line717">line 717</a>
7777
</li></ul></dd>
7878

7979

@@ -152,7 +152,7 @@ <h4 class="name" id=".add"><span class="type-signature">(static) </span>add<span
152152

153153
<dt class="tag-source">Source:</dt>
154154
<dd class="tag-source"><ul class="dummy"><li>
155-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line729">line 729</a>
155+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line732">line 732</a>
156156
</li></ul></dd>
157157

158158

@@ -314,7 +314,7 @@ <h4 class="name" id=".run"><span class="type-signature">(static) </span>run<span
314314

315315
<dt class="tag-source">Source:</dt>
316316
<dd class="tag-source"><ul class="dummy"><li>
317-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line746">line 746</a>
317+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line749">line 749</a>
318318
</li></ul></dd>
319319

320320

docs/Prism.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ <h4 class="name" id=".tokenize"><span class="type-signature">(static) </span>tok
12441244

12451245
<dt class="tag-source">Source:</dt>
12461246
<dd class="tag-source"><ul class="dummy"><li>
1247-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line691">line 691</a>
1247+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line694">line 694</a>
12481248
</li></ul></dd>
12491249

12501250

docs/Token.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h4 class="name" id="Token"><span class="type-signature"></span>new Token<span c
8080

8181
<dt class="tag-source">Source:</dt>
8282
<dd class="tag-source"><ul class="dummy"><li>
83-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line780">line 780</a>
83+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line783">line 783</a>
8484
</li></ul></dd>
8585

8686

@@ -364,7 +364,7 @@ <h4 class="name" id="alias"><span class="type-signature"></span>alias<span class
364364

365365
<dt class="tag-source">Source:</dt>
366366
<dd class="tag-source"><ul class="dummy"><li>
367-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line807">line 807</a>
367+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line810">line 810</a>
368368
</li></ul></dd>
369369

370370

@@ -447,7 +447,7 @@ <h4 class="name" id="content"><span class="type-signature"></span>content<span c
447447

448448
<dt class="tag-source">Source:</dt>
449449
<dd class="tag-source"><ul class="dummy"><li>
450-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line799">line 799</a>
450+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line802">line 802</a>
451451
</li></ul></dd>
452452

453453

@@ -524,7 +524,7 @@ <h4 class="name" id="type"><span class="type-signature"></span>type<span class="
524524

525525
<dt class="tag-source">Source:</dt>
526526
<dd class="tag-source"><ul class="dummy"><li>
527-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line790">line 790</a>
527+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line793">line 793</a>
528528
</li></ul></dd>
529529

530530

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy