Markdown round trip turns URL links into plain text (no autolink parsing since 0.51)
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 65/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- javascript, markdown, typescript
- Domaine
- devtools, documentation
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 10.2k
- Forks
- 772
- Merge moyen
- 6 j 3 h
- PR mergées (30 j)
- 26
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TypeCellOS/BlockNote
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
TypeCellOS/BlockNote#2949 · 1 commentaire ·
-
a11y
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
TypeCellOS/BlockNote#2829 · 1 commentaire ·
-
a11y
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
TypeCellOS/BlockNote#2824 ·
-
a11y
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
TypeCellOS/BlockNote#2811 ·
Toutes les issues de TypeCellOS/BlockNote
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
TanStack/tanstack.com#1293 ·