remend: unclosed `$$` in a table cell is closed on a new line when an earlier line has math
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
Línea de trabajo
Empieza en packages/remend/src/katex-handler.ts, en addClosingKatex, y reproduce el ejemplo de celda de tabla del issue. Verifica la elección de cierre para un $$ sin cerrar después de matemáticas anteriores, incluidos los casos de matemáticas en bloque y en línea; está hecho cuando la fila final Force se cierra en la misma línea sin provocar una regresión en el cierre en una nueva línea para las matemáticas en bloque.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 5.7k
- Forks
- 307
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 24
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de vercel/streamdown
-
The word-fade engine ships with every app, whether or not it animatesPosiblemente ocupada @xyrolle la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 1/100
vercel/streamdown#681 ·
Los mantenedores suelen responder en 1 día
-
Mermaid's UI ships in the main bundle although the chart is lazy-loadedPosiblemente ocupada @xyrolle la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
vercel/streamdown#679 ·
Los mantenedores suelen responder en 1 día
-
CJK autolink boundary handling keeps `**` in the URL when a bold URL is followed by CJK punctuationPosiblemente ocupada @mikemikimike la tomó hace 2 días. Abiertobug
Dificultad 3/5 Medio día Aptitud para principiantes 50/100
vercel/streamdown#672 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Animation: CJK paragraphs only animate their first batch, and queued words pop in when isAnimating turns falsePosiblemente ocupada @sleitor la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
vercel/streamdown#669 ·
Los mantenedores suelen responder en 1 día
-
Mermaid shows an error for a partial chart while its fence is still streamingPosiblemente ocupada @slavco86 la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
vercel/streamdown#667 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de vercel/streamdown
Issues similares
-
bug engine
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
frostney/GocciaScript#1746 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
agilepathway/label-checker#739 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Wrong key location at startupAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
CopilotKit/OpenBot#800 ·
Los mantenedores suelen responder en 1 día
-
Endpoint links in the tag operations list are below the 24px target sizePosiblemente ocupada @AdzerKI la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
ehmpathy/rhachet-roles-bhuild#471 ·
Los mantenedores suelen responder en 1 día