From f803dcbc8eee3b2f2a8b01997c80553b4188f793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Fri, 25 Aug 2017 11:11:07 -0700 Subject: [PATCH] Handle non-standard code blocks gracefully Prior to this change, Docusaurus would encounter an error when trying to parse a ```SnackPlayer ``` codeblock in Prism.js. These code blocks are unique to the React Native site as of this writing. A proper long term fix would be to handle SnackPlayer properly as we do in the React Native website, but until then let's avoid crashing when we encounter these types of blocks. --- lib/core/Prism.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/Prism.js b/lib/core/Prism.js index 3030745466..b75f2834e6 100644 --- a/lib/core/Prism.js +++ b/lib/core/Prism.js @@ -256,9 +256,9 @@ const Prism = { const strarr = [text]; - const rest = grammar.rest; - if (rest) { + if (grammar && grammar.rest) { + const rest = grammar.rest; for (var token in rest) { grammar[token] = rest[token]; }