remark-lint-spaces-around-word

raw JSON →
0.1.2 verified Fri May 01 auth: no javascript

A remark-lint plugin that checks for missing spaces between English words and Chinese characters in Markdown files, following the chinese-document-style-guide. Version 0.1.2 is the latest and stable release, with no active development indicated. It is a niche tool specifically for bilingual (Chinese-English) document formatting, differentiating from general remark-lint rules by targeting a specific typographic convention. The plugin has low release cadence and is best used with remark-lint.

error Error: Cannot find module 'remark-lint-spaces-around-word'
cause Package not installed or not in node_modules.
fix
Run 'npm install remark-lint-spaces-around-word' in your project.
error TypeError: Cannot read properties of undefined (reading 'SpacesAroundWord')
cause Using named import instead of default import.
fix
Use default import: import remarkLintSpacesAroundWord from 'remark-lint-spaces-around-word'
gotcha Plugin only detects missing spaces when English word is surrounded by Chinese characters, not the reverse or other languages.
fix Ensure the English word has Chinese characters on both sides; otherwise the rule may not trigger.
gotcha The plugin does not handle punctuation boundaries; e.g., '中文API。' will warn because of missing space before 'API' even though period follows.
fix Manually review warnings; consider additional processing for punctuation.
npm install remark-lint-spaces-around-word
yarn add remark-lint-spaces-around-word
pnpm add remark-lint-spaces-around-word

Demonstrates how to programmatically use remark-lint-spaces-around-word to lint a Markdown file, showing the process of reading a file, running the plugin, and outputting lint messages.

import { readSync } from 'fs';
import { remark } from 'remark';
import remarkLint from 'remark-lint';
import remarkLintSpacesAroundWord from 'remark-lint-spaces-around-word';
import { reporter } from 'vfile-reporter';

const file = readSync('invalid.md', 'utf8');
const result = remark()
  .use(remarkLint)
  .use(remarkLintSpacesAroundWord)
  .processSync(file);

console.error(reporter(result));