| 1 | 3 | ▶ | use 5.14.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Stenciller::Plugin::ToUnparsedText; | ||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '0.1302'; # VERSION: | |||||||||
| 8 | # ABSTRACT: A plugin that doesn't transform the text | ||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use List::AllUtils qw/first_index/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | with 'Stenciller::Transformer'; | |||||||||
| 13 | 3 | ▶ | use Types::Standard qw/Bool/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 3 | has text_as_html_pod => ( | |||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | isa => Bool, | ||||||||||
| 18 | default => 0, | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | sub transform { | ||||||||||
| 23 | 4 | ▶ | my $self = shift; | ||||||||
|
Subroutine
transform: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 24 | 4 | my $transform_args = shift; | |||||||||
| 25 | |||||||||||
| 26 | 4 | my @out = $self->init_out($self->stenciller, $transform_args); | |||||||||
| 27 | |||||||||||
| 28 | STENCIL: | ||||||||||
| 29 | 4 | for my $i (0 .. $self->stenciller->max_stencil_index) { | |||||||||
| 30 | 10 | ▶ | next STENCIL if $self->should_skip_stencil_by_index($i, $transform_args); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 4 | my $stencil = $self->stenciller->get_stencil($i); | |||||||||
| 33 | 4 | ▶ | next STENCIL if $self->should_skip_stencil($stencil, $transform_args); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 4 | push @out => '', | |||||||||
| 36 | $self->maybe_as_html_pod($stencil->all_before_input), '', | ||||||||||
| 37 | $stencil->all_input, '', | ||||||||||
| 38 | $self->maybe_as_html_pod($stencil->all_between), '', | ||||||||||
| 39 | $stencil->all_output, '', | ||||||||||
| 40 | $self->maybe_as_html_pod($stencil->all_after_output), ''; | ||||||||||
| 41 | } | ||||||||||
| 42 | 4 | my $content = join "\n" => '', @out, ''; | |||||||||
| 43 | 4 | $content =~ s{\v{2,}}{\n\n}g; | |||||||||
| 44 | 4 | return $content; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | sub maybe_as_html_pod { | ||||||||||
| 48 | 12 | ▶ | my $self = shift; | ||||||||
|
Subroutine
maybe_as_html_pod: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 49 | 12 | my @text = @_; | |||||||||
| 50 | |||||||||||
| 51 | 12 | ▶ | return @text if !$self->text_as_html_pod; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 3 | ▶ | return @text if !scalar @text; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 2 | unshift @text => '', '=begin html', ''; | |||||||||
| 55 | 2 | push @text => '', '=end html', ''; | |||||||||
| 56 | 2 | return @text; | |||||||||
| 57 | |||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 3 | 1; | |||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||
| 63 | |||||||||||
| 64 | =pod | ||||||||||
| 65 | |||||||||||
| 66 | =encoding UTF-8 | ||||||||||
| 67 | |||||||||||
| 68 | =head1 NAME | ||||||||||
| 69 | |||||||||||
| 70 | Stenciller::Plugin::ToUnparsedText - A plugin that doesn't transform the text | ||||||||||
| 71 | |||||||||||
| 72 | =head1 VERSION | ||||||||||
| 73 | |||||||||||
| 74 | Version 0.1302, released 2015-11-28. | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | |||||||||||
| 78 | =head1 SYNOPSIS | ||||||||||
| 79 | |||||||||||
| 80 | use Stenciller; | ||||||||||
| 81 | my $stenciller = Stenciller->new(filepath => 't/corpus/test-1.stencil'); | ||||||||||
| 82 | my $content = $stenciller->transform('ToUnparsedText'); | ||||||||||
| 83 | |||||||||||
| 84 | =head1 DESCRIPTION | ||||||||||
| 85 | |||||||||||
| 86 | This plugin to L<Stenciller> basically returns all text content of the stencils. | ||||||||||
| 87 | |||||||||||
| 88 | If this plugin is used via L<Pod::Elemental::Transformer::Stenciller> it could be used like this in pod: | ||||||||||
| 89 | |||||||||||
| 90 | =pod | ||||||||||
| 91 | |||||||||||
| 92 | # includes header_lines and all stencils | ||||||||||
| 93 | :stenciller ToUnparsedText atestfile-1.stencil | ||||||||||
| 94 | |||||||||||
| 95 | # includes header_lines and all stencils | ||||||||||
| 96 | :stenciller ToUnparsedText atestfile-1.stencil { } | ||||||||||
| 97 | |||||||||||
| 98 | # includes only the first stencil in the file | ||||||||||
| 99 | :stenciller ToUnparsedText atestfile-1.stencil { stencils => [0], skip_header_lines => 1 } | ||||||||||
| 100 | |||||||||||
| 101 | # includes only the header_lines | ||||||||||
| 102 | :stenciller ToUnparsedText atestfile-1.stencil { stencils => [] } | ||||||||||
| 103 | |||||||||||
| 104 | =head1 ATTRIBUTES | ||||||||||
| 105 | |||||||||||
| 106 | =head2 text_as_html_pod | ||||||||||
| 107 | |||||||||||
| 108 | Default: 0 | ||||||||||
| 109 | |||||||||||
| 110 | If set to a true value, the parts that are neither C<input> or C<output> will be rendered between C<=begin html> and C<=end html>. This is useful | ||||||||||
| 111 | when rendering the same stencils to html examples files as well as including in pod. | ||||||||||
| 112 | |||||||||||
| 113 | =head1 METHODS | ||||||||||
| 114 | |||||||||||
| 115 | =head2 transform | ||||||||||
| 116 | |||||||||||
| 117 | See L<transform|Stenciller::Transformer/"transform"> in L<Stenciller::Transformer>. | ||||||||||
| 118 | |||||||||||
| 119 | =head1 SOURCE | ||||||||||
| 120 | |||||||||||
| 121 | L<https://github.com/Csson/p5-Stenciller> | ||||||||||
| 122 | |||||||||||
| 123 | =head1 HOMEPAGE | ||||||||||
| 124 | |||||||||||
| 125 | L<https://metacpan.org/release/Stenciller> | ||||||||||
| 126 | |||||||||||
| 127 | =head1 AUTHOR | ||||||||||
| 128 | |||||||||||
| 129 | Erik Carlsson <info@code301.com> | ||||||||||
| 130 | |||||||||||
| 131 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 132 | |||||||||||
| 133 | This software is copyright (c) 2015 by Erik Carlsson. | ||||||||||
| 134 | |||||||||||
| 135 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 136 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 137 | |||||||||||
| 138 | =cut | ||||||||||