1.0.3 • Published 5 years ago

unicode-descriptor v1.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

unicode-descriptor

A javascript/node library for creating text descriptions using unicode border symbols.

Demo

Demo Tool (Source Code)

Getting Started

Install the package using npm/yarn:

npm install unicode-descriptor
# or
yarn add unicode-descriptor

The built library lies in dist/unicode-descriptor.js

Usage

Note: Some sites (like npmjs.com) use a monospace font which does not support the standard unicode box-drawing characters correctly. Because of that, the examples may be misaligned.

var descriptor = new UnicodeDescriptor();

descriptor.addSection(0, 5, 'Section A');
descriptor.addSection(6, 5, 'Section B');
descriptor.addSection(12, 5, 'Section C');

console.log(descriptor.toString());

Result:

Lorem ipsum dolor
└┬──┘ └┬──┘ └┬──┘
 │     │     └─ Section C
 │     └─────── Section B
 └───────────── Section A

Configuration

You can pass a configuration object to the constructor of the descriptor.

indentLabels

Type: boolean

Determines whether to indent the labels to the right. Defaults to true. If set to false, the labels will be displayed in a single line if possible.

https://github.benedikt.dev
└┬─────┘└┬────┘└┬──────┘└┬┘
 │       │      │        Top-level domain
 │       │      Domain name
 │       Subdomain
 Protocol
This statement is false. This is another sentence.
└┬─────────────────────┘ └┬──────────────────────┘
 Paradox                  Not a paradox

characters

Type: object

Contains the characters to be used. The following table contains the required and default values.

KeyDescriptionDefault Value
hlHorizontal Line
vlVertical Line
ctlCorner Top Left
ctrCorner Top Right
ttT-Top
tbT-Bottom
trT-Right
tlT-Left
crossCross

Example with intersecting sections:

Lorem ipsum dolor sit amet
╘╤════│═══╛ ╘╤══│════════╛
 │    ╘╤═════│══╛
 │     │     ╘═ Section C
 │     ╘═══════ Section B
 ╘═════════════ Section A
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago