Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji break wrapWord #180

Open
awensaunders opened this issue Jul 20, 2021 · 4 comments
Open

Emoji break wrapWord #180

awensaunders opened this issue Jul 20, 2021 · 4 comments
Assignees
Labels

Comments

@awensaunders
Copy link

awensaunders commented Jul 20, 2021

Hi there,

If I enable word wrap with columns that have emoji in them, it eats the first letter of the word on the line below... I assume this has something to do with full width calculations.

Example

const table = require("table");

const works = [
  ["Name", "Number"],
  ["Some Text", 24],
  ["Some more text", 22],
  ["I am a reallylong name", 19],
  ["I have a super duperlongname", 18],
];
const doesntwork = [
  ["Name", "Number"],
  ["🥇 Some Text", 24],
  ["🥈 Some more text", 22],
  ["🥉 I am a reallylong name", 19],
  ["I have a super duperlongname", 18],
];

const config = {
  columns: [
    { alignment: "left", width: 15, wrapWord: true },
    { alignment: "right", width: 10, wrapWord: true },
  ],
  header: { alignment: "center", content: "My Table", wrapWord: true },
};
console.log(table.table(works, config));
console.log(table.table(doesntwork, config));

Results

╔══════════════════════════════╗
║           My Table           ║
╟─────────────────┬────────────╢
║ Name            │     Number ║
╟─────────────────┼────────────╢
║ Some Text       │         24 ║
╟─────────────────┼────────────╢
║ Some more text  │         22 ║
╟─────────────────┼────────────╢
║ I am a          │         19 ║
║ reallylong name │            ║
╟─────────────────┼────────────╢
║ I have a super  │         18 ║
║ duperlongname   │            ║
╚═════════════════╧════════════╝

╔══════════════════════════════╗
║           My Table           ║
╟─────────────────┬────────────╢
║ Name            │     Number ║
╟─────────────────┼────────────╢
║ 🥇 Some Text    │         24 ║
╟─────────────────┼────────────╢
║ 🥈 Some more    │         22 ║
║ ext             │            ║
╟─────────────────┼────────────╢
║ 🥉 I am a       │         19 ║
║ eallylong name  │            ║
╟─────────────────┼────────────╢
║ I have a super  │         18 ║
║ duperlongname   │            ║
╚═════════════════╧════════════╝

Do you have any idea how to remedy this?

Thanks for making this library. It's of great use to me 😄

@awensaunders awensaunders changed the title Emoji breaks wordWrap Emoji break wordWrap Jul 20, 2021
@awensaunders awensaunders changed the title Emoji break wordWrap Emoji break wrapWord Jul 20, 2021
@nam-hle nam-hle self-assigned this Jul 20, 2021
@nam-hle nam-hle added the bug label Jul 20, 2021
@nam-hle
Copy link
Collaborator

nam-hle commented Aug 7, 2021

Hi @awensaunders, I tested the output on MacOs and it works fine in various applications: the native terminal, iTerm2, and Intellij IDEA terminal. Can you provide some information about your working environment?

@fullgream
Copy link

I have a similar issue when I save a table in a txt file

@nam-hle
Copy link
Collaborator

nam-hle commented Jan 24, 2022

The library is expected to run and display in monospace output like the terminal. Is it still out of sync if you change to a monospace font?

@gaboroa14
Copy link

Tried a monospace font while dumping the text on a node-canvas and it stills breaks the wrapping, although just a little bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants