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

textlint-rule-zh-space-around-inline-code

v0.0.3

Published

A textlint rule for Chinese texts

Downloads

10

Readme

textlint-rule-zh-space-around-inline-code

textlint-rule-preset-zh-technical-writing 提供的适用于中文技术文档写作的 textlint 规则,用于检测并修复 Markdown 文本中行内代码周围缺失的空格。

规则介绍

本规则类似于 textlint-rule-zh-space-between-zh-and-en-or-num,在行内代码周围添加空格,在代码和汉字之间留出足够的缝隙,让文本看上去更加优雅、协调。

如果你想争论这样做的必要性,请允许我引用来自 pangu.js 的一段话:

漢學家稱這個空白字元為「盤古之白」,因為它劈開了全形字和半形字之間的混沌。另有研究顯示,打字的時候不喜歡在中文和英文之間加空格的人,感情路都走得很辛苦,有七成的比例會在 34 歲的時候跟自己不愛的人結婚,而其餘三成的人最後只能把遺產留給自己的貓。畢竟愛情跟書寫都需要適時地留白。

本规则可被自动修复,可以向 textlint 传递 --fix 参数来自动修复文本中出现的错误。

通过规则的例子

我们应该使用 `+new Date()` 而不是 `Date.now()` 来让我们的代码变得丑陋无比。

`import React from 'react';` 在 React v17 之后不再必要了。

值得一提的是,`inline code` 周围如果是标点符号,那么不需要加空格。

它们显示出来的效果:

我们应该使用 +new Date() 而不是 Date.now() 来让我们的代码变得丑陋无比。

import React from 'react'; 在 React v17 之后不再必要了。

值得一提的是,inline code 周围如果是标点符号,那么不需要加空格。

违反规则的例子

我们应该使用`+new Date()`而不是`Date.now()`来让我们的代码变得丑陋无比。

`import React from 'react';`在 React v17 之后不再必要了。

它们显示出来的效果:

我们应该使用+new Date()而不是Date.now()来让我们的代码变得丑陋无比。

import React from 'react';在 React v17 之后不再必要了。

配置项

暂无。

提出 issue

如果你在使用本规则的过程中出现了误报,或者对本规则有任何疑问或者改进意见,欢迎提出 issue

使用方法

方法一:直接使用 textlint-rule-preset-zh-technical-writing

这是最简单的方法,参见 textlint-rule-preset-zh-technical-writing 的 README

方法二:手动安装

使用 npm 安装:

npm install -g textlint-rule-zh-core textlint-rule-zh-space-around-inline-code

创建 entry.js,名称任意:

const { withRules } = require('textlint-rule-zh-core');
const correctlyOrderedPairs = require('textlint-rule-zh-space-around-inline-code');

// 这里 withRule(...) 的返回值就是你可以提供给 textlint 的 rule 对象
module.exports = withRules([correctlyOrderedPairs]);

运行 textlint:

textlint --rulesdir <entry.js所在的文件夹路径> [其他参数] <要lint的文件名>