-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Upgrade word wrapping in SymfonyStyle #30519
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
Conversation
The original word wrapping method got sometimes ugly outputs because of formatter tags: <comment>, <info>, etc. The new solution skips these tags from the line lengths.
can you provide some code / console output that lead to this fix? I tend to believe it's a new feature instead, where we would preserve raw formatting. Not sure createBlock() should try that, as it's not really supported to use nested markup here (given the block itself uses markup); or at least is interpreted as raw text. cc @chalasr |
Hello @ro0NL ,
I have a command with longer and detailed help texts with many colored words or signs to be readable, eg: The output was really ugly sometimes because of many "hidden" formatter tags, the length of lines were very changing.
I changed only the original |
createBlock() is private and has an escape flag, i assume you either use e.g. ive added formatted text wrapping in #22225, perhaps we can use it here? and render the result as-is (OUTPUT_RAW), sounds more simple :D for the case with escaping, e.g. |
Is there anybody who knows what the problem could be here? https://travis-ci.org/symfony/symfony/jobs/504759370 I can see that one test is failed, but it should be good, it works fine at me and on 7.2 also. It looks like that
I looked at this, and yes, it could be good. As I can see I should refactor everywhere the <?php
// test.php
$string = 'őúáű';
$simple = strlen($string);
$mb = mb_strlen($string);
printf("String: %s\nSimple: %d\nMB: %d", $string, $simple, $mb); # PHP 5.6
$ docker run --rm --volume $PWD:/app --workdir /app php:5.6-cli php test.php
String: őúáű
Simple: 8
MB: 4
# PHP 7.2
$ docker run --rm --volume $PWD:/app --workdir /app php:7.2-cli php test.php
String: őúáű
Simple: 8
MB: 4 |
for the UTF related issue, would it be better to create a separate PR?
based on the amount of code here (and a new feature (breaking tags) of which im not sure we need it) i would prefer that route. |
Yes, I agree with this.
It isn't clear exactly for me. Which route do you prefer? |
using I think even we dont need to change the OUTPUT_ type, using OUTPUT_NORMAL will preserve existing formatted text i expect. |
OK, but it is only available from |
@ro0NL Oh, I have just seen that the
It could be OK in shorter place (<30 chars, eg: table cell), but it isn't same what I made. |
i think we should first focus on correct rendering (not breaking visual output). Then later on we can try to patch formatAndWrap to be more clever concerning 'word breaks' (but never exceed the max width; so worst case we would still chop up words, or more clever with a dash |
The original word wrapping method got sometimes ugly outputs because of formatter tags:
<comment>
,<info>
, etc. The new solution skips these tags from the line lengths, and usesmb_*()
functions to handle strings/words.