/[suikacvs]/messaging/manakai/lib/Message/Util/Formatter/Text.pm
Suika

Contents of /messaging/manakai/lib/Message/Util/Formatter/Text.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Sun Oct 10 06:12:11 2004 UTC (21 years, 8 months ago) by wakaba
Branch: MAIN
CVS Tags: before-dis2-200411, manakai-release-0-3-2, manakai-release-0-3-1, manakai-release-0-4-0, manakai-200612, HEAD
Changes since 1.4: +5 -5 lines
Don't warned as uninitialized

1
2 =head1 NAME
3
4 Message::Util::Formatter::Text --- Manakai : Plain-text formatter
5
6 =head1 DESCRIPTION
7
8 This module is an application of Message::Util::Formatter mechanism,
9 used to generate formatted plain text (fragment) with given formatting
10 rule text and formatting functions.
11
12 This module is part of manakai.
13
14 =cut
15
16 package Message::Util::Formatter::Text;
17 use strict;
18 our $VERSION = do{my @r=(q$Revision: 1.4 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
19 require Message::Util::Formatter::Base;
20 our @ISA = 'Message::Util::Formatter::Base';
21
22 sub ___rule_def () {+{
23 -bare_text => {
24 after => sub {
25 my ($self, $name, $p, $o, $key => $val) = @_;
26 $p->{-result} .= $p->{-bare_text};
27 },
28 },
29 -undef => {
30 post => sub {
31 my ($self, $name, $p, $o) = @_;
32 $p->{-result} = qq([undef: $name]);
33 },
34 },
35 -default => {
36 pre => sub {
37 my ($self, $name, $p, $o, %opt) = @_;
38 $p->{-result} = '';
39 $self->call ($name, 'before', $p, $o, %opt);
40 },
41 post => sub {
42 my ($self, $name, $p, $o, %opt) = @_;
43 $self->call ($name, 'after', $p, $o, %opt);
44 if (length $p->{-result}) {
45 $p->{-result} = $p->{prefix} . $p->{-result} if defined $p->{prefix};
46 $p->{-result} .= $p->{suffix} if defined $p->{suffix};
47 }
48 },
49 attr => sub {
50 my ($self, $name, $p, $o, $key, $val, %opt) = @_;
51 if ($key eq '-boolean') {
52 $p->{$val} = 1;
53 } else {
54 if ($opt{-value_flag} and index ($opt{-value_flag}, 'p') > -1) {
55 $val = $self->replace ($val, param => $o);
56 }
57 $p->{$key} = $val;
58 }
59 },
60 before => sub {
61 },
62 after => sub {
63 },
64 },
65 -entire => {
66 pre => sub {
67 my ($self, $name, $p, $o) = @_;
68 $p->{-result} = '';
69 },
70 attr => sub {
71 my ($self, $name, $p, $o, $key => $val) = @_;
72 $p->{-result} .= $val->{-result};
73 },
74 },
75 percent => {
76 after => sub {
77 my ($self, $name, $p, $o) = @_;
78 $p->{-result} = '%';
79 },
80 },
81 }}
82
83 =head1 LICENSE
84
85 Copyright 2003 Wakaba <w@suika.fam.cx>
86
87 This program is free software; you can redistribute it and/or
88 modify it under the same terms as Perl itself.
89
90 =cut
91
92 1; # $Date: 2003/12/06 05:09:39 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24