Markdown export breaks bold, italic and strikethrough when the styled text starts with a space
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #3233 来自 @RaphaelFakhri —— 已合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
找到 blocksToMarkdownLossy 的实现,并检查它如何为包含空白的粗体、斜体和删除线文本添加包围符。使用提供的示例重现问题,然后运行相关的 Markdown 导出和解析测试。当首尾空格都保留在强调符号之外,并且导出的 Markdown 往返解析后仍保留预期样式时,即为完成。
由索引模型根据 Issue 内容生成。
描述
blocksToMarkdownLossy puts the emphasis delimiters directly around styled text, even when that text starts with a space. A Markdown opening delimiter followed by whitespace doesn't count as emphasis, so the output shows literal asterisks in any CommonMark/GFM renderer, and BlockNote's own Markdown parser reads it wrong as well.
This happens often in practice: selecting a word together with the space before it (for example, by dragging or with Shift+Ctrl+Left) and pressing Ctrl+B produces a text run like " world" with bold: true.
Trailing whitespace is already moved outside **/*. Leading whitespace is not, and strikethrough has no whitespace handling at all.
Steps to reproduce
editor.blocksToMarkdownLossy([
{
type: "paragraph",
content: [
{ type: "text", text: "Normal", styles: {} },
{ type: "text", text: " bold", styles: { bold: true } },
{ type: "text", text: " and", styles: {} },
{ type: "text", text: " italic ", styles: { italic: true } },
{ type: "text", text: "and", styles: {} },
{ type: "text", text: " strike ", styles: { strike: true } },
{ type: "text", text: "end", styles: {} },
],
},
]);
What did you expect to happen?
Normal **bold** and *italic* and ~~strike~~ end
Actual output:
Normal** bold** and* italic* and~~ strike ~~end
If you parse that output back with tryParseMarkdownToBlocks, the styles are lost or land on the wrong text, and literal */~~ characters stay in the document.
BlockNote version
main at 45d07d3.
- 主要语言
- TypeScript
- 星标
- 10.3k
- 派生
- 780
- 平均合并
- 2 天 22 小时
- 30 天内合并 PR
- 48
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TypeCellOS/BlockNote 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
TypeCellOS/BlockNote#2949 · 1 条评论 ·
维护者通常 1 天内回复
-
a11y
难度 2/5 1-3 小时 新手友好度 68/100
TypeCellOS/BlockNote#2855 ·
维护者通常 1 天内回复
-
a11y
难度 2/5 1-3 小时 新手友好度 62/100
TypeCellOS/BlockNote#2829 · 1 条评论 ·
维护者通常 1 天内回复
-
Comment thread actions: hover-only controls and unlabeled buttons in ThreadsSideba可能已有人在做 @matthewlipski 于 3 天前认领。 未关闭a11y
难度 2/5 1-3 小时 新手友好度 72/100
TypeCellOS/BlockNote#2824 · 已指派 1 人 ·
维护者通常 1 天内回复
-
A failed upload from a file drop or paste leaves a stuck "Loading..." block可能已有人在做 @nperez0111 于 2 天前认领。 未关闭needs-triage
难度 3/5 1-2 天 新手友好度 35/100
TypeCellOS/BlockNote#3246 ·
维护者通常 1 天内回复
查看 TypeCellOS/BlockNote 的全部 Issue
相似的 Issue
-
freshness freshness:observed-only
难度 2/5 1-3 小时 新手友好度 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
area: web
难度 2/5 1-3 小时 新手友好度 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
难度 2/5 1-3 小时 新手友好度 72/100
expressjs/expressjs.com#2549 · 1 个 reaction ·
维护者通常 1 天内回复
-
bug good first issue hacktoberfest
难度 2/5 1-3 小时 新手友好度 88/100
codercops/discord-bot#101 · 1 条评论 ·
维护者通常 1 天内回复