line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Simple::Document; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
221493
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
468
|
use namespace::autoclean; |
|
1
|
|
|
|
|
18176
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
514
|
use Markdent::Handler::HTMLStream::Document; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
74
|
|
10
|
1
|
|
|
1
|
|
11
|
use Markdent::Types; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
11
|
1
|
|
|
1
|
|
25957
|
use Params::ValidationCompiler qw( validation_for ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
82
|
|
12
|
1
|
|
|
1
|
|
7
|
use Specio::Declare; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
224
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
15
|
1
|
|
|
1
|
|
8258
|
use MooseX::StrictConstructor; |
|
1
|
|
|
|
|
19584
|
|
|
1
|
|
|
|
|
5
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Markdent::Role::Simple'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
my $validator = validation_for( |
21
|
|
|
|
|
|
|
params => [ |
22
|
|
|
|
|
|
|
dialects => { |
23
|
|
|
|
|
|
|
type => union( |
24
|
|
|
|
|
|
|
of => [ |
25
|
|
|
|
|
|
|
t('Str'), |
26
|
|
|
|
|
|
|
t( 'ArrayRef', of => t('Str') ) |
27
|
|
|
|
|
|
|
] |
28
|
|
|
|
|
|
|
), |
29
|
|
|
|
|
|
|
default => sub { [] }, |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
title => { type => t('Str') }, |
32
|
|
|
|
|
|
|
charset => { |
33
|
|
|
|
|
|
|
type => t('Str'), |
34
|
|
|
|
|
|
|
optional => 1, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
language => { |
37
|
|
|
|
|
|
|
type => t('Str'), |
38
|
|
|
|
|
|
|
optional => 1, |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
markdown => { type => t('Str') }, |
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
named_to_list => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub markdown_to_html { |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
my ( $dialects, $title, $charset, $language, $markdown ) |
48
|
|
|
|
|
|
|
= $validator->(@_); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $handler_class = 'Markdent::Handler::HTMLStream::Document'; |
51
|
|
|
|
|
|
|
my %handler_p = ( |
52
|
|
|
|
|
|
|
title => $title, |
53
|
|
|
|
|
|
|
( $charset ? ( charset => $charset ) : () ), |
54
|
|
|
|
|
|
|
( $language ? ( language => $language ) : () ), |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return $self->_parse_markdown( |
58
|
|
|
|
|
|
|
$markdown, |
59
|
|
|
|
|
|
|
$dialects, |
60
|
|
|
|
|
|
|
$handler_class, |
61
|
|
|
|
|
|
|
\%handler_p |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# ABSTRACT: Convert Markdown to an HTML Document |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Markdent::Simple::Document - Convert Markdown to an HTML Document |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.40 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use Markdent::Simple::Document; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $mds = Markdent::Simple::Document->new; |
91
|
|
|
|
|
|
|
my $html = $mds->markdown_to_html( |
92
|
|
|
|
|
|
|
title => 'My Document', |
93
|
|
|
|
|
|
|
markdown => $markdown, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This class provides a very simple interface for converting Markdown to a |
99
|
|
|
|
|
|
|
complete HTML document. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This class provides the following methods: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 Markdent::Simple::Document->new |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Creates a new Markdent::Simple::Document object. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 $mds->markdown_to_html( title => $title, markdown => $markdown ) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This method turns Markdown into HTML. It accepts the following parameters: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over 4 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * title => $title |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The title of the document. This is required. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * charset => $charset |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
If provided, a C<< <meta charset="..."> >> tag will be added to the document's |
122
|
|
|
|
|
|
|
C<< <head> >>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * language => $language |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
If provided, a "lang" attribute will be added to the document's C<< <html> >> |
127
|
|
|
|
|
|
|
tag. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * dialects => [...] |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This can either be a single string or an array ref of strings containing the |
132
|
|
|
|
|
|
|
class names of dialects. This parameter is optional. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 ROLES |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This class does the L<Markdent::Role::Simple> role. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 BUGS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SOURCE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Dave Rolsky. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
161
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The full text of the license can be found in the |
164
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |