Markdent/Simple/Fragment.pm

filter: Statementstmt 100% 41 / 41 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 100% 53 / 53 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Markdent/Role/SpanParser.pm ↑ Summary Markdent/Types.pm »
1 package Markdent::Simple::Fragment;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.40';
8  
9 2 ▶use Markdent::Handler::HTMLStream::Fragment;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Markdent::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Markdent::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Params::ValidationCompiler qw( validation_for );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Specio::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 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 2 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
31 },
32 2 markdown => { type => t('Str') },
33 ],
34 named_to_list => 1,
35 );
36  
37 sub markdown_to_html {
38 2 ▶ my $self = shift;
Subroutine markdown_to_html: called CC=1 SCAR=0.0
39 2 my ( $dialects, $markdown ) = $validator->(@_);
40  
41 2 my $handler_class = 'Markdent::Handler::HTMLStream::Fragment';
42  
43 2 return $self->_parse_markdown(
44 $markdown,
45 $dialects,
46 $handler_class,
47 );
48 }
49 }
50  
51 2 __PACKAGE__->meta->make_immutable;
52  
53 2 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
« Markdent/Role/SpanParser.pm ↑ Summary Markdent/Types.pm »