Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Markdown export breaks bold, italic and strikethrough when the styled text starts with a space

已关闭 适合新手
#3,232 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TypeCellOS/BlockNote 的其他 Issue

查看 TypeCellOS/BlockNote 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。