[Refactor:System] Render latex in markdown#11931
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11931 +/- ##
============================================
- Coverage 21.67% 21.67% -0.01%
Complexity 9491 9491
============================================
Files 267 267
Lines 36272 36273 +1
Branches 474 474
============================================
Hits 7863 7863
- Misses 27939 27940 +1
Partials 470 470
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
jeffrey-cordero
left a comment
There was a problem hiding this comment.
Markdown rendering looks good, and it's a solid feature to have, especially within proof-heavy CS courses. Adding support for $$ to span an entire line for an equation would be a nice follow-up feature to implement.
williamjallen
left a comment
There was a problem hiding this comment.
We discussed KaTeX vs MathJax and there were reasonable justifications for using KaTeX. Thanks for taking care of this long-standing feature request! Closes #9775.
|
@lavalleeale |
There previously were not any docs explaining adding equations to markdown after the feature was added in Submitty/Submitty#11931. This PR adds docs explaining how to embed an equation in any markdownarea on Submitty. --------- Co-authored-by: Barb Cutler <bmcutler@users.noreply.github.com>
### Why is this Change Important & Necessary? Currently, Submitty's LaTeX rendering only supports in-line math mode (e.g., `$E=mc^2$`). This makes it difficult to display complex or multi-line equations in a clear and readable format. This change introduces support for "display math mode," which renders equations on their own line and centered, a standard feature in mathematical typesetting. This enhancement significantly improves the readability of course materials and student submissions that contain mathematical formulas. Closes #11989 Related to #11931 ### What is the New Behavior? **Before:** Only in-line math using `$...$` or `\(...\)` was rendered. Any expressions using `$$...$$` or `\[...\]` were displayed as plain text. **After:** Users can now use `$$...$$` and `\[...\]` to render mathematical expressions in display mode. The expressions will appear centered on a new line. Existing in-line math rendering is unaffected. **Example:** **Before:** `$$a^2 + b^2 = c^2$$` would just show as plain text. **After:** `$$a^2 + b^2 = c^2$$` will render as: $$ a^2 + b^2 = c^2 $$ ### What steps should a reviewer take to reproduce or test the bug or new feature? 1. Navigate to an area in Submitty that renders Markdown, such as the instructions for a gradeable or a post in the discussion forum. 2. Create or edit a post and enter a mathematical expression using display mode delimiters. For example: `$$f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x-a)^n$$` 3. Also test the other display mode delimiter: `\[ \int_a^b f(x) \, dx = F(b) - F(a) \]` 4. Add an in-line expression to ensure existing functionality is not broken: `This is an in-line equation: $E=mc^2$.` 5. Save and view the rendered output. 6. **Expected Result:** The equations wrapped in `$$` and `\[` should be rendered on their own lines and centered. The equation wrapped in `$` should appear in-line with the text. ### Automated Testing & Documentation * **Automated Testing:** The existing front-end tests that check for KaTeX rendering should be updated to include test cases for display math mode. A new GitHub issue should be created if these tests are not included in this PR. * **Documentation:** The documentation on [submitty.org](http://submitty.org) regarding Markdown usage and supported LaTeX syntax should be updated to include information about the newly supported display math delimiters (`$$...$$` and `\[...\]`). A new GitHub issue should be created to track this documentation update. ### Other information * **Breaking Change:** No, this is not a breaking change. It is additive and preserves all existing functionality for in-line math rendering. * **Migrations:** This PR does not include database migrations as it is a front-end configuration change. * **Security Concerns:** There are no known security concerns with this change. It involves modifying the configuration of the KaTeX library, which is designed to safely render mathematical expressions without executing arbitrary scripts. The change does not introduce new libraries or dependencies. render mathematical expressions without executing arbitrary scripts. The change does not introduce new libraries or dependencies. --------- Co-authored-by: Samarth Naik <samarthnaikk@gmail.com> Co-authored-by: Sátvik Karanam <89281036+skara9@users.noreply.github.com>
Why is this Change Important & Necessary?
There are many places in submitty where the user is able to submit markdown where it would be very useful to be able to write equations in latex. The three main places that make this change important are the forum, notebook gradeables, and grade inquiries.
What is the New Behavior?
Anywhere the user has to write markdown they are able to embed latex via


$equation$or\(equation\).What steps should a reviewer take to reproduce or test the bug or new feature?
Automated Testing & Documentation
Other information
This should be merged after #11929 since it is based off it.
Closes #9775