Giter Site home page Giter Site logo

Comments (4)

MrPaiZi avatar MrPaiZi commented on September 18, 2024 1

@9micra 谢谢你介绍的插件,之后我会研究研究。但是感觉盘古之白没这么简单,它不仅是把反引号 ` 包裹的内容两边加个空格,还有很多特殊情况,比如行内代码前后紧接着中文的标点符号,或者后面紧接着英文的标点符号,这些情况下是不希望加空格的:

这个 `demo`,`fps` 只有 `30`。This `demo`, `fps` is only `30`.

一旦无脑加空格,会变成这样:

这个 `demo` , `fps` 只有 `30` 。This `demo` , `fps` is only `30` .

对比一下:

这个 demofps 只有 30。This demo, fps is only 30.
这个 demofps 只有 30 。This demo , fps is only 30 .

所以用正则表达式就想实现不太行,更何况这个表达式我刚刚测试了一下,好像还有 bug:它的原理是识别前后未加空格的代码块并给其前后加上空格吧?可如果一块行内代码前面加了空格而后面没加——如我上面举例的 这个 `demo`,——那么此时调用正则替换,会匹配到从后面那个反引号到下一个代码块开头的反引号之间包裹的部分。

from obsidian-pangu.

9micra avatar 9micra commented on September 18, 2024 1

@MrPaiZi 抱歉,才看到,我现在用Linter了,
它有内置了很多Ob的md语法规范,当然也有CJK(包括中文)和英文之间加空格 和 在行内代码与CJK间加空格,是比较智能的,不是无脑的正则。

from obsidian-pangu.

9micra avatar 9micra commented on September 18, 2024

这个简单,用正则Regex Pipeline替换

(?<![ ])(`.+?`)(?![ ])

 $1

$1前后有各有一个空格

就行了,不过这个主要的问题是不能忽略代码块里的反单引号``

```powershell
`some codes with`
```

所以就不能无脑对整个文档使用,可以选中需要替换的文本后使用。
Regex Pipeline写法

:: 反单引号前后加空格
"(?<![ ])(`.+?`)(?![ ])"->" $1 "

from obsidian-pangu.

MrPaiZi avatar MrPaiZi commented on September 18, 2024

@9micra 谢谢!这个插件太好用了。

from obsidian-pangu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.