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

Strings consisting '\t' or '\v' not interpreted in YAML #7681

Open
Lord-KA opened this issue Sep 14, 2022 · 5 comments
Open

Strings consisting '\t' or '\v' not interpreted in YAML #7681

Lord-KA opened this issue Sep 14, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@Lord-KA
Copy link
Contributor

Lord-KA commented Sep 14, 2022

When using escaped tab in string, YAML stops interpreting all escaped chars.

  • OS: Linux
  • OS Version: Ubuntu 22
  • Architecture: x86_64

master

Steps to reproduce

Tarantool 2.10.0-beta1-1165-g0b622ac1a
type 'help' for interactive help
tarantool> a = '\t\n\n'
---
...

tarantool> a
---
- "\t\n\n"
...

tarantool> b = '\v\n\n'
---
...

tarantool> b
---
- "\v\n\n"
...

tarantool> c = '\\\n\n'
---
...

tarantool> c
---
- |+
  \

...

Actual behavior

Strings printed in YAML consisting '\t and \v' are not interpreted.

Expected behavior

Strings printed in YAML consisting '\t' and '\v' are interpreted.

@Lord-KA Lord-KA added the bug Something isn't working label Sep 14, 2022
@Totktonada
Copy link
Member

I guess (after a brief reading) that the specification allows both variants. But the goal of JSON and YAML are to be easy to interpret by a human. A human hardly distiguish a sequence of whitespaces from a tab. I think that current behavior (escape a tab) is the best choice.

@Lord-KA
Copy link
Contributor Author

Lord-KA commented Nov 15, 2022

The problem is that we use YAML as default output in console. By definition it should be easy to read as an interface, but here if a module (in my case it was tarantool.compat.dump()) tries to output a complex string for a human to read, like help or some pretty dump, when it uses '\t' to e.g. align something user sees exactly escaped '\t'. I had to use multiple spaces instead and it doesn't seem like a good alternative.

@Totktonada
Copy link
Member

I agree that #3012 would be pretty useful for a prose text (help messages and so on). However I disagree that tab escaping is a problem.

The only known use case is a formatted text within a string, like formatted help message. A tab may be rendered differently (different terminal emulators, text editors, documentation/emails/messaging apps, where the text will be pasted and so on) and it is better to always use whitespaces for formatting.

@Lord-KA
Copy link
Contributor Author

Lord-KA commented Nov 16, 2022

I am not aware of any terminal emulator that interprets '\t' any other way, than several whitespaces. In case of several whitespaces, I think it would be preferable to leave the exact number of those to the renderer.

@Totktonada
Copy link
Member

Several, but how many?

$ echo -e 'foo\tbar\nfoofoof\tbar'
foo	bar
foofoof	bar

This output looks differently in urxvt and in Vim. It also looks differently on GitHub with and without refined-github. There is no one way to show tabs.

$ echo -e 'foo\tbar\nfoofoofo\tbar'
foo	bar
foofoofo	bar

This output doesn't form columns in urxvt, but it is unclear, whether it'll do in other terminals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants