Term::ANSIColor::Markup - Colorize tagged strings for screen output


Term-ANSIColor-Markup documentation  | view source Contained in the Term-ANSIColor-Markup distribution.

Index


NAME

Top

Term::ANSIColor::Markup - Colorize tagged strings for screen output

SYNOPSIS

Top

  use Term::ANSIColor::Markup;

  my $text = qq{aaa<red>bbb<bold>ccc</bold>ddd<black><on_yellow>eee</on_yellow></black>fff</red> &gt; ggg};

  my $parser = Term::ANSIColor::Markup->new;
  $parser->parse($text);
  print $parser->text;

  # or just call colorize method this way:

  print Term::ANSIColor::Markup->colorize($text);

DESCRIPTION

Top

Term::ANSIColor::Markup provides a simple and friendly way to colorize screen output; You can do it using HTML-like tags.

You can use the same names for tag names as ones Term::ANSIColor provides. See the documentation of Term::ANSIColor to get to know what names you can use.

METHODS

Top

new ()

  my $parser = Term::ANSIColor::Markup->new;

Creates and returns a new Term::ANSIColor::Markup object.

parse ( $text )

  $parser->parse($text);

Parses given $text. If start tag and end tag aren't correspondent with each other, this method croaks immediately.

Note that "<" and ">" which are not part of tags must be escaped into "&lt;" and "&gt;".

text ()

  print $parser->text;

Returns parsed text.

colorize ($text)

  print Term::ANSIColor::Markup->colorize($text);

Returns parsed text in just one way.

REPOSITORY

Top

https://github.com/kentaro/perl-term-ansicolor-markup/tree

SEE ALSO

Top

* TermColor

The idea, converts tagged string to colorized one for term, was borrowed from http://github.com/jugyo/termcolor/tree/master

* Term::ANSIColor

You might want to consult the documentation of Term::ANSIColor to get to know what tags you can use.

AUTHOR

Top

Kentaro Kuribayashi <kentaro@cpan.org>

SEE ALSO

Top

COPYRIGHT AND LICENSE (The MIT License)

Top


Term-ANSIColor-Markup documentation  | view source Contained in the Term-ANSIColor-Markup distribution.