| 1 | package Markdent::Role::Simple; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '0.39'; | |||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use Encode qw( decode ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Markdent::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 3 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 3 | requires 'markdown_to_html'; | |||||||||
| 15 | |||||||||||
| 16 | around markdown_to_html => sub { | ||||||||||
| 17 | 3 | ▶ | my $orig = shift; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 18 | 3 | my $self = shift; | |||||||||
| 19 | 3 | my %p = @_; | |||||||||
| 20 | |||||||||||
| 21 | # XXX - should warn eventually. | ||||||||||
| 22 | $p{dialects} = delete $p{dialect} | ||||||||||
| 23 | 3 | ▶ | if exists $p{dialect}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 3 | return $self->$orig(%p); | |||||||||
| 26 | 3 | }; | |||||||||
| 27 | |||||||||||
| 28 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||
| 29 | sub _parse_markdown { | ||||||||||
| 30 | 3 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_parse_markdown: called CC=4 SCAR=13.9
| |||||||||||
| 31 | 3 | my $markdown = shift; | |||||||||
| 32 | 3 | my $dialects = shift; | |||||||||
| 33 | 3 | my $handler_class = shift; | |||||||||
| 34 | 3 | my $handler_p = shift; | |||||||||
| 35 | |||||||||||
| 36 | 3 | my $capture = q{}; | |||||||||
| 37 | |||||||||||
| 38 | ## no critic (InputOutput::RequireBriefOpen) | ||||||||||
| 39 | 3 | ▶ | open my $fh, '>:encoding(UTF-8)', \$capture | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 40 | or die $!; | ||||||||||
| 41 | |||||||||||
| 42 | my $handler = $handler_class->new( | ||||||||||
| 43 | 3 | ▶ | %{ $handler_p || {} }, | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | output => $fh, | ||||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | 3 | my $parser | |||||||||
| 48 | = Markdent::Parser->new( dialects => $dialects, handler => $handler ); | ||||||||||
| 49 | |||||||||||
| 50 | 3 | $parser->parse( markdown => $markdown ); | |||||||||
| 51 | |||||||||||
| 52 | 3 | ▶ | close $fh | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | or die $!; | ||||||||||
| 54 | |||||||||||
| 55 | 3 | return decode( 'UTF-8', $capture ); | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 3 | 1; | |||||||||
| 59 | |||||||||||
| 60 | # ABSTRACT: A role for simple markdown to html converter classes | ||||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||
| 63 | |||||||||||
| 64 | =pod | ||||||||||
| 65 | |||||||||||
| 66 | =encoding UTF-8 | ||||||||||
| 67 | |||||||||||
| 68 | =head1 NAME | ||||||||||
| 69 | |||||||||||
| 70 | Markdent::Role::Simple - A role for simple markdown to html converter classes | ||||||||||
| 71 | |||||||||||
| 72 | =head1 VERSION | ||||||||||
| 73 | |||||||||||
| 74 | version 0.39 | ||||||||||
| 75 | |||||||||||
| 76 | =head1 DESCRIPTION | ||||||||||
| 77 | |||||||||||
| 78 | This role implements behavior shared by all simple markdown to html | ||||||||||
| 79 | converters. | ||||||||||
| 80 | |||||||||||
| 81 | =head1 REQUIRED METHODS | ||||||||||
| 82 | |||||||||||
| 83 | =over 4 | ||||||||||
| 84 | |||||||||||
| 85 | =item * $simple->markdown_to_html(%p); | ||||||||||
| 86 | |||||||||||
| 87 | =back | ||||||||||
| 88 | |||||||||||
| 89 | =head1 BUGS | ||||||||||
| 90 | |||||||||||
| 91 | See L<Markdent> for bug reporting details. | ||||||||||
| 92 | |||||||||||
| 93 | Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. | ||||||||||
| 94 | |||||||||||
| 95 | I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. | ||||||||||
| 96 | |||||||||||
| 97 | =head1 SOURCE | ||||||||||
| 98 | |||||||||||
| 99 | The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. | ||||||||||
| 100 | |||||||||||
| 101 | =head1 AUTHOR | ||||||||||
| 102 | |||||||||||
| 103 | Dave Rolsky <autarch@urth.org> | ||||||||||
| 104 | |||||||||||
| 105 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 106 | |||||||||||
| 107 | This software is copyright (c) 2021 by Dave Rolsky. | ||||||||||
| 108 | |||||||||||
| 109 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 110 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 111 | |||||||||||
| 112 | The full text of the license can be found in the | ||||||||||
| 113 | F<LICENSE> file included with this distribution. | ||||||||||
| 114 | |||||||||||
| 115 | =cut | ||||||||||