Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit f95a762

Browse files
committed
+WikiLinkAutoHint, +CompileSystem +README
1 parent feca6dd commit f95a762

18 files changed

+1172
-10
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
all: build
2+
3+
build:
4+
python3 ./build.py
5+
6+
clean:
7+
rm -rf ./dist

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
11
# CodeMirror-Mode-TiddlyWiki5
22

3-
Adds Syntax Highlighting for TiddlyWiki tiddlers (text/vnd.tiddlywiki) to the CodeMirror.
3+
Adds Syntax Highlighting for TiddlyWiki5 tiddlers (`text/vnd.tiddlywiki`) to the CodeMirror, along with some other useful editor addon (wikilink hint, macro hint, etc.). Now is under development.
4+
5+
为TiddlyWiki的CodeMirror编辑器添加TiddlyWiki5(`text/vnd.tiddlywiki`)语法高亮,同时还有其他有用的编辑器插件(如Wiki链接自动提示、宏提示等)。现在正在开发中。
6+
7+
[> English Readme <](https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5/blob/main/README_en.md)
8+
9+
---
10+
11+
[TOC]
412

5-
![default](media/default.jpg)
6-
![ayu-dark](media/ayu-dark.jpg)
7-
![tiddlywiki](media/tiddlywiki.jpg)
813
## 插件说明
914

10-
增加 [CodeMirror](http://codemirror.net) 对TiddlyWiki5语法高亮的支持,所有类型留空或者为`text/vnd.tiddlywiki`的tiddler都会有高亮。请首先安装最新版CodeMirror主插件和CodeMirror XML子插件(不然会报错)
15+
增加 [CodeMirror](http://codemirror.net) 对TiddlyWiki5语法高亮的支持,所有MIME类型留空或者为`text/vnd.tiddlywiki`的tiddler都会有高亮。同时支持像`VSCode`那样在打字时实时进行代码补全提示(目前仅实现了WikiLink补全),且**不需要**`Ctrl+Space`激活
1116

1217
插件还在开发中,如有任何建议或者bug请直接提Issue。
1318

19+
## 安装&编译
20+
21+
<span style="color: red; font-weight: 900;">请首先安装最新版CodeMirror主插件和CodeMirror XML子插件(不然会报错)。</span>
22+
23+
直接去[Release](https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5/releases)下载`CodeMirrorModeTiddlyWiki5-X.X.X.json`,然后将其拖拽到你的TiddlyWiki中,或者在TiddlyWiki中导入之。
24+
1425
如果插件报错了,不必惊慌,因为插件不会对TiddlyWiki本体内容做修改,所以只需要卸载就能够消除问题,但保险起见**还是建议先备份再安装**
1526

27+
如果想DIY和编译,请直接运行`make`或者`make build`。请注意,被打包的是那几个`xxx.min.js``xxx.min.css`
28+
29+
## 功能介绍
30+
31+
<details>
32+
<summary>高亮TiddlyWiki5语法,支持内嵌代码块和LaTeX的语法高亮</summary>
33+
34+
Default:
35+
![default](media/mode-default.jpg)
36+
37+
Ayu-Dark:
38+
![ayu-dark](media/mode-ayu-dark.jpg)
39+
40+
TiddlyWiki:
41+
![tiddlywiki](media/mode-tiddlywiki.jpg)
42+
43+
</details>
44+
45+
注意:这些主题有些是我自己装的,如感兴趣换主题,请阅读TiddlyWiki的CodeMirror的README。
46+
47+
<details>
48+
<summary>WikiLink自动补全提示</summary>
49+
50+
![wikilink-hint](media/wikilink-hint.gif)
51+
52+
</details>
53+
54+
其他功能正在开发中。
55+
1656
## 开发感想
1757

18-
在使用TiddlyWiki之后,一直苦于TiddlyWiki5语法没有高亮支持,写作体验不是很好。之前有也在网上找到一些相关的解决办法,例如在[Google Group](https://groups.google.com/g/tiddlywiki/c/c3y-PycRP4M)上面有人建议[用TiddlyWiki2的语法进行Hack](https://www.gitmemory.com/issue/Jermolene/TiddlyWiki5/3685/770313436)
58+
在使用TiddlyWiki之后,一直苦于TiddlyWiki5语法没有高亮支持,写作体验不是很好。之前有也在网上找到一些相关的解决办法,例如在[Google Group](https://groups.google.com/g/tiddlywiki/c/c3y-PycRP4M)上面有人建议[用TiddlyWiki2的语法进行Hack](https://www.gitmemory.com/issue/Jermolene/TiddlyWiki5/3685/770313436),但是这种方法并不完美
1959

20-
也有人编写了一个可用的CodeMirror的扩展版本[TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus),虽然是可用的,但是有两个问题:一个是语法高亮的内容有限,另一个是该插件直接基于theme而非mode进行开发,这就导致''如果想要用TW5的高亮就必须舍弃其他语法高亮,并且无法自定义主题''。所以最终还是打算自己写一个XD
60+
也有人编写了一个可用的CodeMirror的扩展版本[TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus),虽然是可用的,但是有两个问题:一个是语法高亮的内容有限,另一个是该插件直接基于theme而非mode进行开发,这就导致**如果想要用TW5的高亮就必须舍弃其他语法高亮,并且无法自定义主题**。所以最终还是打算自己写一个 :D
2161

22-
本插件其实也是基于[TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus)开发的,只不过魔改了很多,基本上是两个插件了
62+
本插件一开始也是基于[TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus)开发的,只不过魔改了很多,现在基本上是两个不同的插件了
2363

24-
## TODO
64+
## TODO List
2565

2666
- [x] 代码块内的语法高亮与缩进。
2767
- [x] LaTeX公式高亮与缩进。
28-
- [ ] 自动补全内部链接的tiddler名称。
68+
- [x] 自动补全内部链接的tiddler名称。
2969
- [ ] 其他代码提示。
3070
- [ ] 代码错误检查。
3171
- [ ] 鼠标悬在LaTeX代码上方能够进行公式预览。

README_en.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CodeMirror-Mode-TiddlyWiki5
2+
3+
Adds Syntax Highlighting for TiddlyWiki5 tiddlers (`text/vnd.tiddlywiki`) to the CodeMirror, along with some other useful editor addon (wikilink hint, macro hint, etc.). Now is under development.
4+
5+
为TiddlyWiki的CodeMirror编辑器添加TiddlyWiki5(`text/vnd.tiddlywiki`)语法高亮,同时还有其他有用的编辑器插件(如Wiki链接自动提示、宏提示等)。现在正在开发中。
6+
7+
[> 中文README <](https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5/blob/main/README.md)
8+
9+
---
10+
11+
[TOC]
12+
13+
## Plugin description
14+
15+
Add [CodeMirror](http://codemirror.net) support for TiddlyWiki5 syntax highlighting, all tiddlers with MIME type left blank or `text/vnd.tiddlywiki` will be highlighted. Also supports real-time code completion hints like `VSCode` while typing (currently only WikiLink completion is implemented) and **no need** to activate with `Ctrl+Space`.
16+
17+
Plugin is still under development, if you have any suggestions or bugs, please directly mention Issues.
18+
19+
## Installation & Compilation
20+
21+
<span style="color: red; font-weight: 900;">First install the latest version of CodeMirror main plugin and CodeMirror XML sub-plugin (otherwise it will report an error).</span>
22+
23+
Go directly to [Release](https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5/releases) and download `CodeMirrorModeTiddlyWiki5-X.X.X.json`, then drag and drop it into your TiddlyWiki, or import it in TiddlyWiki.
24+
25+
If the plugin reports an error, there is no need to panic, because the plugin does not make changes to your TiddlyWiki content, so just uninstall it and you will be able to eliminate the problem, but to be on the safe side **it is still recommended to backup it before installing it**.
26+
27+
If you want to DIY and compile, please run `make` or `make build` directly. Note that it is the `xxx.min.js` and `xxx.min.css` that are packaged.
28+
29+
## Function Introduction
30+
31+
<details>
32+
<summary>TiddlyWiki5 syntax highlighting, support for inline code blocks and syntax highlighting for LaTeX</summary>
33+
34+
Default:
35+
![default](media/mode-default.jpg)
36+
37+
Ayu-Dark:
38+
![ayu-dark](media/mode-ayu-dark.jpg)
39+
40+
TiddlyWiki:
41+
![tiddlywiki](media/mode-tiddlywiki.jpg)
42+
43+
</details>
44+
45+
Note: Some of these themes are installed by myself, if you are interested in changing the theme, please read TiddlyWiki's CodeMirror's README.
46+
47+
<details>
48+
<summary>WikiLink Auto Hint</summary>
49+
50+
![wikilink-hint](media/wikilink-hint.gif)
51+
52+
</details>
53+
54+
Other features are under development.
55+
56+
## Development Thoughts
57+
58+
After using TiddlyWiki, I've been suffering from the lack of highlighting support in TiddlyWiki5 syntax, and the writing experience is not very good. I have found some solutions on the web, for example, on the [Google Group](https://groups.google.com/g/tiddlywiki/c/c3y-PycRP4M) someone suggested [Hack with TiddlyWiki2 syntax](https://www.gitmemory.com/issue/Jermolene/TiddlyWiki5/3685/770313436), but this approach is not perfect.
59+
60+
An extended version of CodeMirror has also been written that is available [TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus), which is available but has two problems. One is that the syntax highlighting is limited. The other is that the plugin is developed directly based on theme rather than mode, which leads to that **if you want to use TW5's highlighting you have to discard other syntax highlighting and can't customize the theme**. So eventually I plan to write one myself :D
61+
62+
This plugin is also based on [TW5-CodeMirror-Plus](https://github.com/adithya-badidey/TW5-codemirror-plus) at the beginning, but I made a lot of changes on it, now they're basically two different plugins.
63+
64+
## TODO List
65+
66+
- [x] Syntax highlighting and indentation within code blocks.
67+
- [x] LaTeX formula highlighting and indentation.
68+
- [x] WikiLink AutoHint.
69+
- [ ] Other code hints.
70+
- [ ] Code error checking.
71+
- [ ] Mouse hovering over LaTeX code enables formula preview.

build.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"meta": {
3+
"version": "0.0.2",
4+
"type": "application/json",
5+
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5",
6+
"plugin-type": "plugin",
7+
"parent-plugin": "$:/plugins/tiddlywiki/codemirror",
8+
"name": "CodeMirror Mode TiddlyWiki5",
9+
"list": "readme-zh",
10+
"description": "TiddlyWiki5 highlighting mode for CodeMirror",
11+
"dependents": "$:/plugins/tiddlywiki/codemirror-mode-xml"
12+
},
13+
"shadow-tiddlers": [{
14+
"type": "external",
15+
"src": "./src/tw5-mode.min.js",
16+
"meta": {
17+
"title": "$:/plugins/tiddlywiki/codemirror/mode/tiddlywiki5/tiddlywiki5.js",
18+
"module-type": "codemirror",
19+
"tags": "",
20+
"type": "application/javascript"
21+
}
22+
},
23+
{
24+
"type": "external",
25+
"src": "./src/style.min.css",
26+
"meta": {
27+
"type": "text/css",
28+
"title": "$:/plugins/Gk0Wk/codemirror-tiddlywiki5/style.css",
29+
"tags": "$:/tags/Stylesheet"
30+
}
31+
},
32+
{
33+
"type": "external",
34+
"src": "./src/tex-mode.min.js",
35+
"meta": {
36+
"type": "application/javascript",
37+
"title": "$:/plugins/tiddlywiki/codemirror/mode/tex/tex.js",
38+
"tags": "",
39+
"module-type": "codemirror"
40+
}
41+
},
42+
{
43+
"type": "external",
44+
"src": "./src/readme-zh.tw5",
45+
"meta": {
46+
"type": "",
47+
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/readme-zh",
48+
"tags": ""
49+
}
50+
},
51+
{
52+
"type": "external",
53+
"src": "./src/tw5-autohint.min.js",
54+
"meta": {
55+
"type": "application/javascript",
56+
"title": "$:/plugins/tiddlywiki/codemirror/addon/hint/hint-tiddlywiki5.js",
57+
"tags": "",
58+
"module-type": "codemirror"
59+
}
60+
}
61+
]
62+
}

build.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
if __name__ == '__main__':
2+
import json
3+
import os
4+
5+
with open('build.json', 'r') as fp:
6+
build_info = json.loads(fp.read())
7+
8+
tiddlers = {}
9+
for tiddler_ in build_info['shadow-tiddlers']:
10+
tiddler = tiddler_['meta']
11+
if tiddler_['type'] == 'external':
12+
if os.path.exists(tiddler_['src']) and os.path.isfile(tiddler_['src']):
13+
with open(tiddler_['src'], 'r') as fp:
14+
tiddler['text'] = fp.read()
15+
else:
16+
tiddler['text'] = ''
17+
tiddlers[tiddler['title']] = tiddler
18+
plugin = build_info['meta']
19+
plugin['text'] = json.dumps({'tiddlers': tiddlers})
20+
21+
os.makedirs('./dist', exist_ok=True)
22+
import re
23+
with open('./dist/' +
24+
re.sub('[^A-Za-z0-9_]', '', build_info['meta']['name'])
25+
+ '-' + build_info['meta']['version'] + '.json', 'w') as fp:
26+
fp.write(json.dumps([plugin]))

media/wikilink-hint.gif

349 KB
Loading

src/readme-zh.tw5

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[GitHub Repo|https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5]]
2+
3+
!! 插件说明
4+
5+
增加 [[CodeMirror|http://codemirror.net]] 对~TiddlyWiki5语法高亮的支持,所有类型留空或者为`text/vnd.tiddlywiki`的tiddler都会有高亮。请首先安装最新版[[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]]主插件和~CodeMirror XML附插件(不然会报错)。
6+
7+
插件还在开发中,如有任何建议或者bug请在[[GitHub|https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5]]上提Issue,如果墙翻不过去的同学,可以联系我(Email: [email protected])。
8+
9+
如果插件报错了,不必惊慌,因为插件不会对~TiddlyWiki本体内容做修改,所以只需要卸载就能够消除问题,但保险起见''__还是建议先备份再安装__''。
10+
11+
!! 开发感想
12+
13+
在使用~TiddlyWiki之后,一直苦于~TiddlyWiki5语法没有高亮支持,写作体验不是很好。之前有也在网上找到一些相关的解决办法,例如在[[Google Group|https://groups.google.com/g/tiddlywiki/c/c3y-PycRP4M]]上面有人建议[[用TiddlyWiki2的语法进行Hack|https://www.gitmemory.com/issue/Jermolene/TiddlyWiki5/3685/770313436]]。
14+
15+
也有人编写了一个可用的~CodeMirror的扩展版本[[TW5-CodeMirror-Plus|https://github.com/adithya-badidey/TW5-codemirror-plus]],虽然是可用的,但是有两个问题:一个是语法高亮的内容有限,另一个是该插件直接基于theme而非mode进行开发,这就导致''如果想要用TW5的高亮就必须舍弃其他语法高亮,并且无法自定义主题''。所以最终还是打算自己写一个XD
16+
17+
本插件其实也是基于[[TW5-CodeMirror-Plus|https://github.com/adithya-badidey/TW5-codemirror-plus]]开发的,只不过魔改了很多,基本上是两个插件了。

0 commit comments

Comments
 (0)