@skyfury/reformat-markdown-cn
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

reformat-markdown-cn

Version node Build Status Coverage Status

例子

MarkDown 表格代码如下:

## 标题

| 姓名 | 电话 | 邮箱 |
| --- | :---: | ---: |
| 王顶 | 13582027613 | 408542507@qq.com |
| 郭玉朝 | 13812347652 | baldy@163.com |
|  | abc | def

通过 reformat-markdown-cn 工具的处理之后:

## 标题

| 姓名   |     电话     |              邮箱 |
|-------|:-----------:|-----------------:|
| 王顶   | 13582027613 | 408542507@qq.com |
| 郭玉朝 | 13812347652 |    baldy@163.com |
|       |     abc     |              def |

终端使用

编辑一个 MarkDown 文件, MarkDown 表格内容,运行下面的命令:

#格式化Markdown表格

npm i @skyfury/reformat-markdown-cn -g

reformat-markdown-cn -h

Usage: reformat-markdown-cn [options] <files|directories|globs>

Options:
  -V, --version          output the version number
  -R, --reformat [type]  check another rules and reformat markdown table, (default: {"0": 0, "1": 2, "2": 3, "3": 5})
  -C, --cat              only cat format markdown content (default: false)
  -h, --help             display help for command

#  1:2对应,合适等比字体
#  '{"0": 0, "1": 2}'
#  [默认] IDEA大致对应
#  '{"0": 0, "1": 2, "2": 3, "3": 5}'
#  自定义对应,按照需求自定义向后添加
#  '{"0": 0, "1": 2, "2": 3, "3": 5, "4": 7}'


# 格式化一个文件
reformat-markdown-cn ./markdown/example.md 
# 格式化多个文件
reformat-markdown-cn ./markdown/**/*.md
# 自定义字符对应
reformat-markdown-cn ./markdown/example.md -R '{"0": 0, "1": 2}'
reformat-markdown-cn ./markdown/**/*.md -R '{"0": 0, "1": 2}'
# 终端输出内容,不会覆盖源文件
reformat-markdown-cn ./markdown/example.md -R '{"0": 0, "1": 2}' -C
reformat-markdown-cn ./markdown/**/*.md -R '{"0": 0, "1": 2}' -C

代码使用

javascript 使用

const {reformatReadmeDoc} = require('@skyfury/reformat-markdown-cn')

const str = `
|测试|你好|world|世界|
|-----|-----|-----|-------|
|1|1|2|2|
|22|33|44|55|
`
const result = reformat(content)

const str1 = reformatReadmeDoc(str, JSON.stringify(format))

console.log(str1)

// | 测试 | 你好 | world | 世界 |
// |------|------|-------|------|
// | 1    | 1    | 2     | 2    |
// | 22   | 33   | 44    | 55   |

typescript 使用

import {reformatReadmeDoc}  from '@skyfury/reformat-markdown-cn'

const str = `
|测试|你好|world|世界|
|-----|-----|-----|-------|
|1|1|2|2|
|22|33|44|55|
`

console.log(str)
const format = {
  0: 0,
  1: 2,
  // 2: 3,
  // 3: 5,
}

const str1 = reformatReadmeDoc(str, JSON.stringify(format))

console.log(str1)

// | 测试 | 你好 | world | 世界 |
// |------|------|-------|------|
// | 1    | 1    | 2     | 2    |
// | 22   | 33   | 44    | 55   |

Package Sidebar

Install

npm i @skyfury/reformat-markdown-cn

Weekly Downloads

2

Version

2.0.4

License

MIT

Unpacked Size

19.6 kB

Total Files

13

Last publish

Collaborators

  • skyfury