Giter VIP home page Giter VIP logo

huacnlee / autocorrect Goto Github PK

View Code? Open in Web Editor NEW
797.0 5.0 26.0 6.44 MB

A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK (Chinese, Japanese, Korean).

Home Page: https://huacnlee.github.io/autocorrect

License: MIT License

Rust 77.95% Makefile 0.80% Shell 0.62% Dockerfile 0.03% HTML 1.81% JavaScript 5.50% TypeScript 6.66% SCSS 2.01% Python 0.57% Ruby 1.81% Java 2.23%
rust formatter linter copywriting autocorrect spellcheck webassembly

autocorrect's Introduction

Co-founder of the Ruby China, 💎 I also created a RubyGems Mirror in China.

  • Before (2011 - 2018): Work for Alibaba and Ant Group.
  • Now: I work for Longbridge Inc. 🌉

Featured

Rust

  • autocorrect - A linter and formatter to help you to improve copywriting, correct spaces, words, punctuations between CJK (Chinese, Japanese, Korean).
  • rust-i18n - A better and simply I18n crate for Rust.

Go

  • gobackup - CLI tool for backup your databases, files to FTP / SCP / S3 / GCS and other cloud storages.
  • gorm-sharding - High performance table sharding plugin for Gorm.
  • html-pipeline - HTML processing filters and utilities.
  • autocorrect-go - Go version of AutoCorrect.
  • assert - Extends stretchr/testify/assert for add more useful methods.
  • opencc-go - Pure Go version OpenCC 繁簡轉換.
  • nested-set - Nested set model for Gorm.
  • go-pinyin - Forked version Pinyin for Go.

Rails Web App

  • homeland - Open source discussion website.
  • bluedoc - Document management tool for enterprise self host.

RubyGems

  • rails-settings-cached - The best solution for store global settings in Rails applications.
  • action-store - Store different kinds of actions (Like, Follow, Star, Block, etc.) in a single table via ActiveRecord Polymorphic Associations.
  • second_level_cache - Second level cache for ActiveRecord for make your application faster.
  • rucaptcha - Captcha gem for Rails Applications which generates captcha image by Rust.
  • notifications - Notifications Center engine like GitHub or other application for any Rails applications.
  • audit-log - Trail audit logs (Operation logs) into the database for user behaviors, including a Web UI to query logs.
  • sql-builder - A simple SQL builder for generate SQL for non-ActiveRecord supports database.

JavaScript

  • feishu-pages - Generate Feishu Wiki into a Markdown for work with Static Page Generators.

Contributed

  • rails - Ruby on Rails
  • gitlab - GitLab Project
  • gorm - The fantastic ORM library for Go.
  • pest - A Rust general purpose parser.

autocorrect's People

Contributors

dependabot[bot] avatar dunky-z avatar exhades avatar fulgari avatar huacnlee avatar kwanhur avatar messense avatar tombener avatar yangtzech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

autocorrect's Issues

VSCODE 插件 Format document 命令错误

命令"AutoCorrect:Format document"导致错误(Error:ENOENT:no such file or directory,stat 'd:\Github\hugo.autocorrectrc)。

image

尝试重新安装插件,未能解决问题。

[JS] 运行wasm报错

node_modules/@huacnlee/autocorrect/autocorrect_bg.js 的170行wasm.__wbindgen_add_to_stack_pointer(16);在Chrome中报错并无法运行:

Uncaught (in promise) TypeError: wasm.__wbindgen_add_to_stack_pointer is not a function

实现代码

    let [value, setValue] = React.useState(`# Hello你好!`);
    let Out1;
    autocorrect.then((autocorrect) => {
        Out1 = autocorrect.format(value); //报错 
    });

spellcheck: replacement in codeblock without '```'

Hello, Markdown do support such codeblock style (for example, use 4 whitespaces after a line without indent)

Test for words replacement in codeblock like this:

    // this is a 'echo' command line demo to print a string: linux
    $ echo linux

    // another demo
    $ cmd-linux -g linux

But the word 'linux' will be replaced by 'Linux' after running autocorrect.

Test for words replacement in codeblock like this:

    // this is a 'echo' command line demo to print a string: linux
    $ echo Linux

    // another demo
    $ cmd-linux -g Linux

If wrap the above codeblock with '```', it is ok.

may be two solve directions:

  1. line with '$' or '#' are command lines (but sometimes, users not explictly add '$' or '#' prompt), which should not be touched, otherwise, the command demo instructions will differ from the original requirement
  2. detect such codeblock style and let them work like the codeblock wrapped with '```'

Bad case: Han in URL

Raw:

wiki/网页浏览器列表#基於WebKit排版引擎
https://zh.wikipedia.org/wiki/网页浏览器列表#基於WebKit排版引擎
- wiki/网页浏览器列表#基於 WebKit 排版引擎
+ wiki/网页浏览器列表#基於WebKit排版引擎
- https://zh.wikipedia.org/wiki/网页浏览器列表#基於 WebKit 排版引擎
+ https://zh.wikipedia.org/wiki/网页浏览器列表#基於WebKit排版引擎

Base case: <code>

- 关键字和<code>Promise</code>构造器创建它的对象
+ 关键字和 <code>Promise</code> 构造器创建它的对象

Need space between link.

Based href

Maybe

- 这是[link链接](https://google.com/a/b/url不处理)测试

should be like

- 这是 [link链接](https://google.com/a/b/url不处理) 测试

image

VSCode是否可以配置.autocorrectrc?

插件介绍里说明提到有支持 .autocorrectrc 配置文件。但是没有说明配置方法,目前根据example添加了.autocorrectrc 配置文件放在待格式化文档同级目录,并不生效。请问VSCode如何配置 .autocorrectrc ?谢谢!

对 Markdown 的支持

大多数时候都很好用。感谢维护。

但似乎没有在 VSCode 插件中支持对 Markdown 文件的 Lint?

Details

image

另:

尝试在 VSCode 中开启插件:

"autocorrect.enable": true,
"autocorrect.formatOnSave": true,

然后新建一个 Markdown 文件,在文件中输入 N~2~为...,然后保存,会发现转成了 N~2~为...(第二个 ~ 变为了一个全角字符),这大概是预期之外的。

暂时禁用 AutoCorrect 并保存:

<!-- autocorrect: false -->
N~2~为...
<!-- autocorrect: true -->

会发现暂时禁用无效,仍然会被更正。

Bad case: . -> 。has a space

Raw

引进给变量, 转换为机器代码. 这意味着任何变量命名的概念都会被删除

To

- 引进给变量, 转换为机器代码。 这意味着任何变量命名的概念都会被删除
+ 引进给变量,转换为机器代码。这意味着任何变量命名的概念都会被删除

[Bug] Lint 跳转失败

AutoCorrect 在 VSCode 的问题面板中给出了纠正建议,但是我点击建议无法正常跳转,提示无法打开...: Unable to resolve resource...

Details

demo

Bad case: Avoid add space near the link in Markdown file

它指向一个[示例](#示例)
它无需[握手](https://zh.wikipedia.org/wiki/握手_(技术))或改进、完善现有条。
- 它指向一个 [示例](#示例)
+ 它指向一个[示例](#示例)
- 它无需[握手](https://zh.wikipedia.org/wiki/握手_(技术)) 或改进、完善现有条。
+ 它无需[握手](https://zh.wikipedia.org/wiki/握手_(技术))或改进、完善现有条。

Bad case: String in URL

- slug: Web/JavaScript/Reference/Operators/async 允许声明一个函数为一个包含异步操作的函数
+ slug: Web/JavaScript/Reference/Operators/async允许声明一个函数为一个包含异步操作的函数

不支持 C++?

目前似乎不支持检查 C++ 源文件?

示例文件:hello.cc

// 你好world

运行 autocorrect

$ ./autocorrect hello.cc
无输出

.cc 重命名成 .txt

$ mv hello.cc hello.txt
$ ./autocorrect hello.txt
// 你好 world

YAML lint 遗漏

responses:
  "400":
    description: "查询失败,请求参数错误."

超长文本(20W字符)执行失败

您好,感谢分享,短文章很好用,效率和准确度都很高。但是在Correct长文章时,出现了问题。

20W的字符,I5 10代 用了8线程,运行了大概24小时仍然没有结束。

  • 是否有字符上限?
  • 建议字符是多少?

谢谢!

插件运行错误,格式化不生效

插件->运行时状态->未捕获的错误(1)

path should be a path.relative()d string, but got "............\Programs\VSCode\data\user-data\User\settings.json"

我使用的是 portable 版的 vsc,数据配置保存 vsc 目录下,也就是报错提示中的路径,报错可能与此有关

image

Markdown 中如果使用了 Wikilinks 不应该被添加空格

[[wikilink]] 作为跳转的 keyword 不应该被添加空格,否则就无法跳转了

- [[2021年十大漏洞利用]]
+ [[2021 年十大漏洞利用]]
- [[从研究者视角看漏洞研究之2010年代]]
+ [[从研究者视角看漏洞研究之 2010 年代]]

spellcheck: replacement happen in the url alias map

原文:

这里是 [链接][1]。
...

[1]: https://example.com/xxx/yyy/zzz-linux

运行 Autocorrect 之后:

这里是 [链接][1]。
...

[1]: https://example.com/xxx/yyy/zzz-Linux

The linux has been wrongly replaced by Linux, this should not happen.

Support pre-commit hook

Under pre-commit, it can add custom hook. So hope autocorrect could support it.

For example, add .pre-commit-hooks.yaml in this repo, then users could import it locally in .pre-commit-config.yaml.

  • .pre-commit-hooks.yaml
-   id: autocorrect-lint
    name: autocorrect lint
    description: "Checks CJK files' copywriting"
    entry: autocorrect --lint
    language: rust
-   id: autocorrect-fix
    name: autocorrect fix
    description: "Fixes CJK files' copywriting"
    entry: autocorrect --fix
    language: rust
  • .pre-commit-config.yaml
- repo: https://github.com/huacnlee/autocorrect
  rev: v1.5.7
  hooks:
    - id: autocorrect-lint
    - id: autocorrect-fix

中文全角的引号

中文全角的引号前面应该不需要加空格:,目前自动会加一个空格,不支持是不是预期的。譬如:

你好“世界“

会被格式化成

你好 “世界”

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.