nextcloud / nextcloud/text

Mathematics node bloats the largest chunk including katex twice

Open
#8,333 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
659
Forks
133
Avg merge
1d 20h
Merged PRs (30d)
110

Description

Describe the bug
The current mathematics implementation imports katex three times:

  • via @tiptap/extension-mathematics

  • via markdown-it-katex

  • directly.

  • We add a custom node view so the katex part in the tiptap extension never gets used - it's imported never the less.

  • Markdown-it-katex will render the latex and then we extract its source from the annotation tag.
    We could avoid the entire rendering in the first place and thus also the katex dependency.

  • Make sure to lazy load katex our in the node view only if latex is actually used on the page.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the mathematics implementation, custom node view, and the three KaTeX imports described in the issue. Inspect the generated largest chunk and the node-view loading path. Done means the duplicate KaTeX imports are removed and KaTeX is loaded only when mathematics is used, without changing rendering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.