Skip to content

Commit 9f8587f

Browse files
authored
Merge pull request #2838 from drgrice1/mathjax-noerror-config-alt
Make MathJax show errors for bad TeX. (alternate approach)
2 parents 6c06cb9 + a7efac1 commit 9f8587f

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

htdocs/js/MathJaxConfig/mathjax-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
if (!window.MathJax) {
22
window.MathJax = {
3-
tex: { packages: { '[+]': ['noerrors'] } },
4-
loader: { load: ['input/asciimath', '[tex]/noerrors'] },
3+
loader: { load: ['input/asciimath'] },
54
startup: {
65
ready() {
76
const AM = MathJax.InputJax.AsciiMath.AM;

lib/WeBWorK/ContentGenerator.pm

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use MIME::Base64;
3232
use Scalar::Util qw(weaken);
3333
use HTML::Entities;
3434
use Encode;
35+
use Mojo::JSON qw(encode_json);
3536

3637
use WeBWorK::File::Scoring qw(parse_scoring_file);
3738
use WeBWorK::Localize;
@@ -682,20 +683,15 @@ sub page_title ($c) {
682683
return route_title($c, $c->current_route, 1);
683684
}
684685

685-
=item webwork_url
686+
=item webwork_js_config
686687
687-
Defined in this package.
688-
689-
Outputs the $webwork_url defined in site.conf, unless $webwork_url is equal to
690-
"/", in which case this outputs the empty string.
691-
692-
This is used to set a value in a global webworkConfig javascript variable,
693-
that can be accessed in javascript files.
688+
Outputs the webwork2 JavaScript configuration. This configuration can be
689+
accessed by JavaScript files to obtain various webwork2 settings.
694690
695691
=cut
696692

697-
sub webwork_url ($c) {
698-
return $c->location;
693+
sub webwork_js_config ($c) {
694+
return encode_json({ webwork_url => $c->location });
699695
}
700696

701697
=item warnings()

templates/ContentGenerator/SampleProblemViewer.html.ep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<%= javascript $c->url({
1515
type => 'webwork', name => 'htdocs', file => 'node_modules/minisearch/dist/umd/index.js'
1616
}), defer => undef =%>
17-
<script>const webworkConfig = { webwork_url: '<%= $c->webwork_url %>' };</script>
17+
<script>const webworkConfig = <%== $c->webwork_js_config %>;</script>
1818
<%= javascript $c->url({
1919
type => 'webwork', name => 'htdocs', file => 'js/SampleProblemViewer/documentation-search.js'
2020
}), defer => undef =%>

templates/layouts/system.html.ep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
% }
2121
%
2222
% # Webwork configuration for javascript
23-
<script>const webworkConfig = { webwork_url: '<%= $c->webwork_url %>' };</script>
23+
<script>const webworkConfig = <%== $c->webwork_js_config %>;</script>
2424
%
2525
% # JS Loads
2626
<%= javascript $c->url({ type => 'webwork', name => 'htdocs', file => 'js/MathJaxConfig/mathjax-config.js' }),

0 commit comments

Comments
 (0)