remend: unclosed `$$` in a table cell is closed on a new line when an earlier line has math
I maintainer di solito rispondono entro 1 giorno
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
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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel/streamdown
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
vercel/streamdown#686 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The word-fade engine ships with every app, whether or not it animatesForse già presa @xyrolle l’ha presa 5 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 1/100
vercel/streamdown#681 ·
I maintainer di solito rispondono entro 1 giorno
-
Mermaid's UI ships in the main bundle although the chart is lazy-loadedForse già presa @xyrolle l’ha presa 5 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
vercel/streamdown#679 ·
I maintainer di solito rispondono entro 1 giorno
-
CJK autolink boundary handling keeps `**` in the URL when a bold URL is followed by CJK punctuationForse già presa @mikemikimike l’ha presa 6 giorni fa. Apertabug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 50/100
vercel/streamdown#672 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Animation: CJK paragraphs only animate their first batch, and queued words pop in when isAnimating turns falseForse già presa @sleitor l’ha presa 5 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
vercel/streamdown#669 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel/streamdown
Issue simili
-
bug P3 UI/UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
StellarState/SS-backend#712 ·
I maintainer di solito rispondono entro 1 giorno
-
area: backend bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
snapotter-hq/SnapOtter#3473 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
gitroomhq/postiz-app#2304 ·
I maintainer di solito rispondono entro 1 giorno
-
harlan-agent-ready-to-implement routine:ci-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
harlan-zw/unlighthouse#454 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno