ansi-align

WebJar for ansi-align

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

ansi-align
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

ansi-align
WebJar for ansi-align
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/nexdrew/ansi-align

Download ansi-align

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/ansi-align/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>ansi-align</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/ansi-align/
implementation 'org.webjars.npm:ansi-align:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/ansi-align/
implementation ("org.webjars.npm:ansi-align:3.0.0")
'org.webjars.npm:ansi-align:jar:3.0.0'
<dependency org="org.webjars.npm" name="ansi-align" rev="3.0.0">
  <artifact name="ansi-align" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='ansi-align', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "ansi-align" % "3.0.0"
[org.webjars.npm/ansi-align "3.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : string-width jar [3.0.0,4)

Project Modules

There are no modules declared in this project.

ansi-align

align-text with ANSI support for CLIs

Build Status Coverage Status Standard Version Greenkeeper badge

Easily center- or right- align a block of text, carefully ignoring ANSI escape codes.

E.g. turn this:

ansi text block no alignment :(

Into this:

ansi text block center aligned!

Install

npm install --save ansi-align
var ansiAlign = require('ansi-align')

API

ansiAlign(text, [opts])

Align the given text per the line with the greatest string-width, returning a new string (or array).

Arguments

  • text: required, string or array

    The text to align. If a string is given, it will be split using either the opts.split value or '\n' by default. If an array is given, a different array of modified strings will be returned.

  • opts: optional, object

    Options to change behavior, see below.

Options

  • opts.align: string, default 'center'

    The alignment mode. Use 'center' for center-alignment, 'right' for right-alignment, or 'left' for left-alignment. Note that the given text is assumed to be left-aligned already, so specifying align: 'left' just returns the text as is (no-op).

  • opts.split: string or RegExp, default '\n'

    The separator to use when splitting the text. Only used if text is given as a string.

  • opts.pad: string, default ' '

    The value used to left-pad (prepend to) lines of lesser width. Will be repeated as necessary to adjust alignment to the line with the greatest width.

ansiAlign.center(text)

Alias for ansiAlign(text, { align: 'center' }).

ansiAlign.right(text)

Alias for ansiAlign(text, { align: 'right' }).

ansiAlign.left(text)

Alias for ansiAlign(text, { align: 'left' }), which is a no-op.

Similar Packages

  • center-align: Very close to this package, except it doesn't support ANSI codes.
  • left-pad: Great for left-padding but does not support center alignment or ANSI codes.
  • Pretty much anything by the chalk team

License

ISC © Contributors

Versions

Version
3.0.0
2.0.0
1.1.0