| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2014, 2015 Yon <anaseto@bardinflor.perso.aquilenet.fr> | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Permission to use, copy, modify, and distribute this software for any | ||||||||||||||||||||||||||||
| 5 | # purpose with or without fee is hereby granted, provided that the above | ||||||||||||||||||||||||||||
| 6 | # copyright notice and this permission notice appear in all copies. | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||||||||||||||||||||||||||
| 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||||||||||||||||||||||||||
| 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||||||||||||||||||||||||||
| 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||||||||||||||||||||||||||
| 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||||||||||||||||||||||||||
| 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||||||||||||||||||||||||||
| 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # Object interface for use in user macros and filters | ||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||
| 19 | package Text::Frundis::Object; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use v5.12; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use open qw(:std :utf8); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | use Text::Frundis::Processing; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 3 | our @Arg; # Macro line arguments (so common that a global variable is handy) | |||||||||||||||||||||||||||
| 31 | 3 | our @EXPORT_OK = qw(@Arg); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 60 | ▶ | sub new { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 60 | my $class = shift; | |||||||||||||||||||||||||||
| 35 | 60 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | 60 | bless $self, $class; | |||||||||||||||||||||||||||
| 37 | } # ]]] | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # methods, in alphabetic order | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | sub args { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 4 | shift; | |||||||||||||||||||||||||||
| 43 | 4 | return \@Arg; | |||||||||||||||||||||||||||
| 44 | } # ]]] | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 12 | ▶ | sub call { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
call: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 12 | shift; | |||||||||||||||||||||||||||
| 48 | 12 | Text::Frundis::Processing::call(@_); | |||||||||||||||||||||||||||
| 49 | } # ]]] | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 86 | ▶ | sub _call_perl_macro { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
_call_perl_macro: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 86 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 86 | my $macro = shift; | |||||||||||||||||||||||||||
| 54 | 86 | $self->{macros}{$macro}{code}->($self); | |||||||||||||||||||||||||||
| 55 | } # ]]] | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub diag_warning { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
diag_warning: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | shift; | |||||||||||||||||||||||||||
| 59 | 0 | Text::Frundis::Processing::diag_error(@_); | |||||||||||||||||||||||||||
| 60 | } # ]]] | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 2 | ▶ | sub diag_error { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
diag_error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 2 | shift; | |||||||||||||||||||||||||||
| 64 | 2 | Text::Frundis::Processing::diag_error(@_); | |||||||||||||||||||||||||||
| 65 | } # ]]] | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub diag_fatal { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
diag_fatal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | shift; | |||||||||||||||||||||||||||
| 69 | 0 | Text::Frundis::Processing::diag_fatal(@_); | |||||||||||||||||||||||||||
| 70 | } # ]]] | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 2 | ▶ | sub escape { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
escape: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 2 | shift; | |||||||||||||||||||||||||||
| 74 | 2 | Text::Frundis::Processing::escape(@_); | |||||||||||||||||||||||||||
| 75 | } # ]]] | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 18 | ▶ | sub escape_text { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
escape_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 18 | shift; | |||||||||||||||||||||||||||
| 79 | 18 | Text::Frundis::Processing::escape_text(@_); | |||||||||||||||||||||||||||
| 80 | } # ]]] | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | sub file { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 84 | 2 | return ${ $self->{file} }; | |||||||||||||||||||||||||||
| 85 | } # ]]] | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 2 | ▶ | sub flag { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
flag: called CC=6 SCAR=30.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | 2 | my @arg = @_; | |||||||||||||||||||||||||||
| 90 | 2 | ▶ | if (@arg == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 91 | 2 | return $self->{flags}{ $arg[0] }; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | elsif (@arg == 2) { | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return unless $self->process; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | unless ($self->{allowed_flags}{ $_[0] } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"allowed_flags"}{$_[0]} and not $self->{"allowed_flags"}{$_[0]} =~ /^_/u
MC/DC0%0/2
$self->{"allowed_flags"}{$_[0]} and not $self->{"allowed_flags"}{$_[0]} =~ /^_/u
$self->{"allowed_flags"}{$_[0]}
not $self->{"allowed_flags"}{$_[0]} =~ /^_/u
Truth table0%0/3
A and not(B)
A= $self->{"allowed_flags"}{$_[0]}B= not $self->{"allowed_flags"}{$_[0]} =~ /^_/u
| |||||||||||||||||||||||||||||
| 96 | and $self->{allowed_flags}{ $_[0] } !~ /^_/) | ||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||
| 98 | 0 | $self->{allowed_flags}{ $_[0] } = 1; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | $self->{flags}{ $_[0] } = $_[1]; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||
| 103 | 0 | $self->diag_error("perl:method flag has one or two arguments"); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } # ]]] | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 5 | ▶ | sub format { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 109 | 5 | return $self->{format}; | |||||||||||||||||||||||||||
| 110 | } # ]]] | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 18 | ▶ | sub get_close_delim { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
get_close_delim: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 18 | shift; | |||||||||||||||||||||||||||
| 114 | 18 | Text::Frundis::Processing::get_close_delim(); | |||||||||||||||||||||||||||
| 115 | } # ]]] | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 18 | ▶ | sub ivars { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
ivars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 118 | 18 | my $self = shift; | |||||||||||||||||||||||||||
| 119 | 18 | return $self->{ivars}; | |||||||||||||||||||||||||||
| 120 | } # ]]] | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 2 | ▶ | sub lnum { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
lnum: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 124 | 2 | return $self->{state}{lnum}; | |||||||||||||||||||||||||||
| 125 | } # ]]] | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 8 | ▶ | sub loX_entry_infos { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
loX_entry_infos: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 129 | 8 | ▶ | return if $self->process; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 8 | Text::Frundis::Processing::loX_entry_infos(@_); | |||||||||||||||||||||||||||
| 131 | } # ]]] | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 2 | ▶ | sub macro { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
macro: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 134 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 135 | 2 | return $self->{state}{macro}; | |||||||||||||||||||||||||||
| 136 | } # ]]] | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 8 | ▶ | sub new_id { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
new_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 139 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 140 | 8 | my $id = shift; | |||||||||||||||||||||||||||
| 141 | 8 | $id = Text::Frundis::Processing::escape_text($id); | |||||||||||||||||||||||||||
| 142 | 8 | $self->{ID}{$id} = Text::Frundis::Processing::xhtml_gen_href("", $id); | |||||||||||||||||||||||||||
| 143 | } # ]]] | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 2 | ▶ | sub param { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
param: called CC=6 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 146 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 147 | 2 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 148 | 0 | return $self->{params}{ $_[0] }; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | elsif (@_ == 2) { | ||||||||||||||||||||||||||||
| 151 | 2 | ▶ | return unless $self->process; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 2 | ▶ | unless ($self->{allowed_params}{ $_[0] } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"allowed_params"}{$_[0]} and not $self->{"allowed_params"}{$_[0]} =~ /^_/u
MC/DC0%0/2
$self->{"allowed_params"}{$_[0]} and not $self->{"allowed_params"}{$_[0]} =~ /^_/u
$self->{"allowed_params"}{$_[0]}
not $self->{"allowed_params"}{$_[0]} =~ /^_/u
Truth table33%1/3
A and not(B)
A= $self->{"allowed_params"}{$_[0]}B= not $self->{"allowed_params"}{$_[0]} =~ /^_/u
| |||||||||||||||||||||||||||||
| 153 | and $self->{allowed_params}{ $_[0] } !~ /^_/) | ||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||
| 155 | 2 | $self->{allowed_params}{ $_[0] } = 1; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | 2 | $self->{params}{ $_[0] } = $_[1]; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | else { | ||||||||||||||||||||||||||||
| 160 | 0 | diag_error("perl:method param has one or two arguments"); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } # ]]] | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 2 | ▶ | sub parse_options { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
parse_options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 165 | 2 | shift; | |||||||||||||||||||||||||||
| 166 | 2 | Text::Frundis::Processing::parse_options(@_); | |||||||||||||||||||||||||||
| 167 | } # ]]] | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 28 | ▶ | sub phrasing_macro_begin { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
phrasing_macro_begin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 28 | shift; | |||||||||||||||||||||||||||
| 171 | 28 | Text::Frundis::Processing::phrasing_macro_begin(@_); | |||||||||||||||||||||||||||
| 172 | } # ]]] | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 2 | ▶ | sub phrasing_macro_end { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
phrasing_macro_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 175 | 2 | shift; | |||||||||||||||||||||||||||
| 176 | 2 | Text::Frundis::Processing::phrasing_macro_end(@_); | |||||||||||||||||||||||||||
| 177 | } # ]]] | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 94 | ▶ | sub process { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 180 | 94 | my $self = shift; | |||||||||||||||||||||||||||
| 181 | 94 | return ${ $self->{process} }; | |||||||||||||||||||||||||||
| 182 | } # ]]] | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 6 | ▶ | sub text { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
text: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 185 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 186 | 6 | my @arg = @_; | |||||||||||||||||||||||||||
| 187 | 6 | ▶ | if (@arg == 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 188 | 4 | return $self->{state}{text}; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | elsif (@arg == 1) { | ||||||||||||||||||||||||||||
| 191 | 2 | $self->{state}{text} = $arg[0]; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | else { | ||||||||||||||||||||||||||||
| 194 | 0 | diag_error("perl:method text has one or two arguments"); | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } # ]]] | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 42 | ▶ | sub vars { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
vars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 199 | 42 | return shift->{vars}; | |||||||||||||||||||||||||||
| 200 | } # ]]] | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub xhtml_gen_href { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
xhtml_gen_href: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 203 | 0 | shift; | |||||||||||||||||||||||||||
| 204 | 0 | Text::Frundis::Processing::xhtml_gen_href(@_); | |||||||||||||||||||||||||||
| 205 | } # ]]] | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 4 | ▶ | sub xhtml_loX { # [[[ | ||||||||||||||||||||||||||
|
Subroutine
xhtml_loX: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 208 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | 4 | ▶ | return unless $self->process; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 4 | Text::Frundis::Processing::xhtml_loX(@_); | |||||||||||||||||||||||||||
| 211 | } # ]]] | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 3 | 1; | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # vim:foldmarker=[[[,]]]:foldmethod=marker:sw=4:sts=4:expandtab | ||||||||||||||||||||||||||||