https://github.com/ryu1kn/multiline-string
Nicer look multiline string in your JavaScript
https://github.com/ryu1kn/multiline-string
multiline-strings npm-package
Last synced: 13 days ago
JSON representation
Nicer look multiline string in your JavaScript
- Host: GitHub
- URL: https://github.com/ryu1kn/multiline-string
- Owner: ryu1kn
- Created: 2018-03-11T07:18:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:46:30.000Z (almost 2 years ago)
- Last Synced: 2025-06-18T18:57:49.909Z (16 days ago)
- Topics: multiline-strings, npm-package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/multiline-string
- Size: 643 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[](https://travis-ci.org/ryu1kn/multiline-string)
[](https://coveralls.io/github/ryu1kn/multiline-string?branch=master)# multiline-string
Remove leading space characters to let you nicely indent your multiline strings in your code.
## Prerequisite
* Node v4+
## Usage
By default, `multiline` detects indentation by looking at the first non-empty line.
Notice that the first empty line is dropped from the output to let you to start
the first line with the indentation level you like.```js
const multiline = require('multiline-string')()const s = multiline(`
1. xxx
a. yyy
2. zzz
`)console.log(s)
// => "1. xxx\n a. yyy\n2. zzz"
```If you want to start your string with an empty line, you can do:
```js
const s = multiline(`Line 1
Line 2
`)
// => "\nLine 1\nLine 2\n"
```You can also give `marginMark` to identify the start of each line
to include indentation in the resulting text.```js
const multiline = require('multiline-string')({ marginMark: '|' })const s = multiline(`
| Usage: my-command file
|
| -v, --version Show version
| -h, --help Show help information
|`)console.log(s)
// => " Usage: ...\n\n -v, --version ..."
```