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

Bad column width when printing hyperlinks in terminal #212

Open
juanique opened this issue Mar 22, 2023 · 2 comments
Open

Bad column width when printing hyperlinks in terminal #212

juanique opened this issue Mar 22, 2023 · 2 comments

Comments

@juanique
Copy link

When trying to print hyperlinks in terminal using escape characters, the table width values get messed up and the table renders incorrectly:

package main

import (
	"fmt"
	"os"

	"github.com/olekukonko/tablewriter"
)

func main() {
	table := tablewriter.NewWriter(os.Stdout)
	table.Append([]string{"Ubuntu"})
	table.Render()

	link := fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", "https://ubuntu.com", "Ubuntu")
	table.Append([]string{link})
	table.Render()
}

Output is:

+--------+
| Ubuntu |
+--------+
+------------------------------------+
| Ubuntu                             |
| Ubuntu |
+------------------------------------+

On terminal emulators with hyperlink support, the link actually works (see the underline in screenshot):
image

@petersid2022
Copy link

I encounter the same issue when printing hyperlinks in a table using escape characters. Has this issue been resolved?
If not, is there any workaround to ensure proper rendering of tables with hyperlinks in the terminal?

@colinodell
Copy link

#220 fixes this

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

No branches or pull requests

3 participants