-
Notifications
You must be signed in to change notification settings - Fork 44
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
Link as hyperlink in terminal doesn't render correctly #73
Comments
Hi, can you provide a small reproducible test case? |
The problem above is caused when cli-table3 truncates the content. Here is a small code to reproduce the problem (tested in iTerm2). const Table = require('cli-table3')
function hyperlink(url = '', text = 'link') {
const OSC = '\u001B]'
const BEL = '\u0007'
const SEP = ';'
return [
OSC,
'8',
SEP,
SEP,
url,
BEL,
text,
OSC,
'8',
SEP,
SEP,
BEL
].join('')
}
const link = hyperlink('https://www.example.com', 'example')
const table1 = new Table({
head: ['Wide Column'],
colWidths: [100]
})
table1.push([link])
console.log(table1.toString())
const table2 = new Table({
head: ['Narrow Column'],
colWidths: [25]
})
table2.push([link])
console.log(table2.toString()) If I comment I'm trying to figure out how I can fix the spacing... any tips? |
@matheussampaio the Poc has released yet? or whren? |
@ElsaOOo PRs are very welcome. |
Any plans to support hyperlinks inside the table? Currently, I use a workaround where a hyperlink is placed in the last table column and the table itself is rendered without borders. This is the only way to hide incorrectly drawn borders. |
Just reviewing this. There is not enough info to attempt to reproduce @hamxabaig's reported issue. (Thanks for the lead to terminal-link!) I cannot reproduce @matheussampaio's spacing issue. When I run the code I get: @matheussampaio's POC is confusing in that it uses the text as display text. But it highlights the dichotomy between display text and displaying the url. For cli-table3 to [conveniently] support hyperlinks I do believe it needs to be embedded so that cli-table3 can control the output of the display text (whether it be the URL or otherwise). In the event hyperlinks are not supported by the output target (Eg. stdout), it should probably fallback to the link (and potentially avoid truncation with the new Something like this is what I'd have in mind prima facie:
If/when I dive into this, I'll likely open a new issue as a feature request. |
Hyperlinks will be supported in the next release (v0.6.2)! The interface is simple:
Link text is wrapped, truncated, etc. as usual but when the text of a cell spans multiple lines, each link is wrapped with the link. The solution basically mimics matheussampaio's POC but cleans up the Cell API slightly as a small step toward refactoring cells for better performance. |
* Failing tests for hyperlink support * Add hyperlink support for cells (#73) * Add hyperlink example to basic usage docs
Hey there, I tried all versions of
cli-table
i-ecli-table1
,cli-table2
&cli-table3
. All of them doesn't render the link properly.This is the library i'm using terminal-link: Create clickable links in the terminal When i log it without
cli-table3
it renders the link correctly. But when used inside the columns ofcli-table
it doesn't render it and mess up the table borders. (Check the pic)What do you think can be an issue? I think
cli-table
is encoding the column's content which mess up the encoding provided byterminal-link
?(90m should suppose to be the link) I'm using
iterm2
The text was updated successfully, but these errors were encountered: