Home PHP Libraries Other libraries ANSI to HTML5 library
ANSI to HTML5 library
<?php
namespace SensioLabs\AnsiConverter\Tests;
use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
class AnsiToHtmlConverterTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getConvertData
     */
    public function testConvert($expected, $input)
    {
        $converter = new AnsiToHtmlConverter();
        $this->assertEquals($expected, $converter->convert($input));
    }
    public function getConvertData()
    {
        return array(
            // text is escaped
            array('<span style="background-color: black; color: white">foo <br /></span>', 'foo <br />'),
            // newlines are preserved
            array("<span style=\"background-color: black; color: white\">foo\nbar</span>", "foo\nbar"),
            // backspaces
            array('<span style="background-color: black; color: white">foo   </span>', "foobar\x08\x08\x08   "),
            array('<span style="background-color: black; color: white">foo</span><span style="background-color: black; color: white">   </span>', "foob\e[31;41ma\e[0mr\x08\x08\x08   "),
            // color
            array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[0m"),
            // color with [m as a termination (equivalent to [0m])
            array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[m"),
            // bright color
            array('<span style="background-color: red; color: red">foo</span>', "\e[31;41;1mfoo\e[0m"),
            // carriage returns
            array('<span style="background-color: black; color: white">foobar</span>', "foo\rbar\rfoobar"),
            // underline
            array('<span style="background-color: black; color: white; text-decoration: underline">foo</span>', "\e[4mfoo\e[0m"),
            // non valid unicode codepoints substitution (only available with PHP >= 5.4)
            PHP_VERSION_ID < 50400 ?: array('<span style="background-color: black; color: white">foo '."\xEF\xBF\xBD".'</span>', "foo \xF4\xFF\xFF\xFF"),
        );
    }
}

ANSI is a character code. In order to enable the computer to support more languages, 1 byte in the range of 0x00~0x7f is usually used to represent 1 English character. Anything outside this range is encoded using 0x80~0xFFFF, which is extended ASCII encoding.

HTML is Hypertext Markup Language, an application under Standard Universal Markup Language. "Hypertext" means that the page can contain pictures, links, and even non-text elements such as music and programs. The structure of hypertext markup language includes a "head" part (English: Head) and a "body" part (English


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Solutions to conflicts between jQuery library and other JS libraries_jquery Solutions to conflicts between jQuery library and other JS libraries_jquery

16 May 2016

Solutions to conflicts between jQuery library and other JS libraries

Use jquery.noConflict() to solve the problem of conflicts between jquery library and other libraries Use jquery.noConflict() to solve the problem of conflicts between jquery library and other libraries

20 Jun 2017

When developing with jQuery, you may also use other JS libraries, such as Prototype, but conflicts may occur when multiple libraries coexist; if conflicts occur, you can solve them through the following solutions: 1. jQuery libraries in other Import the library before and use the jQuery (callback) method directly such as:

What to do about jQuery library conflicts What to do about jQuery library conflicts

11 Jan 2018

When developing with jQuery, you may also use other JS libraries, such as Prototype, but conflicts may occur when multiple libraries coexist. This article mainly introduces you to the perfect solution to jQuery library conflicts. Friends who need it can refer to it. For reference, let’s take a look below.

How to resolve $naming conflicts between Jquery library and other libraries_jquery How to resolve $naming conflicts between Jquery library and other libraries_jquery

16 May 2016

This article introduces the solution to the $ naming conflict between the Jquery library and other libraries. Friends in need can refer to it.

Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries) Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries)

30 Sep 2016

Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries)~~ It mainly needs to have search functions, especially file classification retrieval/file tag retrieval functions, no need for online conversion, online browsing!

Someone asked, how to find a suitable Python library? Someone asked, how to find a suitable Python library?

12 Apr 2023

Finding a suitable Python library is actually very simple. Follow the following three steps and you can find 90% of Python libraries. 1. Search on Baidu and Google to clarify your needs and what to use Python for, and strive to be brief and clear. For example, if you locate "data analysis" and then search for the keywords [Python + data analysis + third-party libraries], there will be many third-party libraries recommended by blogs about data analysis. This is also the way most people find Python libraries, and it is also the simplest. Methods. Search out other people’s experience posts to see if it suits you. However, this method is sometimes difficult to search accurately, and many unpopular libraries have little content, so search engines naturally cannot crawl the library you want. If you can't find the library you want through searching, you have to use the

See all articles