@guineadog/normalize-typography
v0.4.1
Published
CLI tool to replace non-standard typography (smart quotes, dashes) with standard ASCII equivalents
Maintainers
Readme
@guineadog/normalize-typography
A CLI tool to replace non-standard typography with standard ASCII equivalents. It targets common "smart" characters often introduced by word processors or copy-pasting from styled text.
https://www.npmjs.com/package/@guineadog/normalize-typography
What it fixes:
- Dashes: Replaces
—(em dash),–(en dash),‒,―with-. - Double Quotes: Replaces
“and”with". - Single Quotes: Replaces
‘and’with'.
Installation
As a dev dependency (recommended)
It is best to install the tool locally in your project as a dev dependency:
npm install --save-dev @guineadog/normalize-typographyWhy local?
- Easy Automation: You can use the short alias
nrm-tpgrornormalize-typographydirectly in yourpackage.jsonscripts without needingnpx. - Team Consistency: The tool is automatically installed for everyone on the team when they run
npm install. - Version Control: Everyone uses the same version of the tool, preventing "works on my machine" issues.
Run without installation
You can run it directly using npx:
npx @guineadog/normalize-typographyUsage
If installed locally, you can add it to your package.json scripts:
{
"scripts": {
"nrm-tpgr": "normalize-typography",
"nrm-tpgr:check": "nrm-tpgr -- --check"
}
}Then run it using your package manager:
npm run nrm-tpgrResult:
🔍 Searching for non-standard typography (dashes, smart quotes)...
path/fixme.txt ✅ Fixed
fixme.ts ✅ Fixed
ok.ts
✅ Fixed:
path/fixme.txt
fixme.txtCLI Options
You can use the full command normalize-typography or the shortened alias: nrm-tpgr.
Auto-fix everything (respects .gitignore and .prettierignore)
npx @guineadog/normalize-typographyOnly check (lint mode)
npx @guineadog/normalize-typography --checkResult:
🔍 Searching for non-standard typography (dashes, smart quotes)...
path/fixme.txt ❗ Warning: Non-standard typography found.
fixme.ts ❗ Warning: Non-standard typography found.
ok.ts
❗ Warning: Non-standard typography found. Use "npx normalize-typography" to auto-fix it:
path/fixme.txt
fixme.txtSpecific files
npx @guineadog/normalize-typography src/index.js README.mdIf you use lint-staged (https://www.npmjs.com/package/lint-staged)
Add to the lint-staged section in the root package.json. Note: nrm-tpgr alias should be added to the scripts section in the root package.json.
To auto fix files that need to be committed:
"lint-staged": { "*": [ ..., "npm run nrm-tpgr" ], },To check for files that need to be committed (and to prevent committing if non-standard typography is present):
"lint-staged": { "*": [ ..., "npm run nrm-tpgr:check" ], },
Update
To update the tool to the latest version:
Local installation
npm install --save-dev @guineadog/normalize-typography@latestGlobal installation
npm install -g @guineadog/normalize-typography@latestKnown issues
None.
Roadmap
- Add config file (https://github.com/GuineaDog/GuineaDog/issues/4)
- Add the line number and text of the line containing the non-standard typographic characters to be replaced (https://github.com/GuineaDog/GuineaDog/issues/18)
Changelog
See the CHANGELOG for a history of changes.
Contributing
Please refer to the CONTRIBUTING.md file for information on how to report bugs, suggest features, or submit pull requests.
License
This project is licensed under the MIT License.
