Skip to content

Markdown hyperlink parsing exception when using API /api/block/* to upsert block #7846

Closed
@Zuoqiu-Yingyi

Description

@Zuoqiu-Yingyi
Contributor

使用 API /api/block/* 更新/插入的 markdown 文本解析异常

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

API /api/block/updateBlock 的请求体如下所示时
When the request body of API /api/block/updateBlock is shown below

{
  "dataType": "markdown",
  "data": "**[456](123 \"789\")**",
  "id": "20211230161520-querkps"
}

对应的块渲染正常, 但是数据库 markdown 字段, 导出内容, API /api/block/getBlockKramdown 返回内容如下所示
The corresponding block renders normally, but database field markdown, export content, API /api/block/getBlockKramdown return content as shown below

[456](123 "789")****

Expected result

数据库 markdown 字段, 导出内容, API /api/block/getBlockKramdown 返回内容如下所示
Database field markdown, export content, API /api/block/getBlockKramdown return content as shown below

**[456](123 "789")**

Screenshot or screen recording presentation

粗体 **[foo](bar)**, 斜体 *[foo](bar)*, 删除线 ~~[foo](bar)~~, 高亮 ==[foo](bar)==, 上标 ^[foo](bar)^, 下标 ~[foo](bar)~ 存在同样的问题
Bold **[foo](bar)**, Italic *[foo](bar)*, Strikethrough ~~[foo](bar)~~, Mark ==[foo](bar)==, Superscript ^[foo](bar)^, Subscript ~[foo](bar)~ have the same problem.

Version environment

- Version: 2.8.3-dev1
- Operating System: 
- Browser (if used):

Log file

无有效信息输出
No valid information output

More information

No response

Activity

changed the title [-]Markdown text parsing exception when using API `/api/block/*` to update/inserte block | 使用 API `/api/block/*` 更新/插入的 markdown 文本解析异常[/-] [+]Markdown text parsing exception when using API `/api/block/*` to update/inserte block [/+] on Apr 1, 2023
changed the title [-]Markdown text parsing exception when using API `/api/block/*` to update/inserte block [/-] [+]Markdown text parsing exception when using API `/api/block/*` to upsert block [/+] on Apr 1, 2023
changed the title [-]Markdown text parsing exception when using API `/api/block/*` to upsert block [/-] [+]Markdown hyperlink parsing exception when using API `/api/block/*` to upsert block [/+] on Apr 1, 2023
self-assigned this
on Apr 1, 2023
added this to the 2.8.3 milestone on Apr 1, 2023
changed the title [-]Markdown hyperlink parsing exception when using API `/api/block/*` to upsert block [/-] [+]Markdown hyperlink parsing exception when using API `/api/block/*` to upsert block[/+] on Apr 1, 2023
Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on May 6, 2023

@Zuoqiu-Yingyi
ContributorAuthor

@88250 v2.8.6 版本中还存在一些问题, 请求体如下所示时

{
  "dataType": "markdown",
  "data": "[`456`](123 \"789\")",
  "id": "20211230161520-querkps"
}

导出内容如下所示

[456](123 "789")``​

由此可以看出, 样式嵌套的超链接元素的导出方案应该将标志符设置在超链接锚文本的内部, 锚文本内的标志符使用 \ 转义, 如下所示

粗体 [**\*foo\*foo\***](bar), 斜体 [*\*foo\*foo\**](bar), 删除线 [~~\~foo\~foo\~~~](bar), 高亮 [==\=foo\=foo\===](bar), 上标 [^\^foo\^foo\^^](bar), 下标 [~\~foo\~foo\~~](bar), 行内代码 [`foo`](bar)

上述内容渲染结果: 粗体 *foo*foo*, 斜体 *foo*foo*, 删除线 ~foo~foo~, 行内代码 foo

88250

88250 commented on Dec 28, 2023

@88250
Member

#9998 中会修改超链接和其他标记符的嵌套处理逻辑,将标记符移到 a 外面,例如: [**\*foo\*foo\***](bar) 会变为 **[\*foo\*foo\*](bar)**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Zuoqiu-Yingyi

      Issue actions

        Markdown hyperlink parsing exception when using API `/api/block/*` to upsert block · Issue #7846 · siyuan-note/siyuan