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