Skip to content

Commit a62cc4b

Browse files
committed
fix that link were recongnized as YAML
1 parent 78e8235 commit a62cc4b

File tree

6 files changed

+29
-123
lines changed

6 files changed

+29
-123
lines changed

CHANGELOG.md

-111
Original file line numberDiff line numberDiff line change
@@ -1,112 +1 @@
1-
# Changelog
21

3-
## v0.3.5 2024-04-30
4-
5-
* [Add `direction` to plugin method `Setting.addItem`](https://github.com/siyuan-note/siyuan/issues/11183)
6-
7-
8-
## 0.3.4 2024-02-20
9-
10-
* [Add plugin event bus `click-flashcard-action`](https://github.com/siyuan-note/siyuan/issues/10318)
11-
12-
## 0.3.3 2024-01-24
13-
14-
* Update dock icon class
15-
16-
## 0.3.2 2024-01-09
17-
18-
* [Add plugin `protyleOptions`](https://github.com/siyuan-note/siyuan/issues/10090)
19-
* [Add plugin api `uninstall`](https://github.com/siyuan-note/siyuan/issues/10063)
20-
* [Add plugin method `updateCards`](https://github.com/siyuan-note/siyuan/issues/10065)
21-
* [Add plugin function `lockScreen`](https://github.com/siyuan-note/siyuan/issues/10063)
22-
* [Add plugin event bus `lock-screen`](https://github.com/siyuan-note/siyuan/pull/9967)
23-
* [Add plugin event bus `open-menu-inbox`](https://github.com/siyuan-note/siyuan/pull/9967)
24-
25-
26-
## 0.3.1 2023-12-06
27-
28-
* [Support `Dock Plugin` and `Command Palette` on mobile](https://github.com/siyuan-note/siyuan/issues/9926)
29-
30-
## 0.3.0 2023-12-05
31-
32-
* Upgrade Siyuan to 0.9.0
33-
* Support more platforms
34-
35-
## 0.2.9 2023-11-28
36-
37-
* [Add plugin method `openMobileFileById`](https://github.com/siyuan-note/siyuan/issues/9738)
38-
39-
40-
## 0.2.8 2023-11-15
41-
42-
* [`resize` cannot be triggered after dragging to unpin the dock](https://github.com/siyuan-note/siyuan/issues/9640)
43-
44-
## 0.2.7 2023-10-31
45-
46-
* [Export `Constants` to plugin](https://github.com/siyuan-note/siyuan/issues/9555)
47-
* [Add plugin `app.appId`](https://github.com/siyuan-note/siyuan/issues/9538)
48-
* [Add plugin event bus `switch-protyle`](https://github.com/siyuan-note/siyuan/issues/9454)
49-
50-
## 0.2.6 2023-10-24
51-
52-
* [Deprecated `loaded-protyle` use `loaded-protyle-static` instead](https://github.com/siyuan-note/siyuan/issues/9468)
53-
54-
## 0.2.5 2023-10-10
55-
56-
* [Add plugin event bus `open-menu-doctree`](https://github.com/siyuan-note/siyuan/issues/9351)
57-
58-
## 0.2.4 2023-09-19
59-
60-
* Supports use in windows
61-
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
62-
63-
## 0.2.3 2023-09-05
64-
65-
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
66-
* [Plugin API add openWindow and command.globalCallback](https://github.com/siyuan-note/siyuan/issues/9032)
67-
68-
## 0.2.2 2023-08-29
69-
70-
* [Add plugin event bus `destroy-protyle`](https://github.com/siyuan-note/siyuan/issues/9033)
71-
* [Add plugin event bus `loaded-protyle-dynamic`](https://github.com/siyuan-note/siyuan/issues/9021)
72-
73-
## 0.2.1 2023-08-21
74-
75-
* [Plugin API add getOpenedTab method](https://github.com/siyuan-note/siyuan/issues/9002)
76-
* [Plugin API custom.fn => custom.id in openTab](https://github.com/siyuan-note/siyuan/issues/8944)
77-
78-
## 0.2.0 2023-08-15
79-
80-
* [Add plugin event bus `open-siyuan-url-plugin` and `open-siyuan-url-block`](https://github.com/siyuan-note/siyuan/pull/8927)
81-
82-
83-
## 0.1.12 2023-08-01
84-
85-
* Upgrade siyuan to 0.7.9
86-
87-
## 0.1.11
88-
89-
* [Add `input-search` event bus to plugins](https://github.com/siyuan-note/siyuan/issues/8725)
90-
91-
92-
## 0.1.10
93-
94-
* [Add `bind this` example for eventBus in plugins](https://github.com/siyuan-note/siyuan/issues/8668)
95-
* [Add `open-menu-breadcrumbmore` event bus to plugins](https://github.com/siyuan-note/siyuan/issues/8666)
96-
97-
## 0.1.9
98-
99-
* [Add `open-menu-xxx` event bus for plugins ](https://github.com/siyuan-note/siyuan/issues/8617)
100-
101-
## 0.1.8
102-
103-
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)
104-
* [Add plugin API protyle](https://github.com/siyuan-note/siyuan/issues/8445)
105-
106-
## 0.1.7
107-
108-
* [Support build js and json](https://github.com/siyuan-note/plugin-sample/pull/8)
109-
110-
## 0.1.6
111-
112-
* add `fetchPost` example

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
1. Copy your from code somewhere
99
2. Paste into SiYuan, and it will automatically detect language and set highlight regarding to the specific language.
1010

11+
# FAQ
12+
Q: The content that is not code after pasting is recognized as code?
13+
A: You can try Siyuan's paste as plain text shortcut (default is Ctrl+Shift+V), or right click - paste as plain text, or turn off automatic pasting and only use the slash menu.
14+
1115
# TODO
1216
- Improve the elegance of the slash menu popup.
1317
- Automatically adjust the language in the context menu of the code block.
@@ -18,4 +22,4 @@
1822

1923
# Thanks ♥️
2024
- [@frostime](https://github.com/frostime): Provided the code for the slash menu and the methods to bypass SiYuan's pre-process logic for pasting content.
21-
- [@leolee](https://github.com/leolee9086): Gave me methods regarding the code block highlights issue.
25+
- [@leolee](https://github.com/leolee9086): Gave me methods regarding the code block highlights issue.

README_zh_CN.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## 本插件是完全开源免费的,我相信任何经营模式都有可取之处,本插件的开源免费经营模式,需要的就是您的鼓励。
55
## 我是毕业大学生,在艰难的就业市场中正在寻找工作。
66
## 您给我点的免费Star将很大程度帮助我解决温饱问题,再次感谢!
7-
##
7+
##
88

99
# 用法1
1010
1. 光标放到你要插入代码块的地方
@@ -16,6 +16,10 @@
1616
1. 在别的地方复制代码
1717
2. 到思源粘贴,自动设置语言和高亮
1818

19+
# FAQ
20+
Q: 粘贴后不是代码的内容被识别为代码?
21+
A: 可以尝试思源的粘贴为纯文本快捷键(默认是Ctrl+Shift+V),或右键-粘贴为纯文本,或者关闭自动粘贴,只使用斜杠菜单
22+
1923
# TODO
2024
- 斜杠菜单弹窗不优雅
2125
- 代码块上下文菜单自动调整语言
@@ -28,4 +32,4 @@
2832

2933
# 感谢 ♥️
3034
- [@frostime](https://github.com/frostime):: 提供斜杠菜单的代码和绕过思源对剪贴内容预处理逻辑的方案 ♥️
31-
- [@leolee](https://github.com/leolee9086): 对于代码块高亮问题的解决方案 ♥️
35+
- [@leolee](https://github.com/leolee9086): 对于代码块高亮问题的解决方案 ♥️

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "siyuan_auto_codeblock",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"type": "module",
55
"description": "Auto detect the programming language of the code block",
66
"repository": "",

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "siyuan_auto_codeblock",
33
"author": "zxkmm",
44
"url": "https://github.com/zxkmm/siyuan_auto_codeblock",
5-
"version": "0.1.0",
5+
"version": "0.1.1",
66
"minAppVersion": "3.0.12",
77
"backends": ["windows", "linux", "darwin", "docker", "ios", "android"],
88
"frontends": [

src/index.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export default class SiyuanAutoCodeblock extends Plugin {
2929
console.log(_input_text_);
3030
///v edge case handler
3131
//TODO: check other clipboard content e.g. files and link etc, make suer bypass all of them.
32-
///v html code handler
33-
// TODO: html things (e.g. vscode)
34-
///^ html code handler
35-
///v situation about: if it has md format already and also if it has md format with languagee already. TODO check what for vscode.
32+
///
33+
///v edge case 1: if it has md format already and also if it has md format with languagee already. TODO check what for vscode.
3634
if (_input_text_.startsWith("```") && _input_text_.endsWith("```")) {
37-
console.log("ent1");
35+
console.log(
36+
"edge case 1: paste md code block format content, paste as is",
37+
);
3838
const firstLineEnd = _input_text_.indexOf("\n");
3939
const firstLine = _input_text_.substring(0, firstLineEnd).trim();
4040

@@ -57,8 +57,8 @@ export default class SiyuanAutoCodeblock extends Plugin {
5757
return _input_text_;
5858
}
5959
}
60-
///^ situation about: if it has md format already and also if it has md format with languagee already.
61-
///^ edge case handler
60+
///^ edge case1: if it has md format already and also if it has md format with languagee already.
61+
///
6262

6363
///v handle content from siyuan itself //TODO: it seems _input_test_ didn't gave html things, only plain text, but somwhow still not working.
6464
// if (
@@ -78,6 +78,15 @@ export default class SiyuanAutoCodeblock extends Plugin {
7878
// }
7979
///^ handle content from siyuan itself
8080

81+
///v edge case2: single line, link, to prevent it reginganze as YAML.
82+
if (/^https?:\/\/\S+$/.test(_input_text_)) {
83+
console.log("edge case 2: single line http/https link, paste as is");
84+
return _input_text_;
85+
}
86+
///^ edge case2
87+
88+
///^ edge case handler
89+
8190
const originalLanguage = this.handleLanguage(_input_text_); //better looking so this is necessary
8291
const language = this.codeLanguageNameToSiyuanStyle(originalLanguage);
8392

0 commit comments

Comments
 (0)