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

Terminal links are broken #113

Open
ericbiewener opened this issue Jul 3, 2020 · 1 comment
Open

Terminal links are broken #113

ericbiewener opened this issue Jul 3, 2020 · 1 comment
Labels

Comments

@ericbiewener
Copy link

ericbiewener commented Jul 3, 2020

I'm testing this with the exact test case from this repo:

const { table } = require('table')

const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
const url = 'https://example.com';
const text = 'This is a link to example.com';

const link = [
  OSC,
  '8',
  SEP,
  SEP,
  url,
  BEL,
  text,
  OSC,
  '8',
  SEP,
  SEP,
  BEL
].join('');

console.log(table([[link]]));

Output:

╔═══════════════════════════════╗
║ ttps://example.comThis is a link to exa         ║
║ ttps://exammple.com           ║
╚═══════════════════════════════╝

Additionally, if I change the text variable to be something shorter, i.e. foo, it throws an error:

Error: Subject parameter value width cannot be greater than the container width.
    at alignString (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignString.js:78:11)
    at /Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:27:41
    at Array.map (<anonymous>)
    at /Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:21:18
    at Array.map (<anonymous>)
    at alignTableData (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:20:15)
    at table (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/table.js:102:38)
    at Object.<anonymous> (/Users/ericbiewener/Repos/Walmart/github-api/src/test.js:24:13)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)

From testing, it appears that error gets thrown if text is shorter than url.

I'm using zsh, node v12.2.0, and OSX 10.15.5.

@mizdra
Copy link

mizdra commented Feb 26, 2022

Probably, this problem is caused by slice-ansi problem.

chalk/slice-ansi#31 is not completely fixed, but it seems to be fixed only in the case of no wrapping. This fix has been released in slice-ansi 5.0.0.

Therefore, upgrading the slice-ansi version to 5.0.0 may fix the problem in the no-wrapping case.

On the other hand, slice-ansi 5.0.0 is a Pure ESM. Importing a Pure ESM requires that the importer also be an ESM. To import a Pure ESM, the import source must also be an ESM, i.e., it must wait for the work of #194.


I'm sorry, I have misunderstood something. chalk/slice-ansi#32 was just adding the test.

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

3 participants