sensiolabs / ansi-to-html

An ANSI to HTML5 converter
MIT License
238 stars 32 forks source link

Does not preserve carriage return #11

Open Theosakamg opened 8 years ago

Theosakamg commented 8 years ago

Console display :

$ ./app/console  project:ota:update
Check if new firmware is available...
Found embeded Firmware for Xxxxx on 0.2.6 (206)

But actualy Html display :

<span style="background-color: black;color: yellow;display: block;">Check if new firmware is available...</span><span style="background-color: black;color: white;display: block;"></span><span style="background-color: black;color: yellow;display: block;">Found embeded Firmware for Xxxxx (heater) on 0.2.6 (206)</span><span style="background-color: black; color: white"></span>

Html should be display :

<span style="background-color: black;color: yellow;">Check if new firmware is available...</span><br/><span style="background-color: black;color: yellow;">Found embeded Firmware for Xxxxx (heater) on 0.2.6 (206)</span>

my code : In ContainerAwareCommand

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<comment>Check if new firmware is available...</comment>');
        $output->writeln("<comment>Found Alfred embeded Firmware for $board  on $ver ($version)</comment>");
    }

In Controller

    public function scanAction()
    {
        $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true );

... Call my command ...

        // return the output
        $converter = new AnsiToHtmlConverter(); //new SolarizedTheme(), true);
        $content = $converter->convert($output->fetch());

        $this->addFlash('sonata_flash_success', "$content");
    }

With :

RichardTMiles commented 3 years ago

I agree this was a tad annoying, though this plugin consistently uses span so this is how I choose to fix this.

preg_replace('##i', '
', (new AnsiToHtmlConverter())->convert(shell_exec('tail -n 25 ' . 'nohup.out'))) :