Skip to content

Emoji break wrapWord #180

@awensaunders

Description

@awensaunders

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 😄

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions