{"id":20826930,"url":"https://github.com/mklement0/nws-cli","last_synced_at":"2025-05-11T22:32:38.227Z","repository":{"id":33720641,"uuid":"37374593","full_name":"mklement0/nws-cli","owner":"mklement0","description":"a Unix CLI for normalizing whitespace in text","archived":false,"fork":false,"pushed_at":"2022-12-27T14:09:44.000Z","size":58,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T07:45:26.210Z","etag":null,"topics":["cli","newline-character-sequences","text-formatting","text-processing","transliteration","unix-cli","whitespace-normalization"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mklement0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-13T14:33:47.000Z","updated_at":"2024-09-22T04:38:25.000Z","dependencies_parsed_at":"2023-01-15T02:12:30.922Z","dependency_job_id":null,"html_url":"https://github.com/mklement0/nws-cli","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2Fnws-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2Fnws-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2Fnws-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2Fnws-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mklement0","download_url":"https://codeload.github.com/mklement0/nws-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225101840,"owners_count":17421082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","newline-character-sequences","text-formatting","text-processing","transliteration","unix-cli","whitespace-normalization"],"created_at":"2024-11-17T23:10:30.258Z","updated_at":"2024-11-17T23:10:31.097Z","avatar_url":"https://github.com/mklement0.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://img.shields.io/npm/v/nws-cli.svg)](https://npmjs.com/package/nws-cli) [![license](https://img.shields.io/npm/l/nws-cli.svg)](https://github.com/mklement0/nws-cli/blob/master/LICENSE.md)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n**Contents**\n\n- [nws \u0026mdash; whitespace normalization](#nws-\u0026mdash-whitespace-normalization)\n- [Examples](#examples)\n  - [Transliteration Examples](#transliteration-examples)\n  - [Condensing Examples](#condensing-examples)\n- [Installation](#installation)\n  - [Installation from the npm registry](#installation-from-the-npm-registry)\n  - [Manual installation](#manual-installation)\n- [Usage](#usage)\n- [License](#license)\n  - [Acknowledgements](#acknowledgements)\n  - [npm dependencies](#npm-dependencies)\n- [Changelog](#changelog)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# nws \u0026mdash; whitespace normalization\n\n`nws` is a Unix CLI that normalizes whitespace in text, offering several modes,\ngrouped into two categories:\n\n* Whitespace _transliteration_ modes:\n\nLine endings can be changed to be Windows- or Unix-specific, and select  \nUnicode whitespace and punctuation can be replaced with their closest ASCII  \nequivalents.\n\n* Whitespace _condensing_ modes:\n\nTrims leading and trailing runs of any mix of tabs and spaces and replaces  \nthem with a single space each. The individual modes in this category differ \nonly with respect to how _multi-line_ input is treated. \n\nInput can be provided either via filename arguments or via stdin.\nOption `-i` offers in-place updating.\n\nSee the examples below, get concise [usage](#usage) information further below,\nor read the [manual](doc/nws.md).\n\n# Examples\n\n## Transliteration Examples\n\n```shell\n# Converts a CRLF line-endings file (Windows) to a LF-only file (Unix).\n# No output is produced, because the file is updated in-place; a backup\n# of the original file is created with suffix '.bak'. \n$ nws --mode lf --in-place=.bak from-windows.txt\n\n# Converts a LF-only file (Unix) to a CRLF line-endings file (Windows).\n# No output is produced, because the file is updated in-place; since no\n# backup suffix is specified, no backup file is created.\n$ nws --crlf -i from-unix.txt\n\n# Converts select Unicode whitespace and punctuation chars. to their \n# closest ASCII equivalents and sends the output to a different file.\n# Note that any other non-ASCII characters are left untouched.\n# Helpful for converting code samples that were formatted for display back to\n# valid source code. \n# IMPORTANT: This only works with properly encoded UTF-8 files.\n$ nws --ascii unicode-punct.txt \u003e ascii-punct.txt \n\n```\n\n## Condensing Examples\n\n * Output from the example commands is piped to `cat -et` to better illustrate the output; `cat -et` shows line endings as `$` (and control chars. as `^M\u003cchar\u003e`; e.g., a tab would show as `^I`).\n\n```shell\n# -- Single-input-line normalization (mode option doesn't apply).\n\n\u003e nws \u003c\u003c\u003c'    I   will   be normalized.   ' | cat -et \nI will be normalized.$\n  # Ditto, but with a mix of spaces and tabs.\n\u003e nws \"$(printf ' I \\t\\t will   be normalized.\\t\\t')\" | cat -et \nI will be normalized.$\n\n# -- Multi-input-line normalizations, using different modes.\n\n  # Create demo file.\n\u003e cat \u003c\u003cEOF \u003e /tmp/nws-demo\n\n    $(printf '\\t')\n  \none\n  two  \n\n   $(printf '\\t')\n\nthree\n\n\nEOF\n\n  # Multi-paragraph mode - by default, or with `--mp` or `-m mp` or \n  # `--mode multi-para`.\n  # In addition to line-internal normalization, \n  # folds runs of blank/empty lines into 1 empty line each.\n$ nws \u003c /tmp/nws-demo | cat -et\n$\none$\ntwo$\n$\nthree$\n$\n\n  # Single-paragraph mode: `--sp` or `-m sp` or `--mode single-para`\n  # In addition to line-internal normalization, \n  # removes all blank/empty lines.\n$ nws --sp \u003c /tmp/nws-demo | cat -et\none$\ntwo$\nthree$\n\n  # Flattened-multi-pargraph mode: `--fp` or `-m fp` or `--mode flat-para`\n  # In addition to line-internal normalization, \n  # joins paragraph-internal lines with a space each.\n$ nws --fp \u003c /tmp/nws-demo | cat -et\n$\none two$\n$\nthree$\n$\n\n  # Single-output-line mode: `sl` or `-m sl` or `--mode single-line`.\n  # In addition to line-internal normalization, \n  # joins all non-empty/non-blank lines with a space each\n  # to form a single, long output line.\n$ nws --sl \u003c /tmp/nws-demo | cat -et\none two three$\n```\n\n# Installation\n\n**Supported platforms**\n\n* When installing from the **npm registry**: **Linux** and **OSX**\n* When installing **manually**: any **Unix-like** platform with **Bash** and **POSIX-compatible utilities**.\n\n## Installation from the npm registry\n\n\u003csup\u003eNote: Even if you don't use Node.js, its package manager, `npm`, works across platforms and is easy to install; try [`curl -L http://git.io/n-install | bash`](https://github.com/mklement0/n-install)\u003c/sup\u003e\n\nWith [Node.js](http://nodejs.org/) or [io.js](https://iojs.org/) installed, install [the package](https://www.npmjs.com/package/nws-cli) as follows:\n\n    [sudo] npm install nws-cli -g\n\n**Note**:\n\n* Whether you need `sudo` depends on how you installed Node.js / io.js and whether you've [changed permissions later](https://docs.npmjs.com/getting-started/fixing-npm-permissions); if you get an `EACCES` error, try again with `sudo`.\n* The `-g` ensures [_global_ installation](https://docs.npmjs.com/getting-started/installing-npm-packages-globally) and is needed to put `nws` in your system's `$PATH`.\n\n## Manual installation\n\n* Download [the CLI](https://raw.githubusercontent.com/mklement0/nws-cli/stable/bin/nws) as `nws`.\n* Make it executable with `chmod +x nws`.\n* Move it or symlink it to a folder in your `$PATH`, such as `/usr/local/bin` (OSX) or `/usr/bin` (Linux).\n\n# Usage\n\nFind concise usage information below; for complete documentation, read the [manual online](doc/nws.md) or,\nonce installed, run `man nws` (`nws --man` if installed manually).\n\n\u003c!-- DO NOT EDIT THE FENCED CODE BLOCK and RETAIN THIS COMMENT: The fenced code block below is updated by `make update-readme/release` with CLI usage information. --\u003e\n\n```nohighlight\n$ nws --help\n\n\nNormalizes whitespace in one of several modes.\n\n    nws [-m \u003cmode\u003e] [[-i[\u003cext\u003e]] file...]\n\n    Condensing \u003cmode\u003es:\n\n    All these modes normalize runs of tabs and spaces to a single space  \n    each and trim leading and trailing runs; they only differ with respect to\n    how multi-line input is processed.\n\n    mp   (default) multi-paragraph: folds multiple blank lines into one\n    fp   flattened multi-paragraph: normalizes each paragraph to single line\n    sp   single-paragraph: removes all blank lines.\n    sl   single-line: normalizes to single output line\n\n    Transliteration \u003cmode\u003es:\n\n    lf     translates line endings to LF-only (\\n)\n    crlf   translates line endings to CRLF (\\r\\n)\n    ascii  translates Unicode whitespace and punctuation to ASCII\n\nAlternatively, specify mode values directly as options; e.g., --sp in lieu  \nof -m sp\n\nStandard options: --help, --man, --version, --home\n```\n\n\u003c!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the contents of 'LICENSE.md'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --\u003e\n\n# License\n\nCopyright (c) 2015-2017 Michael Klement \u003cmklement0@gmail.com\u003e (http://same2u.net), released under the [MIT license](https://spdx.org/licenses/MIT#licenseText).\n\n## Acknowledgements\n\nThis project gratefully depends on the following open-source components, according to the terms of their respective licenses.\n\n[npm](https://www.npmjs.com/) dependencies below have optional suffixes denoting the type of dependency; the *absence* of a suffix denotes a required *run-time* dependency: `(D)` denotes a *development-time-only* dependency, `(O)` an *optional* dependency, and `(P)` a *peer* dependency.\n\n\u003c!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the dependencies from 'package.json'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --\u003e\n\n## npm dependencies\n\n* [doctoc (D)](https://github.com/thlorenz/doctoc)\n* [json (D)](https://github.com/trentm/json)\n* [marked-man (D)](https://github.com/kapouer/marked-man#readme)\n* [replace (D)](https://github.com/harthur/replace)\n* [semver (D)](https://github.com/npm/node-semver#readme)\n* [urchin (D)](https://git.sdf.org/tlevine/urchin)\n\n\u003c!-- DO NOT EDIT THE NEXT CHAPTER and RETAIN THIS COMMENT: The next chapter is updated by `make update-readme/release` with the contents of 'CHANGELOG.md'. ALSO, LEAVE AT LEAST 1 BLANK LINE AFTER THIS COMMENT. --\u003e\n\n# Changelog\n\nVersioning complies with [semantic versioning (semver)](http://semver.org/).\n\n\u003c!-- NOTE: An entry template for a new version is automatically added each time `make version` is called. Fill in changes afterwards. --\u003e\n\n* **[v0.3.4](https://github.com/mklement0/nws-cli/compare/v0.3.3...v0.3.4)** (2017-09-06):\n  * [doc] Clarified that `--mode ascii` (`--asci`) only works with properly encoded UTF-8 files.\n\n* **[v0.3.3](https://github.com/mklement0/nws-cli/compare/v0.3.2...v0.3.3)** (2017-09-05):\n  * [enhancement] Error message for -i mode improved to reflect the count of input files in case the pre-updating check fails; \n                  this is an improvement with potentially batched `xargs`-mediated invocations to at least provide a hint that only\n                  a given _batch_ failed.\n  * [doc] Fixed typo in man page.\n\n* **[v0.3.2](https://github.com/mklement0/nws-cli/compare/v0.3.1...v0.3.2)** (2016-12-11):\n  * [fix] Mode `--crlf` is now idempotent with input that is already CRLF-\n          terminated (previously, an extra CR was mistakenly added).\n\n* **[v0.3.1](https://github.com/mklement0/nws-cli/compare/v0.3.0...v0.3.1)** (2016-12-10):\n  * [doc] Copy-editing in read-me file.\n\n* **[v0.3.0](https://github.com/mklement0/nws-cli/compare/v0.2.0...v0.3.0)** (2016-11-13):\n  * [BREAKING CHANGE] `nws` is now file-based: operands are interpreted as \n    filenames, and option `-i` allows in-place updating. Use stdin to provide\n    strings as input, such as via `echo ... | nws ...`.\n  * [enhancement] New transliteration modes added for changing line-ending\n    styles and for translating non-ASCII Unicode whitespace/punctuation to\n    their closest ASCII equivalents.\n\n* **[v0.2.0](https://github.com/mklement0/nws-cli/compare/v0.1.4...v0.2.0)** (2015-09-18):\n  * [usability improvement] New, mnemonic mode names supersede the old numeric \n    normalization modes (option-arguments for `-m`); mode names come in both\n    short and long forms; similarly, `--mode` is now supported as a verbose\n    alternative to `-m`.\n  * [deprecation] The numeric modes (0..3) still work, but should no longer be\n    used and are no longer documented.\n  * [doc] `nws` now has a man page (if manually installed, use `nws --man`);\n    `nws -h` now just prints concise usage information.\n\n* **[v0.1.4](https://github.com/mklement0/nws-cli/compare/v0.1.3...v0.1.4)** (2015-09-15):\n  * [dev] Makefile improvements; various other behind-the-scenes tweaks.\n\n* **[v0.1.3](https://github.com/mklement0/nws-cli/compare/v0.1.2...v0.1.3)** (2015-06-13):\n  * [doc] Read-me improvements.\n\n* **[v0.1.2](https://github.com/mklement0/nws-cli/compare/v0.1.1...v0.1.2)** (2015-06-13):\n  * [doc] Read-me improvements.\n\n* **[v0.1.1](https://github.com/mklement0/nws-cli/compare/v0.1.0...v0.1.1)** (2015-06-13):\n  * [doc] Read-me improvements.\n\n* **v0.1.0** (2015-06-13):\n  * Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmklement0%2Fnws-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmklement0%2Fnws-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmklement0%2Fnws-cli/lists"}