Markdown round trip turns URL links into plain text (no autolink parsing since 0.51)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 65/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, markdown, typescript
- Bereich
- devtools, documentation
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 10.2k
- Forks
- 772
- Ø Merge
- 6 T. 3 Std.
- Gemergte PRs (30 T.)
- 26
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TypeCellOS/BlockNote
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
TypeCellOS/BlockNote#2949 · 1 Kommentar ·
-
a11y
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
TypeCellOS/BlockNote#2829 · 1 Kommentar ·
-
a11y
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
TypeCellOS/BlockNote#2824 ·
-
a11y
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
TypeCellOS/BlockNote#2811 ·
Alle Issues in TypeCellOS/BlockNote
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
TanStack/tanstack.com#1293 ·