Coder Social home page Coder Social logo

Comments (3)

jamestalmage avatar jamestalmage commented on May 28, 2024

I'd have to review, but I believe in cli-table2 it's a pretty naive implementation that does a merge of the default config, the table config, the the cell config using merge (listed in order of increasing importance).

The way cli-table works is that each cell is responsible for rendering it's own top and left edges. Only cells in the last column render their right edge. Only cells in the last row render their bottom edge. This does not make for very convenient custom characters at the cell level. If you want to change the bottom / right edge of a particular cell, you actually need to find the neighbor responsible for that and set the value there. It would be better if, when deciding what character to use for it's own left edge, a cell checked first for a custom left character in it's own config, if not, check for a custom right character in the config of it's neighbor, and followed by the left character as configured at the table level, followed by the default.

Corners get even more interesting (who gets to take precedence).

I'm not sure how necessary "custom chars" really are. It might be better just to offer the ability to make certain lines "double" or "heavy".

box-chars

box-chars helps pick the correct character for a given edge or intersection

For a standard top left corner character (a character that points down, and to the right), you find it as follows:

var box = require('box-chars');

var left = box.NOTHING;    // nothing pointing to the left from top-left corner
var right = box.LIGHT;     // other options are HEAVY or DOUBLE
var up = box.NOTHING;      // nothing pointing up
var down = box.LIGHT;

box(left, right, up, down);
//=> โ”Œ

for situations that do not exist (i.e. right=LIGHT, left=DOUBLE), it picks a sensible default (DOUBLE, DOUBLE in that case).

box-chars is not documented, but it is well tested.

from table.

jamestalmage avatar jamestalmage commented on May 28, 2024

@gajus
Added you as collaborator on box-chars, if you think it's worthwhile for table, run with it. I haven't touched it in a while

from table.

gajus avatar gajus commented on May 28, 2024

I thought about this and consider this feature to be too much of an edge case. Very few packages will use this feature and it will add a considerable level of complexity to the existing code. As such, it will not be implemented.

from table.

Related Issues (20)

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.