| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Markdent::Simple::Fragment; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
442437
|
use strict; |
|
|
2
|
|
|
|
|
24
|
|
|
|
2
|
|
|
|
|
59
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
57
|
|
|
5
|
2
|
|
|
2
|
|
945
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
36279
|
|
|
|
2
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.38'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1017
|
use Markdent::Handler::HTMLStream::Fragment; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
106
|
|
|
10
|
2
|
|
|
2
|
|
1149
|
use Markdent::Parser; |
|
|
2
|
|
|
|
|
13
|
|
|
|
2
|
|
|
|
|
98
|
|
|
11
|
2
|
|
|
2
|
|
24
|
use Markdent::Types; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
21
|
|
|
12
|
2
|
|
|
2
|
|
53102
|
use Params::ValidationCompiler qw( validation_for ); |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
143
|
|
|
13
|
2
|
|
|
2
|
|
13
|
use Specio::Declare; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
430
|
use Moose; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
21
|
|
|
16
|
2
|
|
|
2
|
|
14873
|
use MooseX::StrictConstructor; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
19
|
|
|
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.38 |
|
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 fragment. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This class provides the following methods: |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 Markdent::Simple::Fragment->new() |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Creates a new Markdent::Simple::Fragment object. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 $mdf->markdown_to_html( markdown => $markdown ) |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method turns Markdown into HTML. It accepts the following parameters: |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * markdown |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is the markdown to pass. This argument is required. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * dialects |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This can either be a single string or an array ref of strings containing the |
|
105
|
|
|
|
|
|
|
class names of dialects. This parameter is optional. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 ROLES |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This class does the L<Markdent::Role::Simple> role. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 BUGS |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SOURCE |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Dave Rolsky. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
134
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
137
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |