WeBWorK Main Forum

Macros for GT LT, etc are rendered as code

Macros for GT LT, etc are rendered as code

by Bob Mahar -
Number of replies: 11

We recently set up a brand new WW server with the latest appliance image and generally everything is OK.    We do have one residual problem, $LTE and so on macros display as code.    I have confirmed that the MathJax js files from localOverrides.con is accessible and it "seems" as if MathJax is installed - and given its from the pe-made appliance image I would assume its working?   The problem file itself uses the PG macros for these symbols:


$mc = new_multiple_choice();
$mc->qa('Determine the domain of the function.', "\( x {\not =} -$int \)");
$mc->extra("\( x $GTE -$int \)", "\( x $LTE -$int \)", "all Real numbers");

( Also... I'm just the friendly neighborhood IT person, not a WW guru, so please be gentle if this is a stupid question. )

Screen shot of rendered problem


Thanks!

-- Bob

In reply to Bob Mahar

Re: Macros for GT LT, etc are rendered as code

by Glenn Rice -
What version of WeBWorK is this? If you are using a version of WeBWorK prior to version 2.16 (the latest), then you will need to make sure that you have the legacy-v2 MathJax branch. Go to the MathJax directory (usually /opt/webwork/MathJax) and run "git status" and see what branch it shows. That command will show something like "On branch ....". If it doesn't show the legacy-v2 branch, then run "git checkout legacy-v2".

If you are using WeBWorK 2.16 things work a bit differently.  In that case go to /opt/webwork/webwork2/htdocs and run "npm ci".  That is assuming you have npm installed.  If not, then you will need to run "sudo apt install npm" first.

Although, none of this may help you.  Something odd is going on as your screenshot shows that some of the math has rendered.  I believe the problem that you are showing is Library/WHFreeman/Rogawski_Calculus_Early_Transcendentals_Second_Edition/1_Precalculus_Review/1.3_The_Basic_Classes_of_Functions/1.3.5.pg. I tested that problem, and don't have those display issues.
In reply to Glenn Rice

Re: Macros for GT LT, etc are rendered as code

by Bob Mahar -
We are running 2.16 downloaded as an appliance. Ran nmp ci as indicated and it did update. However the issue persists.

wwadmin@webwork:/opt/webwork/webwork2/htdocs$ npm ci
npm WARN prepare removing existing node_modules/ before installation
> @fortawesome/fontawesome-free@5.15.2 postinstall /opt/webwork/webwork2/htdocs/node_modules/@fortawesome/fontawesome-free
> node attribution.js
Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
added 8 packages in 1.827s
How would I go about troubleshooting this further?   Any other common modes by which this breaks?

Thanks!

-- Bob



In reply to Bob Mahar

Re: Macros for GT LT, etc are rendered as code

by Glenn Rice -
This shouldn't be an issue or break anything. The "appliance" you downloaded apparently already had the javascript installed via "npm ci" or "npm install". I am not sure why npm warned about removing the existing node_modules, but it then proceeded to install the 8 javascript libraries that it should have installed.
In reply to Glenn Rice

Re: Macros for GT LT, etc are rendered as code

by Bob Mahar -

Incidentally on changing the "Using what display mode?" option to "Images" for a given problem problem appears to display correctly.   So what is this setting actually doing?   ( I assume bypassing MathJax and using latex to render? )   Is there a way to test MathJax directly?   I am looking in the apache. lighttp, and ww logs and cannot find any errors that correlate with the failed rendering.

Setting "Using What Display Mode" Option to "Images"

Formulas rendered OK

-- Bob

In reply to Bob Mahar

Re: Macros for GT LT, etc are rendered as code

by Alex Jordan -
For you,

"x$GTE-$int"

is being interpolated as

x<U>&gt;</U>-$int

in this setting. But for me (and it sounds like Glenn), it is interpolated as

x\ge -$int

I'm not sure what is going on. This is math content within HTML output. I see from
https://github.com/openwebwork/pg/blob/37637e2f880bccbbb8781b5d669421849ac81267/macros/PGbasicmacros.pl#L1547
that HTML mode interpolates $GTE using the U tag.

So what is making it so that for me and Glenn, it actually comes out as "\ge" instead? If someone knows where that is controlled, maybe it gives a clue to where something should be changed on Bob's server.

Side note: marking up a < character with underlining is not an accessible way to represent a less-than-or-equals symbol. Do we have enough character support to just drop in a literal ≤ when its $LTE in HTML output?

In reply to Alex Jordan

Re: Macros for GT LT, etc are rendered as code

by Glenn Rice -

Yeah, for me this is being rendered via MathJax with "\ge".

I am not sure why it is being rendered in that way for us though.  Since the display mode is HTML, it should be rendered for all of us as '<U>&gt;</U>'.  The problem should use "\ge" directly in this situation.

As to the underlined less than symbol, I do not know why it is not just "&leq;".  Presumably that would be accessible.

In reply to Glenn Rice

Re: Macros for GT LT, etc are rendered as code

by Glenn Rice -
So after doing a little testing, it seems that this is being rendered in HTML_tth mode which is defined as "\ge". I am not sure why, and I don't know why it is in that display mode for us, but not for Bob.
In reply to Glenn Rice

Re: Macros for GT LT, etc are rendered as code

by Arnold Pizer -
In reply to Arnold Pizer

Re: Macros for GT LT, etc are rendered as code

by Bob Mahar -
I confirmed the file is already set up that way.   I am going to try to switch it to the "wrong" way given HTTP_tth seemed to be a mode that worked.    Or maybe the underlying bug that makes this change necessary is fixed in the build of WW I have.  IDK.

# MODES() is now table driven
our %DISPLAY_MODE_FAILOVER = (
        TeX              => [],
        HTML             => [],
        PTX              => [ "HTML" ],
        HTML_tth         => [ "HTML", ],
        HTML_dpng        => [ "HTML_tth", "HTML", ],
        HTML_jsMath      => [ "HTML_dpng", "HTML_tth", "HTML", ],
#       HTML_MathJax     => [ "HTML_dpng", "HTML_tth", "HTML", ],
        HTML_MathJax     => [ "HTML_dpng", "HTML", "HTML_tth", ],
        HTML_asciimath   => [ "HTML_dpng", "HTML_tth", "HTML", ],
        HTML_LaTeXMathML => [ "HTML_dpng", "HTML_tth", "HTML", ],
        # legacy modes -- these are not supported, but some problems might try to
        # set the display mode to one of these values manually and some macros may
        # provide rendered versions for these modes but not the one we want.
        Latex2HTML       => [ "TeX", "HTML", ],
        HTML_img         => [ "HTML_dpng", "HTML_tth", "HTML", ],
);

-- Bob
In reply to Bob Mahar

Re: Macros for GT LT, etc are rendered as code

by Bob Mahar -
Yup! That was it! Undoing the "fix", which I guess was baked into the appliance already, makes it display properly in MathJax mode. So I am guessing that the version of WW baked into the appliance might not actually need that re-ordering of the fallback list. So now it renders as expected and displays properly:

<script type="math/tex">x \ge  -4</script>
Thanks everybody!

-- Bob
In reply to Bob Mahar

Re: Macros for GT LT, etc are rendered as code

by Arnold Pizer -

Just for reference, the problem is that the macros $GTE, $LTE, etc. were designed to be used in text mode, not in math mode. In math mode, all the LaTeX macros (e.g.  \geq, \leq) are available and should be used. So when I setup the OVA and AMI images, I edited the basic macros file so these work as intended and made a note of this --- see https://webwork.maa.org/wiki/WeBWorK_2.16_Ubuntu_Server_20.04_LTS_Virtual_Machine_Image#PGbasicmacros.pl

 and

 https://webwork.maa.org/wiki/WeBWorK_2.16_Ubuntu_Server_20.04_LTS_Amazon_Machine_Image#PGbasicmacros.pl

However this breaks problems where the author uses $GTE, etc. in math mode.  If you edit the problem using \geq in place of $GTE, etc. the problem will display correctly. But is is probably easier to do what you did and hope users don't run into $GTE, etc. being used in text mode.