npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@skyfury/reformat-markdown-cn

v2.0.4

Published

Reformat and align markdown tables with Chinese

Downloads

8

Readme

reformat-markdown-cn

Version node Build Status Coverage Status

例子

MarkDown 表格代码如下:

## 标题

| 姓名 | 电话 | 邮箱 |
| --- | :---: | ---: |
| 王顶 | 13582027613 | [email protected] |
| 郭玉朝 | 13812347652 | [email protected] |
|  | abc | def

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

## 标题

| 姓名   |     电话     |              邮箱 |
|-------|:-----------:|-----------------:|
| 王顶   | 13582027613 | [email protected] |
| 郭玉朝 | 13812347652 |    [email protected] |
|       |     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   |