Markdown round trip turns URL links into plain text (no autolink parsing since 0.51)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, markdown, typescript
- Ambito
- devtools, documentation
Direzione di ricerca
Look at htmlToMarkdown.ts for formatLink and markdownToHtml.ts for the parser. The issue is that the serializer writes bare URLs expecting autolinking, but the parser lacks an autolink tokenizer. Start by adding an autolink tokenizer to the parser configuration, then test with the provided reproduction script. Verify that both bare URLs and CommonMark autolinks (https://example.com) are parsed correctly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What's broken?
Since the custom Markdown parser landed in 0.51.0 (#2624), a link whose text equals its URL does not survive a Markdown round trip. It comes back as plain text.
The two halves disagree. formatLink in htmlToMarkdown.ts writes such a link as a bare URL, following the remark-stringify behavior from #2661. That relies on the parser autolinking it, as remark-gfm did. The new parser in markdownToHtml.ts has no autolink tokenizer, so it reads the URL back as text. It also does not recognize CommonMark autolinks (<https://example.com>), which it leaves as literal text including the angle brackets.
Still reproducible on 0.55.0. On 0.50.0 the link survives both cases.
What did you expect to happen?
tryParseMarkdownToBlocks(blocksToMarkdownLossy(blocks)) keeps the link. At minimum, the parser should accept what the serializer emits. Ideally it recognizes both CommonMark autolinks (<https://…>) and GFM autolink literals (bare https://…, www.…), which the pre-0.51 remark-gfm pipeline handled.
Steps to reproduce
import { JSDOM } from "jsdom";
const dom = new JSDOM("<!doctype html>");
globalThis.window = dom.window;
globalThis.document = dom.window.document;
globalThis.DOMParser = dom.window.DOMParser;
const { BlockNoteEditor } = await import("@blocknote/core");
const editor = BlockNoteEditor.create({
initialContent: [
{
type: "paragraph",
content: [{ type: "link", href: "https://example.com", content: "https://example.com" }],
},
],
});
const markdown = await editor.blocksToMarkdownLossy(editor.document);
console.log(JSON.stringify(markdown));
console.log(JSON.stringify((await editor.tryParseMarkdownToBlocks(markdown))[0].content));
console.log(JSON.stringify((await editor.tryParseMarkdownToBlocks("<https://example.com>"))[0].content));
0.55.0:
"https://example.com\n"
[{"type":"text","text":"https://example.com","styles":{}}]
[{"type":"text","text":"<https://example.com>","styles":{}}]
0.50.0:
"<https://example.com>\n"
[{"type":"link","href":"https://example.com","content":[{"type":"text","text":"https://example.com","styles":{}}]}]
[{"type":"link","href":"https://example.com","content":[{"type":"text","text":"https://example.com","styles":{}}]}]
Impact
We keep documents editable as Markdown and only accept an edit when the document round-trips. From 0.51 on, any document containing a URL link fails that check. Markdown written by other tools also loses its links, for example a description with Issue: https://github.com/org/repo/issues/1.
BlockNote version
0.51.0 through 0.55.0 (@blocknote/core)
Environment
Node 24, jsdom 26 (also reproduced in Chrome)
Related: #3035 covers the serializer's link format, not the parse side.
- Lingua principale
- TypeScript
- Stelle
- 10.2k
- Fork
- 772
- Merge medio
- 6g 3h
- PR unite (30g)
- 26
Guida per i contributori
Apri 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 TypeCellOS/BlockNote
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TypeCellOS/BlockNote#2949 · 1 commento ·
-
a11y
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
TypeCellOS/BlockNote#2829 · 1 commento ·
-
a11y
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
TypeCellOS/BlockNote#2824 ·
-
a11y
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
TypeCellOS/BlockNote#2811 ·
Tutte le issue di TypeCellOS/BlockNote
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
TanStack/tanstack.com#1293 ·