<?php function ansiSafeWrapper(string $string, int $max = 80) { return preg_replace( "~(?=(?:(?:\\\\x1b\[[0-9;]+m)?.){{$max}})(?:(?:\\\\x1b\[[0-9;]+m)?.){0,$max}\K ~u", PHP_EOL, str_replace(PHP_EOL, ' ', $string) ); } $test = <<<'ANSI' Morbi leo risus, \x1b[34;1mporta ac consectetur\x1b[39;22m ac, vestibulum at eros. Aenean lacinia bibendum nulla sed consectetur. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Curabitur blandit tempus porttitor. ANSI; echo ansiSafeWrapper($test);
You have javascript disabled. You will not be able to edit any code.