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

@1-week/doctor-jones

v1.0.3

Published

After all, we should all respect w3c/clreq

Downloads

7

Readme

Doctor Jones

After all, we should all respect w3c/clreq

介绍

doctor-jones 是一个用来格式化中文字符串(包括中英文混排)的工具集,它基于 w3c/clreq 及其他中文排版最佳实践。作为一个工具集,doctor-jones 包括:

  • [x] 一个 npm,用于接收字符串,并返回格式化后的字符串
  • [x] 一个 webpack loader,用于格式化你的 .js, .ts, .jsx, .tsx, .vue 文件中的字符串
  • [x] 一个 Chrome 插件,用于格式化当前正在浏览的网页
  • [ ] 一个即开即用的网站,粘贴一段文本,得到格式化后的输出,即 doctor-jones-as-a-service,简称 DJaaS(计划中)

使用 doctor-jones 可以做到以下格式化:

  • 中英文、中文与数字之间增加半角空格
  • 移除全角标点和英文/数字之间多余的半角空格
  • 移除多于一个的连续感叹号
  • 将省略号规范化为 ……
  • 将引号 “” ‘’ 替换为 「」 『』
  • 将纯数字周围的全角括号替换为半角括号

需要注意的是,这些格式化只对至少包含一个中文字符或全角符号的字符串生效。同时,每个格式化选项都可以通过设置来关闭。

安装

CDN

<script type="text/javascript" src="https://unpkg.com/doctor-jones/dist/index.umd.min.js"></script>

npm

npm i doctor-jones -S

使用

// 使用 CDN
const dj = window.dj

// 使用 npm
import dj from 'doctor-jones'

dj('doctor-jones是一个“治疗”中英文混排格式的工具') // 返回 'doctor-jones 是一个「治疗」中英文混排格式的工具'

格式化选项

dj(
  // 待格式化的字符串
  'doctor-jones是一个“治疗”中英文混排格式的工具',
  
  // 格式化选项
  {
    // 是否在中文和字母数字之间添加空格
    // 可选值:boolean
    spacing: true,

    // 是否允许在全角符号与字母数字之间存在空格  
    // 可选值:boolean
    spaceBetweenFullwidthPunctuationAndAlphabets: false,

    // 是否允许连续的感叹号  
    // 可选值:boolean
    successiveExclamationMarks: false,
  
    // 省略号规范化规则
    // 可选值:'none' | '3dots' | 'all'
    // 'none':将连续出现两次或以上的 。、,. 规范化为 ……
    // '3dots':除 ... 以外,将连续出现两次或以上的 。、,. 规范化为 ……
    // 'all':不进行省略号规范化
    ellipsisTolerance: 'none',
  
    // 弯引号替换规则
    // 可选值:'double' | 'single' | 'none'
    // 'double':使用直角引号「」替换弯引号“”,同时使用直角引号『』替换弯引号‘’
    // 'single':使用直角引号「」替换弯引号‘’,同时使用直角引号『』替换弯引号“”
    // 'none':不替换弯引号
    replaceWithCornerQuotes: 'double',

    // 是否在数字周围使用半角括号  
    // 可选值:boolean
    halfwidthParenthesisAroundNumbers: true
  }
)

CLI

全局安装 doctor-jones,即可在终端中使用:

npm i doctor-jones -g
$ doctor-jones --help

Format Options
  --spacing, -s          是否在中文和字母数字之间添加空格                  [boolean]
  --space-between, --sb  是否允许在全角符号与字母数字之间存在空格           [boolean]
  --exclamation, --ex    是否允许连续的感叹号                            [boolean]
  --ellipsis, --el       省略号规范化规则       [choices: "none", "3dots", "all"]
  --quote, -q            弯引号替换规则     [choices: "none", "double", "single"]
  --parenthesis, -p      是否在数字周围使用半角括号                       [boolean]

Options:
  --help, -h     帮助信息                                              [boolean]
  --version, -v  当前版本                                              [boolean]

Examples:
    doctor-jones 需要格式化的字符串
    doctor-jones -s false 需要格式化的字符串
    doctor-jones -s false --el 3dots 需要格式化的字符串

感谢