Serializer keeps a link open across a whitespace-only marked node

Aperta
#1,263 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
tooling

Direzione di ricerca

Start in MarkdownSerializerState.renderInline and the expelEnclosingWhitespace step it relies on, since the issue traces the bug to renderInline setting marks = active for a whitespace-only marked node. Reproduce with the BaseSchemaSpecs, LinkSpecs and BoldSpecs setup from the issue and confirm the output drops the autolink. Done means the link is closed before the space is written, the serializer test prints the autolink followed by text, and a parsing regression test covers the round trip.

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

Descrizione

bug

MarkdownSerializerState.renderInline keeps the previous link active when the next node contains only marked whitespace.

Reproduce with BaseSchemaSpecs, LinkSpecs and BoldSpecs:

const href = 'https://ya.ru/';
const content = doc(p(a({href}, href), bold(' '), 'text'));

serializer.serialize(content);

Expected:

<https://ya.ru/> text

Actual:

<https://ya.ru/ >text

The result is not a valid autolink. After parsing, < and > become visible text.

When expelEnclosingWhitespace removes all text from the bold node, renderInline sets marks = active. This keeps the previous link open while writing the space, although the original space node has no link mark.

Close marks absent from the original node before writing its whitespace. Add regression tests for serialization and parsing.

Lingua principale
TypeScript
Stelle
428
Fork
48
Merge medio
5g 15h
PR unite (30g)
47

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 gravity-ui/markdown-editor

Tutte le issue di gravity-ui/markdown-editor

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.