Skip to content

Commit

Permalink
v2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaozhuwa committed May 11, 2021
1 parent 42d19ba commit 797fdca
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 42 deletions.
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Easy Typing
这是一个 [Obsidian](https://obsidian.md/) 的书写体验增强插件。
## Easy Typing Plugin
## Easy Typing 插件
[English README](#Easy-Typing-Plugin)

本插件可以在笔记编辑过程中自动格式化书写,比如自动在中英文之间添加空格,让中文用户的 Obsidian 书写体验起飞~
![show](show.gif)
- 运行测试
Expand All @@ -22,13 +24,39 @@
- 快捷键/命令
- [x] 格式化当前行
- [ ] 一键全文格式化

### 展望功能/改进空间
- [ ] 选中文本的功能?目前没有好的想法来实现该功能。
- [ ] 选中文本情况下,按中文的¥键,将自动替换成$,变成行内公式
- [ ] 选中文本情况下,按中文的·,将自动替换成`,变成行内代码块
- [ ] 用户自定义正则表达式及其替换规则?
### 手动安装插件

`main.js`, `styles.css`, `manifest.json` 复制到您的保管库 `VaultFolder/.obsidian/plugins/your-plugin-id/` 中。

### Changelog
- v2.3.0
- improvement
- 增加了对obsidian 和 zotero 链接的识别(`obsidian:https://`, `zotero:https://`),链接内部不自动 format
- Bug fix
- 修复了对部分链接内部字符无法识别的bug
- v2.2.0
- improvement
- 去除部分冗余代码
- 对main.ts中类重新命名
- v2.1.0
- bugs fix
- 修复上个版本中链接在某些情况下还是会被格式化的bug
- v2.0.0
- Improvement
- 独立设置数字和英文文本,标点的空格,数字和`.`不空格
- list,checkbox 中支持英文行首字母大写
- 自动识别网址链接,不格式化网址链接部分内容
- 识别 WikiLink 和 MarkDown link,不格式化其内容
- 设置面板分类更加清晰
- Bug fix
- inline 元素的范围识别逻辑
- v1.0.0
- 基本功能完成
---
## Easy Typing Plugin
This plugin designed for better typing experience.
Expand All @@ -53,32 +81,8 @@ This plugin designed for better typing experience.
- [x] format current line
- [ ] format current note

### ToDo

### Changelog
- v2.2.0
- improvement
- 去除部分冗余代码
- 对main.ts中类重新命名
- v2.1.0
- bugs fix
- 修复上个版本中链接在某些情况下还是会被格式化的bug
- v2.0.0
- Improvement
- 独立设置数字和英文文本,标点的空格,数字和`.`不空格
- list,checkbox 中支持英文行首字母大写
- 自动识别网址链接,不格式化网址链接部分内容
- 识别 WikiLink 和 MarkDown link,不格式化其内容
- 设置面板分类更加清晰
- Bug fix
- inline 元素的范围识别逻辑
- v1.0.0
- 基本功能完成
### How to use

- Clone this repo.
- `npm i` or `yarn` to install dependencies
- `npm run dev` to start compilation in watch mode.
### Notice
don't put your link inside inline code or inline formula, or autoformatting may not works

### Manually installing the plugin

Expand Down
22 changes: 12 additions & 10 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum InlineMarks {codestart = 'CodeStart', codeend='CodeEnd',
formulastart='FormulaStart', formulaend="FormulaEnd",
mdlinkstart='MdLinkStart', mdlinkend='MdLinkEnd',
wikilinkstart='WikiLinkBegin', wikilinkend='WikiLinkEnd',
httpinkstart ='HttpLinkStart', httplinkend='HttpLinkEnd', none='None'};
otherlinkstart ='OtherLinkStart', otherlinkend='HttpLinkEnd', none='None'};

const DEFAULT_SETTINGS: EasyTypingPluginSettings = {
mySetting: 'default',
Expand Down Expand Up @@ -263,18 +263,19 @@ export default class EasyTypingPlugin extends Plugin {
}

// var regHttpLink = /(?<!\()http(s?):\/\/[0-9a-zA-Z-#\.\/]+/;
var regHttpLink = /http(s?):\/\/[0-9a-zA-Z-#\.\/]+/;
// var regOtherLink = /(https?|obsidian|zotero):\/\/[_0-9a-zA-Z-#\.\/]+/;
var regOtherLink = /(https?|obsidian|zotero):\/\/[^\s\)\(\[\]\{\}']+/;
offset = 0;
linecopy = line;
while(linecopy.search(regHttpLink)!=-1)
while(linecopy.search(regOtherLink)!=-1)
{
let begin = linecopy.search(regHttpLink);
let end = begin + linecopy.match(regHttpLink)[0].length-1;
if(begin!=0 && linecopy.charAt(begin-1)==='!'){
begin -= 1;
}
inlineIndex.push([begin+offset, InlineMarks.httpinkstart]);
inlineIndex.push([end+offset, InlineMarks.httplinkend]);
let begin = linecopy.search(regOtherLink);
let end = begin + linecopy.match(regOtherLink)[0].length-1;
// if(begin!=0 && linecopy.charAt(begin-1)==='!'){
// begin -= 1;
// }
inlineIndex.push([begin+offset, InlineMarks.otherlinkstart]);
inlineIndex.push([end+offset, InlineMarks.otherlinkend]);
linecopy = linecopy.substring(end+1);
offset += end+1;
}
Expand Down Expand Up @@ -336,6 +337,7 @@ export default class EasyTypingPlugin extends Plugin {

linecopy = plugin.processInlineElements(linecopy);
let subStrings = plugin.getSubStrings(linecopy);
// console.log(subStrings);
let output = '';
subStrings.forEach(function(item){
let tempString = item[0];
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "easy-typing-obsidian",
"name": "Easy Typing",
"version": "2.2.0",
"version": "2.3.0",
"minAppVersion": "0.9.12",
"description": "This is a simple plugin for Obsidian. This plugin designed for better typing experience.",
"description": "This plugin designed for better typing experience.",
"author": "yaozhuwa",
"authorUrl": "https://github.com/Yaozhuwa",
"isDesktopOnly": false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easy-typing-obsidian",
"version": "2.2.0",
"version": "2.3.0",
"description": "This plugin designed for better typing experience.",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"2.2.0": "0.9.12"
"2.3.0": "0.9.12"
}

0 comments on commit 797fdca

Please sign in to comment.