New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

doctor-jones

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doctor-jones

After all, we should all respect w3c/clreq

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
6
20%
Maintainers
1
Weekly downloads
 
Created
Source

Doctor Jones

After all, we should all respect w3c/clreq

Codacy grade Coverage Status npm bundle size Liscense







链接
文档 · English README · npm Page

相关项目
doctor-jones-loader · doctor-jones-extension · More to be developed...

介绍

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

  • 一个 npm,用于接收字符串,并返回格式化后的字符串
  • 一个 webpack loader,用于格式化你的 .js, .ts, .jsx, .tsx, .vue 文件中的字符串
  • 一个 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 需要格式化的字符串

感谢

FAQs

Package last updated on 21 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts