Skip to content

Commit

Permalink
Proper error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
as-com committed Aug 23, 2016
1 parent 6bedd74 commit 9d0eff0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function katex_rubber() {
global $katex_using;
if ($katex_using) {
?>
<script>!function(){"use strict";var t=document.querySelectorAll("script[type='text/katex']");Array.prototype.forEach.call(t,function(t,e){var r={displayMode:"true"===t.getAttribute("data-display"),throwOnError:!1},a=document.createElement("span");katex.render(t.textContent,a,r),t.parentNode.replaceChild(a,t)})}();</script>
<script>!function(){"use strict";var t=document.querySelectorAll("script[type='text/katex']");Array.prototype.forEach.call(t,function(t,e){var r={displayMode:"true"===t.getAttribute("data-display"),throwOnError:!1},a=document.createElement("span");try{katex.render(t.textContent,a,r)}catch(o){t.style.color="red",t.textContent=o.message}t.parentNode.replaceChild(a,t)})}();</script>
<?php
}
}
Expand Down
7 changes: 6 additions & 1 deletion scripts/render-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
throwOnError: false
};
var eq = document.createElement("span");
katex.render(el.textContent, eq, options);
try {
katex.render(el.textContent, eq, options);
} catch (e) {
el.style.color = "red";
el.textContent = e.message;
}
el.parentNode.replaceChild(eq, el);
});
})();

0 comments on commit 9d0eff0

Please sign in to comment.