merge-char
v1.3.4
Published
Algorithms for rendering lines and boxes to plain text
Downloads
3,838
Maintainers
Readme
│ │
│ │ │ │
│ │ │ │ │
│ └─┼─────┼─┐ │ │
└──────────┼┴─┼───┼─┼──┼────┬───┴─
│ │ └┬───┴────┼┐
┌───────┬─┴─┴┴────┼────┐ ││
│ │ │
│
This is tiny, zero-dependency library for merging special characters, based on the official UTF8 tables. This library is mainly useful for overlapping some text on other text, while preserving as much visual information as possible.
const { mergeChar } = require('merge-char')
mergeChar('└', '┘') // results in ┴
mergeChar('a', 'b') // not mergable: will return null
Limitations
Currently the only characters that are supported are the full subset of the UTF8 box drawing characters. Feel free to open a pull request if you'd like to see some other characters supported.
API
isMergable(char)
Checks if given character is mergable with other characters, based on the merging tables.
mergeChars(...chars)
Merges the given characters, returning the merged character if one is found. In
case of failure, null
is returned.