-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LaTeX ; double slash or single slash #71
Comments
This seems odd, something with python? >>> "\sqrt{\\rho_\mathrm{Cu} / \\rho_\mathrm{Al}}"
'\\sqrt{\\rho_\\mathrm{Cu} / \\rho_\\mathrm{Al}}'
>>> r"\sqrt{\\rho_\mathrm{Cu} / \\rho_\mathrm{Al}}"
'\\sqrt{\\\\rho_\\mathrm{Cu} / \\\\rho_\\mathrm{Al}}' Is this due to >>> "\nu"
'\nu'
>>> "\\nu"
'\\nu'
>>> "\sqrt{\\nu}"
'\\sqrt{\\nu}'
>>> "\sqrt{\\nu}" I think thats whats happening here, its not a prarielearn thing, its that python won't autoescape escape sequences without raw strings, but will escape invalid escape backslashes |
Ah yes, you're right. So \nrtfh are special sequences in python. So what would you do:
I think I'm leaning towards option 2. |
I would do 2, it makes it the most readable to people not familiar with the issue here, but that will require a 1 time fix to remove our manual escaping of them, otherwise they will not render in the same vein, since the backslash will be escaped and defeat the purpose of the fix, so there will need to be a 1 time fix either way |
Yes there has to be a one time fix no matter what. I think I'll do it next week after the Apsc 181 questions are merged in so I can do it all at once. In the meantime I'll add that guidance to the training docs so we pick a way forward. Thanks for your help. |
Just as an FYI - the guidance (and solution), needs to be changed to use raw strings. In 3.12, it was changed in cpython such that invalid escapes generate We can't rely on always using 3.10, or any python version below this change, so it would be better to use raw strings (which can still have formatting, (See also: python/cpython#98401) |
I agree raw strings are what we need to do. This change would happen script-side only right? IOW, no need to change the MD files? If so, and you have time, feel free to take care of this too as part of the 1.0 update. |
I don't think this can be done script side, since we have no way to know if a valid escape should be left alone or not There's too much ambiguity about this |
This was testing using
pbs v0.8.1
.Standard LaTeX to produce this code
is:
but in PrairieLearn
question.html
files, the\rho
needs to be\\rho
when passed in fromserver.py
via mustache templatingAlternatively, the string can be made a raw string (which also works):
Aside:
I thought another alternative, in
question.html
, would be to surround the passed variable with triple curly braces:but this does not work.
Due to recent changes in how
pbs
handles unicode (namely #51), I think I have to do a find/replace to convert all\\
to\
in theinstructor_physics_bank
, for example in this question from OPBP.Unfortunately, because of the issue outlined above, it's not a simple matter of doing a find and replace to convert all
\\
to\
.So need to think about a way to do this without reviewing every question one by one.
The text was updated successfully, but these errors were encountered: