RunestoneInteractive / thinkcspy

How to Think Like a Computer Scientist, Interactive Edition
https://runestone.academy/ns/books/published/thinkcspy/index.html
Other
108 stars 191 forks source link

A math library is converting code to math symbols #265

Closed sheggen closed 3 weeks ago

sheggen commented 3 weeks ago

What Course are you in

The bug first appears here: https://runestone.academy/ns/books/published/2024_fall_csc226/SimplePythonData/Input.html

What Page were you on

https://runestone.academy/ns/books/published/2024_fall_csc226/SimplePythonData/Input.html

Screenshot 2024-08-26 at 2 18 15 PM

What is your username

heggens (instructor). First reported by a student though.

Describe the bug The code int is being converted to an integral symbol. Right clicking on the symbol reveals there is a math library is in use, as does inspecting the HTML. Less important, there is grammatical issues with the question as well.

Traceback N/A

Javascript Errors N/A

bnmnetp commented 3 weeks ago

The question was written incorrectly using a single backquote around the word int where it should be double backquotes. So since single backquotes are in the html, MathJax (more specifically the asciimath parser) interprets that as something it should display as math.

The fix is to update the RST source for the book and correct the markup.

sheggen commented 3 weeks ago

It now parses correctly as int. Is the RS convention to highlight code (for example, int vs. int in markdown)? If so, it is not rendering it as inline code, but still wrapping it in MathJax:

Screenshot 2024-08-27 at 8 26 36 AM

Personally, I would prefer to see code parsed differently than regular text, like it is done elsewhere in the book (e.g., ex_2_5 where print is presented as code):

Screenshot 2024-08-27 at 8 31 59 AM

If not, then the issue is resolved.

bnmnetp commented 3 weeks ago

The Runestone RST is built on top of Sphinx, which in turn uses restructuredText (docutils). So things like how code is presented are whatever is standard in Sphinx. But that is kind of beside the point, as I'm not working on the RST parts of Runestone anymore, new books are written in PreTeXt, and many old books have been converted. See the httlacs book on Runestone Academy for the PreTeXt version.