Skip to content

Conversation

@ascholerChemeketa
Copy link
Contributor

If an answer is not supposed to involve mathematics, rendering it with MathJax and displaying the result is at best confusing and at worst will actually display something that makes no sense.

This adds a switch to the <response> to disable mathjax rendering and a book level switch to change the default behavior. Otherwise, the default is to render with MathJax in order to maintain existing behavior.

Note that you should see the change in the HTML output, but RS will still render MathJax until this PR is in place:
RunestoneInteractive/rs#1082

To test without a RS server, make sure to use stringparam short-answer-responses always.

Tagging @bnmnetp

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 18, 2025

rendering it with MathJax and displaying the result is at best confusing and at worst will actually display something that makes no sense.

I guess so? Now, because we are allowing/interpreting free-form user input, we are in the business of protecting against unintentional bad input. I'll need to let that percolate a bit.

I do not think an author should know anything about what MathJax is. So, at a minimum, a switch/attribute should be named something like @allow-math or @support-math-syntax. Don't make a change just yet, I'm going to sit on this for a day or two.

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 18, 2025

David Farmer (@davidfarmer) is able to parse user-input text and distinguish math/LaTeX syntax from "regular" punctuation. Maybe he can help?

Something like: An $8\times 8$ checkerboard costs $3.50. does what you expect it to.

Maybe respones can be parsed on the RS side and marked-up accordingly? I forget if we are using $, $$, \(, \[ or what. I once converted \( in PreTeXt source by inserting a thin (invisible?) space. Now we use a MathJax configuration device to only process bits that we know are math, and ignore everything else.

@ascholerChemeketa
Copy link
Contributor Author

This can be used for experimentation:
https://runestone.academy/ns/books/published/PTXSB/short-answer-exercises.html

While An $8\times 8$ checkerboard costs $3.50. does what you expect, A checkerboard costs $3.50. That is $2.00 too much. does not behave as you would expect/desire.

We could use a regex to guess at whether there is something that could be rendered as math. But that does not mean it should be rendered as math.

At the extreme, given a piece of text, it is fundamentally unknowable if the intent was to embed math content. IMO, anything that can't be guaranteed to correctly guess intent should have a way to specify that intent.

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 19, 2025

I think that parsing a reader's response to a short-answer question should be a Runestone responsibility. Or conversely, it should not be an author's responsibility to predict (or restrict/enable) what sort of syntax gets used. So I don't think the proposed extension to PreTeXt belongs.

With asymmetric delimiters, say \( and \), I would think they could be paired and marked-off for MathJax to interpret. Any leftovers could be dealt with as straight text.

We can discuss further on pretext-dev if desirable, either as PreTeXt (the language) or aspects of parsing math within free-form text.

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 19, 2025

the intent was to embed math content

That intent lies with the reader, no? Maybe the text-box should have a checkbox ("Use math syntax").

You are correct that $ is a very bad choice for delimiters. That is part of why LaTeX introduced (, ).

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 28, 2025

This was discussed in Drop-In. Some work will be done on the Runestone side to improve things such as previewing an answer. Closing for now.

@rbeezer rbeezer closed this Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants