A javascript/node library for creating text descriptions using unicode border symbols.
Install the package using npm/yarn:
npm install unicode-descriptor
# or
yarn add unicode-descriptor
The built library lies in dist/unicode-descriptor.js
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
You can pass a configuration object to the constructor of the descriptor.
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
Type: object
Contains the characters to be used. The following table contains the required and default values.
Key | Description | Default Value |
---|---|---|
hl |
Horizontal Line | ─ |
vl |
Vertical Line | │ |
ctl |
Corner Top Left | ┘ |
ctr |
Corner Top Right | └ |
tt |
T-Top | ┴ |
tb |
T-Bottom | ┬ |
tr |
T-Right | ├ |
tl |
T-Left | ┤ |
cross |
Cross | ┼ |
Example with intersecting sections:
Lorem ipsum dolor sit amet
╘╤════│═══╛ ╘╤══│════════╛
│ ╘╤═════│══╛
│ │ ╘═ Section C
│ ╘═══════ Section B
╘═════════════ Section A