https://github.com/keenwon/string-break
Break string into lines according to visual width.
https://github.com/keenwon/string-break
break chinese cli console fixed-width fullwidth string terminal
Last synced: 7 months ago
JSON representation
Break string into lines according to visual width.
- Host: GitHub
- URL: https://github.com/keenwon/string-break
- Owner: keenwon
- License: mit
- Created: 2017-07-17T11:45:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-20T02:22:39.000Z (12 months ago)
- Last Synced: 2025-07-02T08:09:51.835Z (8 months ago)
- Topics: break, chinese, cli, console, fixed-width, fullwidth, string, terminal
- Language: JavaScript
- Homepage:
- Size: 2.98 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# String-Break
[![NPM version][npm-image]][npm-url]
[![Build status][build-status-image]][build-status-url]
[![npm download][download-image]][download-url]
[![Coverage status][codecov-image]][codecov-url]

String-Break 是命令行字符串格式化工具,可以方便的将长字符串按照宽度分段。
特点:
- 支持中文,英文,中英文混排
- 英文不会被截断
- 标点不会出现在行首
## Install
```shell
npm install string-break --save
```
## Usage
```js
const stringBreak = require('string-break');
const str = '远处海港传来阵阵船笛 我一直飘零到被你拣起 如今望著反映窗户玻璃 有个我陌生又熟悉';
let lines = stringBreak(str, 30);
/**
* lines: [
* '远处海港传来阵阵船笛 我一直飘',
* '零到被你拣起 如今望著反映窗户',
* '玻璃 有个我陌生又熟悉'
* ]
*/
```
## License
MIT.
[npm-image]: https://img.shields.io/npm/v/string-break.svg?maxAge=3600
[npm-url]: https://www.npmjs.com/package/string-break
[build-status-image]: https://github.com/keenwon/string-break/workflows/unittest/badge.svg
[build-status-url]: https://github.com/keenwon/string-break/actions
[download-image]: https://img.shields.io/npm/dm/string-break.svg?maxAge=3600
[download-url]: https://npmjs.org/package/string-break
[codecov-image]: https://img.shields.io/codecov/c/github/keenwon/string-break.svg?maxAge=3600
[codecov-url]: https://codecov.io/gh/keenwon/string-break