Skip to content

[Refactor:System] Render latex in markdown#11931

Merged
bmcutler merged 10 commits intomainfrom
markdown-katex
Aug 8, 2025
Merged

[Refactor:System] Render latex in markdown#11931
bmcutler merged 10 commits intomainfrom
markdown-katex

Conversation

@lavalleeale
Copy link
Copy Markdown
Contributor

@lavalleeale lavalleeale commented Jul 30, 2025

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?

  1. View a markdownarea (creating a new post on the discussion forum is one of the easiest)
  2. Write some markdown with latex embedded in it.
  3. View the preview/rendered version

Automated Testing & Documentation

Other information

This should be merged after #11929 since it is based off it.
Closes #9775

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 21.67%. Comparing base (740bc69) to head (ffc9783).

Additional details and impacted files

Impacted file tree graph

@@             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              
Flag Coverage Δ
autograder 21.31% <ø> (ø)
js 2.07% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.68% <0.00%> (-0.01%) ⬇️
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 90.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lavalleeale lavalleeale marked this pull request as draft July 30, 2025 22:50
@automateprojectmangement automateprojectmangement bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Jul 30, 2025
@lavalleeale lavalleeale marked this pull request as ready for review August 8, 2025 14:02
@automateprojectmangement automateprojectmangement bot moved this from Work in Progress to Seeking Reviewer in Submitty Development Aug 8, 2025
Copy link
Copy Markdown
Contributor

@jeffrey-cordero jeffrey-cordero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-project-automation github-project-automation bot moved this from Seeking Reviewer to Awaiting Maintainer Review in Submitty Development Aug 8, 2025
Copy link
Copy Markdown
Member

@williamjallen williamjallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bmcutler
Copy link
Copy Markdown
Member

bmcutler commented Aug 8, 2025

@lavalleeale
a simple example of how to write latex in markdown should be added to our documentation page:
https://submitty.org/student/communication/markdown

@bmcutler bmcutler merged commit 101ceab into main Aug 8, 2025
29 checks passed
@bmcutler bmcutler deleted the markdown-katex branch August 8, 2025 17:33
bmcutler added a commit to Submitty/submitty.github.io that referenced this pull request Aug 9, 2025
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>
bmcutler pushed a commit that referenced this pull request Nov 14, 2025
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Support Latex in Discussion Forum

4 participants