line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###############################################################################
|
2
|
|
|
|
|
|
|
#unparsed.pm
|
3
|
|
|
|
|
|
|
#Last Change: 2009-02-09
|
4
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
5
|
|
|
|
|
|
|
#Version 0.2
|
6
|
|
|
|
|
|
|
####################
|
7
|
|
|
|
|
|
|
#This file is an addon to the Dotiac::DTL project.
|
8
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
9
|
|
|
|
|
|
|
#
|
10
|
|
|
|
|
|
|
#unparsed.pm is published under the terms of the MIT license, which basically
|
11
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
12
|
|
|
|
|
|
|
#license.txt file that should be enclosed with libsofu distributions. A copy of
|
13
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
14
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
15
|
|
|
|
|
|
|
###############################################################################
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Dotiac::DTL::Addon::markup;
|
19
|
1
|
|
|
1
|
|
402241
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
20
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
21
|
1
|
|
|
1
|
|
20
|
use Text::Textile;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
22
|
1
|
|
|
1
|
|
5
|
use Text::Markdown;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
23
|
1
|
|
|
1
|
|
6
|
use File::Temp qw/ :POSIX /;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
221
|
|
24
|
|
|
|
|
|
|
#use Text::Restructured;
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#If it is not already loaded.
|
27
|
|
|
|
|
|
|
require Dotiac::DTL::Filter;
|
28
|
|
|
|
|
|
|
require Dotiac::DTL::Value;
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION=0.2;
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $oldmarkdown;
|
35
|
|
|
|
|
|
|
my $oldtextile;
|
36
|
|
|
|
|
|
|
my $oldrest;
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub import {
|
39
|
1
|
|
|
1
|
|
6
|
no warnings qw/redefine/;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
167
|
|
40
|
12
|
|
|
12
|
|
20453
|
$oldrest = *{Dotiac::DTL::Filter::restructuredtext};
|
41
|
12
|
|
|
|
|
31
|
$oldmarkdown = *{Dotiac::DTL::Filter::markdown};
|
42
|
12
|
|
|
|
|
33
|
$oldtextile = *{Dotiac::DTL::Filter::textile};
|
43
|
12
|
|
|
|
|
29
|
*{Dotiac::DTL::Filter::restructuredtext}=\&restructuredtext;
|
44
|
12
|
|
|
|
|
26
|
*{Dotiac::DTL::Filter::markdown}=\&markdown;
|
45
|
12
|
|
|
|
|
27
|
*{Dotiac::DTL::Filter::textile}=\&textile;
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
sub unimport {
|
49
|
1
|
|
|
1
|
|
6
|
no warnings qw/redefine/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
194
|
|
50
|
12
|
|
|
12
|
|
48746
|
*{Dotiac::DTL::Filter::restructuredtext} = $oldrest;
|
51
|
12
|
|
|
|
|
25
|
*{Dotiac::DTL::Filter::markdown} = $oldmarkdown;
|
52
|
12
|
|
|
|
|
35
|
*{Dotiac::DTL::Filter::textile} = $oldtextile;
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub markdown {
|
56
|
4
|
|
|
4
|
1
|
277
|
my $val=shift;
|
57
|
4
|
|
|
|
|
20
|
return Dotiac::DTL::Value->safe(Text::Markdown::markdown($val->repr()));
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
sub textile {
|
60
|
4
|
|
|
4
|
1
|
329
|
my $val=shift;
|
61
|
4
|
|
|
|
|
18
|
return Dotiac::DTL::Value->safe(Text::Textile::textile($val->repr()));
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
sub restructuredtext {
|
64
|
0
|
|
0
|
0
|
1
|
|
return eval {
|
65
|
1
|
|
|
1
|
|
6
|
no warnings qw/redefine/;
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
346
|
|
66
|
|
|
|
|
|
|
my $w=$^W;
|
67
|
|
|
|
|
|
|
$^W=0;
|
68
|
|
|
|
|
|
|
require Text::Restructured::Writer;
|
69
|
|
|
|
|
|
|
require Text::Restructured::DOM;
|
70
|
|
|
|
|
|
|
require File::Temp; #Has to be installed by Dotiac::DTL
|
71
|
|
|
|
|
|
|
my $writer = new Text::Restructured::Writer('html',{w=>'html',d=>0,D=>{}});
|
72
|
|
|
|
|
|
|
my $value=shift;
|
73
|
|
|
|
|
|
|
$value=$value->repr;
|
74
|
|
|
|
|
|
|
my $dom;
|
75
|
|
|
|
|
|
|
if ($value =~ /^
|
76
|
|
|
|
|
|
|
$dom = Text::Restructured::DOM::Parse($value, {w=>'html',d=>0,D=>{}});
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
else {
|
79
|
|
|
|
|
|
|
require Text::Restructured;
|
80
|
|
|
|
|
|
|
my $rst_parser = new Text::Restructured({w=>'html',d=>0,D=>{}}, "1 release 1");
|
81
|
|
|
|
|
|
|
$dom = $rst_parser->Parse($value, tmpnam());
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
my $x=$writer->ProcessDOM($dom);
|
84
|
|
|
|
|
|
|
$^W=$w;
|
85
|
|
|
|
|
|
|
$x=substr $x,index($x,"")+6;
|
86
|
|
|
|
|
|
|
$x=substr $x,0,index($x," |
87
|
|
|
|
|
|
|
return Dotiac::DTL::Value->safe($x);
|
88
|
|
|
|
|
|
|
} || Dotiac::DTL::Value->safe("");
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1;
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__
|