| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
MKDoc::Text::Structured - Another Text to HTML module |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $text = some_structured_text(); |
|
9
|
|
|
|
|
|
|
my $html = MKDoc::Text::Structured::process ($text); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SUMMARY |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
L is a library which allows simple syntaxic |
|
15
|
|
|
|
|
|
|
text construct to be turned into HTML. These constructs are the ones |
|
16
|
|
|
|
|
|
|
you would be using when writing a text email or newsgroup message. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
L follows the KISS philosophy. Comparing with |
|
19
|
|
|
|
|
|
|
similar modules which try to implement as many HTML constructs as possible, |
|
20
|
|
|
|
|
|
|
this module is incredibly conservative. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
package MKDoc::Text::Structured; |
|
24
|
20
|
|
|
20
|
|
742714
|
use MKDoc::Text::Structured::Factory; |
|
|
20
|
|
|
|
|
64
|
|
|
|
20
|
|
|
|
|
559
|
|
|
25
|
20
|
|
|
20
|
|
102
|
use strict; |
|
|
20
|
|
|
|
|
39
|
|
|
|
20
|
|
|
|
|
562
|
|
|
26
|
20
|
|
|
20
|
|
100
|
use warnings; |
|
|
20
|
|
|
|
|
40
|
|
|
|
20
|
|
|
|
|
6716
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $Text = ''; |
|
29
|
|
|
|
|
|
|
our $VERSION = 0.83; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub process |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
85
|
|
|
85
|
0
|
60664
|
my $text = shift; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Mac + DOS carriage returns -> bang! |
|
37
|
85
|
|
|
|
|
254
|
$text =~ s/\r\n/\n/gs; |
|
38
|
85
|
|
|
|
|
167
|
$text =~ s/\r/\n/gs; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Trailing spaces -> fizzle! |
|
41
|
|
|
|
|
|
|
# (except when the line is made only of trailing spaces...) |
|
42
|
239
|
|
|
|
|
522
|
$text = join "\n", map { |
|
43
|
85
|
|
|
|
|
378
|
chomp(); |
|
44
|
239
|
100
|
|
|
|
1652
|
s/\s+$// unless (/^\s*$/); |
|
45
|
239
|
|
|
|
|
674
|
$_; |
|
46
|
|
|
|
|
|
|
} split /\n/, $text; |
|
47
|
|
|
|
|
|
|
|
|
48
|
85
|
|
|
|
|
464
|
my @lines = split /\n/, $text; |
|
49
|
85
|
|
|
|
|
164
|
my @result = (); |
|
50
|
85
|
|
|
|
|
123
|
my $current = undef; |
|
51
|
|
|
|
|
|
|
|
|
52
|
85
|
|
|
|
|
241
|
while (scalar @lines) |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
272
|
|
|
|
|
531
|
my $line = shift (@lines); |
|
55
|
272
|
|
100
|
|
|
1462
|
$current ||= MKDoc::Text::Structured::Factory->new ($line); |
|
56
|
272
|
100
|
|
|
|
626
|
$current || next; |
|
57
|
|
|
|
|
|
|
|
|
58
|
248
|
100
|
|
|
|
693
|
if ($current->is_ok ($line)) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
215
|
|
|
|
|
758
|
$current->add_line ($line); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
else |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
33
|
|
|
|
|
132
|
push @result, $current->process(); |
|
65
|
33
|
|
|
|
|
81
|
unshift (@lines, $line); |
|
66
|
33
|
|
|
|
|
359
|
$current = undef; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
85
|
50
|
|
|
|
13381
|
push @result, $current->process() if ($current); |
|
71
|
85
|
|
|
|
|
1104
|
return join "\n", @result; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |