Comments (4)
@9micra 谢谢你介绍的插件,之后我会研究研究。但是感觉盘古之白没这么简单,它不仅是把反引号 `
包裹的内容两边加个空格,还有很多特殊情况,比如行内代码前后紧接着中文的标点符号,或者后面紧接着英文的标点符号,这些情况下是不希望加空格的:
这个 `demo`,`fps` 只有 `30`。This `demo`, `fps` is only `30`.
一旦无脑加空格,会变成这样:
这个 `demo` , `fps` 只有 `30` 。This `demo` , `fps` is only `30` .
对比一下:
这个 demo
,fps
只有 30
。This demo
, fps
is only 30
.
这个 demo
, fps
只有 30
。This demo
, fps
is only 30
.
所以用正则表达式就想实现不太行,更何况这个表达式我刚刚测试了一下,好像还有 bug:它的原理是识别前后未加空格的代码块并给其前后加上空格吧?可如果一块行内代码前面加了空格而后面没加——如我上面举例的 这个 `demo`,
——那么此时调用正则替换,会匹配到从后面那个反引号到下一个代码块开头的反引号之间包裹的部分。
from obsidian-pangu.
@MrPaiZi 抱歉,才看到,我现在用Linter了,
它有内置了很多Ob的md语法规范,当然也有CJK(包括中文)和英文之间加空格 和 在行内代码与CJK间加空格,是比较智能的,不是无脑的正则。
from obsidian-pangu.
这个简单,用正则Regex Pipeline替换
(?<![ ])(`.+?`)(?![ ])
为
$1
↑$1
前后有各有一个空格
就行了,不过这个主要的问题是不能忽略代码块里的反单引号``
```powershell
`some codes with`
```
所以就不能无脑对整个文档使用,可以选中需要替换的文本后使用。
Regex Pipeline写法
:: 反单引号前后加空格
"(?<![ ])(`.+?`)(?![ ])"->" $1 "
from obsidian-pangu.
@9micra 谢谢!这个插件太好用了。
from obsidian-pangu.
Related Issues (20)
- [bug]很多非预期的情况加了空格 HOT 4
- 代码片段被增加了空格 HOT 1
- 感谢的伟大及分享 HOT 1
- 可否支持在 yaml 块和正文块之间加空行 HOT 2
- 转用Linter,功能丰富且稳定。感谢过去一段时间pangu的陪伴 HOT 1
- 在一行内,只要有超链接,超链接之后的中英文混排都无法自动添加空格 HOT 1
- FR 能否增加英文的命令控制 HOT 2
- 引用文件名不包含空格的笔记文件时,引用链接被错误的加上了空格 HOT 2
- 格式化后列表缩进丢失 HOT 1
- [bug]以及建议
- feat: 打字時自動添加空格
- "+"被替换成了"-"
- 公式中的“_”被替换成“*”
- 盘古的设置不能保存 HOT 1
- 首行 tab 被更改为空格的问题
- [Feature] 格式化已选择部分
- 是否可以默认增加一个选项。
- 希望行内公式与其他文本之间也增加空格
- [Feature] 希望可以只添加空格,不更改空行
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-pangu.