Skip to content

Improve find-replace of text containing escape characters #14173

Closed
@TCOTC

Description

@TCOTC
Contributor

包含转义符的文本无法替换

https://ld246.com/article/1740150873393

<span data-type="virtual-block-ref">

复制,粘贴纯文本:

video.webm

Activity

88250

88250 commented on Feb 22, 2025

@88250
Member

这个问题无法解决了,因为粘贴纯文本后 = 会被转义为 \=,而搜索是在 content 字段上的,这个字段没有转义符,所以可以命中原文本 <span data-type="virtual-block-ref">,但是替换的时候是在语法树上执行的,语法树节点:

  • <span data-type 文本节点
  • \= 转义节点
  • "virtual-block-ref"> 文本节点

遍历语法树节点的时候无法完整匹配到原文本,所以无法替换。

changed the title [-]文本无法替换[/-] [+]包含转义符的文本无法替换[/+] on Feb 22, 2025
TCOTC

TCOTC commented on Feb 22, 2025

@TCOTC
ContributorAuthor

粘贴纯文本后 = 会被转义为 \=

这个是为什么?= 应该没有必要转义吧?

88250

88250 commented on Feb 23, 2025

@88250
Member

用于标记元素

TCOTC

TCOTC commented on Feb 23, 2025

@TCOTC
ContributorAuthor

@88250 至少在关闭标记语法的情况下我觉得不应该转义

Image

88250

88250 commented on Feb 23, 2025

@88250
Member

没有办法做到的

TCOTC

TCOTC commented on Feb 23, 2025

@TCOTC
ContributorAuthor

@88250 我试了一下单独替换 =,会残留一个标签,这里应该有点问题:

Image

88250

88250 commented on Feb 23, 2025

@88250
Member

这个稍后改进

self-assigned this
on Feb 23, 2025
added this to the 3.1.23 milestone on Feb 23, 2025
changed the title [-]包含转义符的文本无法替换[/-] [+]Improve find-replace of text containing escape characters[/+] on Feb 23, 2025
TCOTC

TCOTC commented on Feb 23, 2025

@TCOTC
ContributorAuthor

@88250 没有转义好像也无法替换:

video.webm

5 remaining items

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@TCOTC

      Issue actions

        Improve find-replace of text containing escape characters · Issue #14173 · siyuan-note/siyuan