aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/ReST.pm
blob: bd43528e3b22c591085b0fc5ef9698f846566506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package WebCoso::ReST; 
use strict;
use warnings;
use WebCoso::Common;
use Path::Class;
use Text::Restructured;
use Text::Restructured::Writer::LibXML;
 
sub new {
    my ($class,%opts)=@_;
 
    my $self={%opts};
 
    $self->{rest}=Text::Restructured->new(
        {
            D=>{
                'file-insertion-enabled'=>0, # we use TT 
                generator=>0,
                date=>0,
                'time'=>0,
                'source-link'=>0,
                'section-subtitles'=>1,
            },
        },
        'WebCoso');
 
    $self->{fc}->add_parser(qr{\.rest\.txt$} =>
                                sub {
                                    my $dudom=$self->{rest}->Parse($_[1],$_[0]);
                                    return Text::Restructured::Writer::LibXML
                                        ->new->ProcessDOM($dudom);
                                });
 
    bless $self,$class;
}
 
1;