Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

remend: unclosed `$$` in a table cell is closed on a new line when an earlier line has math

Aperta Adatta ai principianti
#652 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@orinnz ci sta già lavorando.

Dal 3/10/2026.

  • #653 di @orinnz — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
content, frontend

Direzione di ricerca

Inizia in packages/remend/src/katex-handler.ts, in addClosingKatex, e riproduci l'esempio della cella di tabella dell'issue. Verifica la scelta di chiusura per un $$ non chiuso dopo una matematica precedente, inclusi i casi di matematica a blocchi e inline; è completato quando la riga Force finale viene chiusa sulla stessa riga senza causare regressioni nella chiusura su una nuova riga per la matematica a blocchi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug Description

addClosingKatex in packages/remend/src/katex-handler.ts picks between $$ and \n$$ by looking for a newline after the first $$ in the whole text (text.indexOf("$$")). It should look after the $$ that is still open. So once any earlier line has math, every later unclosed $$ gets closed with \n$$.

In a table cell that newline ends the row, and the cell shows $$F = ma as raw text until the closing $$ arrives. A table with a formula in every row hits this on each row after the first.

Steps to Reproduce
import remend from "remend";

remend(
  "| Quantity | Formula |\n| --- | --- |\n| Energy | $$E = mc^2$$ |\n| Force | $$F = ma",
);
Expected Behavior

The last row is closed on the same line:

| Force | $$F = ma$$
Actual Behavior

The last row is closed on a new line:

| Force | $$F = ma\n$$

Rendered with <Streamdown plugins={{ math }} isAnimating>, the Force cell shows the raw text $$F = ma.

Without the Energy row, the same input closes correctly on the same line. Any earlier $$ causes it, for example "text $$a$$\n\n| A | B |\n| - | - |\n| x | $$E" also gets \n$$.

Code Sample

A possible fix is to measure from the last $$, which is the open one when the pair count is odd:

const openIndex = text.lastIndexOf("$$");
const hasNewlineAfterStart =
  openIndex !== -1 && text.indexOf("\n", openIndex) !== -1;

I ran the current and patched versions of addClosingKatex on these inputs:

Input ends with indexOf (current) lastIndexOf
| Force | $$F = ma (row above has math) \n$$ $$
| x | $$E (earlier paragraph has math) \n$$ $$
$$\nx^2 + y (block math) \n$$ \n$$
Inline $$a$$ then $$b $$ $$
Streamdown Version

streamdown 2.7.0, remend 1.4.0. The handler is the same on main.

React Version

19.2.8

Node.js Version

24.19.0

Browser(s)

Any. It reproduces in remend alone.

Operating System

Windows 11

Additional Context

We work around it with a custom remend handler at priority 65 that closes $$ on the same line when the last line is a table row.

Related: #539 covers other partial states that flash during streaming.

Lingua principale
TypeScript
Stelle
5.7k
Fork
313
Merge medio
3g 18h
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/streamdown

Tutte le issue di vercel/streamdown

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.