Markdown 格式检查工具 hint

码农软件 · 软件分类 · Markdown开发包 · 2019-10-09 20:27:45

软件介绍

hint 是一个简单的 markdown 静态检查的控制台 cli 工具,可以方便 markdown 开发者轻松集成 travis 自动检测。

一、安装

pip install hint

然后在系统中会得到一个 hint 的命令 cli 工具。

二、使用

使用方法有两种:

2.1 一种是命令行 cli 方式,简单使用方法如下:

hint markdown_file

或者

hint markdown_folder

或者使用 hint --help 查看帮助信息和具体详细的使用方法。

$ hint --help
Usage: hint-script.py [OPTIONS] FILE

Options:
  -i, --ignore TEXT         The error codes which will be ignored.
  -f, --format [text|json]  The output format of error information.
  -m, --max-depth INTEGER   The max depth for traverse the path.
  --help                    Show this message and exit.

可以用于直接集成到各种 ci 系统中,例如 travis-ci。

2.2 另外一种是代码 API 调用的方式,简单使用方法如下:

import hint

text='''
hint 是一个简单的 **markdown** 静态检查的控制台 `cli` 工具。
可以方便 markdown 开发者轻松集成 travis 自动检测。
'''
errors = hint.check(text, ignore='E201')

fn = 'README.md'
errors = hint.check_file(fn, format='text')

可以方便的进行第三方扩展开发。

三、错误码

检查规则来源于 chinese-copywriting-guidelines,错误码命名方式参考于 flake8。目前支持的错误码如下所示:

错误码检查类型详细描述完成
E101空格中英文之间需要增加空格done
E102空格中文与数字之间需要增加空格done
E103空格全角标点与其他字符之间不加空格done
E104空格除了%、℃、°、以及倍数单位(如 2x、3n)之外,数字与单位之间需要增加空格done
E201标点不重复使用标点符号done
E202标点只有中文或中英文混排中,一律使用中文全角标点done
E203标点如果出现整句英文,则在这句英文中使用英文、半角标点done
E204标点省略号请使用……标准用法done
E205标点英文和后面的半角标点之间不需要空格done
E301数字数字使用半角字符done

关于各种错误码的正确、错误范例,可以参考 tests/md目前有了大概的代码结构,欢迎 PR 更多的检查错误类型和检查方式

本文地址:https://codercto.com/soft/d/16406.html

Programming the Mobile Web

Programming the Mobile Web

Maximiliano Firtman / O'Reilly Media / 2010-07-23 / $44.99

* Learn how to use your existing skills to move into mobile web development * Discover the new possibilities of mobile web development, and understand its limitations * Get detailed coverage of ......一起来看看 《Programming the Mobile Web》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码