NAME
HTML::FromANSI - Mark up ANSI sequences as HTML
SYNOPSIS
use HTML::FromANSI;
use Term::ANSIColor;
$HTML::FromANSI::Options{fill_cols} = 1; # fill all 80 cols
print ansi2html(color('bold blue'), "This text is bold blue.");
DESCRIPTION
This small module converts ANSI text sequences to corresponding HTML codes, using stylesheets to control color and blinking properties.
It exports ansi2html()
by default, which takes an array, joins it it into a single scalar, and returns its HTML rendering.
From version 0.99 and above, this module has been changed to use the excellent Term::VT102 module, so cursor movement and other terminal control codes are properly handled.
If you want to generate these movement codes in perl, please take a look at my Term::ANSIScreen module.
OPTIONS
There are various options stored in the %HTML::FromANSI::Options
hash; you can also import it explicitly from the use
line. Below are brief description of each option:
- linewrap
-
A boolean value to specify whether to wrap lines that exceeds width specified by
col
, or simply truncate them. Defaults to1
. - lf_to_crlf
-
A boolean value to specify whether to translate all incoming \n into
\r\n
or not; you generally wants to use this if your data is from a file using unix line endings. The default is0
on MSWin32 and MacOS, and1
on other platforms. - fill_cols
-
A boolean value to specify whether to fill empty columns with space; use this if you want to maintain a screen-like appearance in the resulting HTML, so that each row will be aligned properly. Defaults to
0
. - html_entity
-
A boolean value to specify whether to escape all high-bit characters to HTML entities or not; defaults to
0
, which means only<
,>
,"
and&
will be escaped. (Handy when processing most ANSI art entries.) - cols
-
A number specifying the width of the virtual terminal; defaults to 80.
- rows
-
A number specifying the height of the virtual terminal; rows that exceeds this number will be truncated. If left unspecified, it will be recalculated automatically on each
ansi2html
invocation, which is probably what you want in most cases. - font_face
-
A string used as the
face
attribute to thefont
tag enclosing the HTML text; defaults tofixedsys, lucida console, terminal, vga, monospace
.If this option and the
style
option are both set to empty strings, thefont
tag will be omitted. - style
-
A string used as the
style
attribute to thefont
tag enclosing the HTML text; defaults to <line-height: 1; letter-spacing: 0; font-size: 12pt>.If this option and the
font_face
option are both set to empty strings, thefont
tag will be omitted. - tt
-
A boolean value specifying whether the HTML text should be enclosed in a
tt
tag or not. Defaults to1
.
SEE ALSO
Term::VT102, HTML::Entities, Term::ANSIScreen
AUTHORS
Autrijus Tang <autrijus@autrijus.org>
COPYRIGHT
Copyright 2001, 2002 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 228:
You forgot a '=back' before '=head1'