Giter Club home page Giter Club logo

unicode-descriptor's Introduction

unicode-descriptor

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

npm version

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.

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

unicode-descriptor's People

Contributors

benedikt-wueller avatar bwuellerlprit avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.