-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
console.table text alignment always centered #50117
Comments
Seems interesting. As per the MDN docs, the table is left aligned. https://developer.mozilla.org/en-US/docs/Web/API/console/table . So, we need a fix here. However, had a look into the current implementation, and If we can expose a
Need a discussion and happy to fix/add feature this. |
Yeah I am +1 this as we use usually table() to show the results in tinybench. And because it is centered, it looks unreadable. Also configuring the the alignment makes sense, as usually you want to align text to the left and numbers to the right (see excel). But aligning is not documented in mdn. Are we allowed to deviate? |
We should not be deviated from the JS standards. |
There is no real standard |
We should also think about RTL languages, it's been years since the last time I've opened Excel but I'm pretty sure it aligns text to the left only for LTR text. The upside of using center align is that we don't need to think about it. console.table([
'طنجة',
'تطوان',
'القصر الكبير',
'Larache',
'الفنيدق'
]) |
Does node have a bidi implentation? I used years ago bidi implentation by @ashensis in jspdf Also what happens if you use arabic ligatures? Like لا ? This can open up a big hornet nest of issues... |
Is this a question to this PR or a general discussion? Please feel free to start a new one in the discussion tab, or raise a new issue with your questions please. So, reviewers will not be confused. |
It is not a question and not a general discussion. It is an answer to @aduh95 . |
Did you try when the system lang is set to a RTL language? |
There are a lot of interrogation points in your comment, which I think is why it was interpreted as a question rather than a answer. FWIW I think we simply pass Unicode characters to stdout and let the terminal deal with it (I'm just guessing here, I haven't looked at the code). |
Make sense. Sure. Let's wait for RTL users. |
Just to understand where this is going: does Node.js already output its prompt on the right side when started with an RTL locale? Or are you trying to correctly display RTL languages in a tabular output while the Node.js REPL is not capable of RTL output, anyway? |
PR-URL: nodejs#50135 Fixes: nodejs#50117 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Version
v18.17.1
Platform
Linux nucke 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
internal/cli_table.js
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
What do you see instead?
Additional information
The centered content in the table makes output harder to read and counteracts the idea of using a table to display structured data.
A real-world example:
It is also not clear why the Node.js implementation differs from those in current browsers:
Edge:
Firefox:
The text was updated successfully, but these errors were encountered: