lib/LaTeXML/Common/Config.pm

filter: Statementstmt 12.2% 52 / 426 Branchbran 0.3% 1 / 268 Conditioncond 1.2% 2 / 164 MC/DCmcdc 0.0% 0 / 90 Subroutinesub 18.7% 12 / 64 Podpod 52.6% 10 / 19 totaltotal 7.4% 77 / 1031 CC 203 SCAR 89.2
CC
203
Cov
6%
_prepare_options
15750.0
read
380.0
_obey_profile
210.0
CRAP 7454.9
« lib/LaTeXML/MathGrammar.pm ↑ Summary lib/LaTeXML/Util/Image.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Config | #
3 # | Configuration logic for LaTeXML | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> | #
10 # | Deyan Ginev <deyan.ginev@nist.gov> #_# | #
11 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
12 # \=========================================================ooo==U==ooo=/ #
13 package LaTeXML::Common::Config;
14 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use Getopt::Long qw(:config no_ignore_case);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use Pod::Find qw(pod_where);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use LaTeXML::Util::Pathname;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 our $PROFILES_DB = {}; # Class-wide, caches all profiles that get used while the server is alive
25 5 our $is_bibtex = qr/(^literal\:\s*\@)|(\.bib$)/;
26 5 our $is_archive = qr/(^literal\:PK)|(\.zip$)/;
27  
28 5 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 our @EXPORT = (qw(addMathFormat removeMathFormat maybeAddMathFormat));
30  
31 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
32 0 my ($class, %opts) = @_;
33 #TODO: How about defaults in the daemon server use case? Should we support those here?
34 # or are defaults always bad/confusing to allow?
35 0 ▶ %opts = () unless %opts;
Branch: 1 branch
BranchTrueFalseTotal
unless %opts 0 0 0
36 0 return bless { dirty => 1, opts => \%opts }, $class; }
37  
38 ###########################################
39 #### Command-line reader #####
40 ###########################################
41 5 ▶sub getopt_specification {
Subroutine getopt_specification: called CC=7 SCAR=34.5
Pod undocumented
42 5 my (%options) = @_;
43 5 ▶ my $opts = $options{options} || {};
Condition50%1/2
$options{'options'} || {}
l!l
05
MC/DC0%0/1
$options{'options'} || {}
$options{'options'}
Truth table50%1/2
A
A= $options{'options'}
Aresult
11
00
44 my $spec = {
45 # Basics and Paths
46 "output=s" => \$$opts{destination},
47 "destination=s" => \$$opts{destination},
48 "log=s" => \$$opts{log},
49 5 "preload=s" => \@{ $$opts{preload} },
50 "preamble=s" => \$$opts{preamble},
51 "postamble=s" => \$$opts{postamble},
52 "base=s" => \$$opts{base},
53 5 "path=s" => \@{ $$opts{paths} },
54 0 ▶ "quiet" => sub { $$opts{verbosity}--; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 ▶ "verbose" => sub { $$opts{verbosity}++; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 "strict" => \$$opts{strict},
57 "includestyles" => \$$opts{includestyles},
58 "inputencoding=s" => \$$opts{inputencoding},
59 # Formats
60 0 ▶ "xml" => sub { $$opts{format} = 'xml'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ "tex" => sub { $$opts{format} = 'tex'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 ▶ "box" => sub { $$opts{format} = 'box'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 0 ▶ "bibtex" => sub { $$opts{type} = 'BibTeX'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 0 ▶ "noparse" => sub { $$opts{mathparse} = 'no'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 "format=s" => \$$opts{format},
66 "parse=s" => \$$opts{mathparse},
67 # Profiles
68 "profile=s" => \$$opts{profile},
69 "cache_key=s" => \$$opts{cache_key},
70 "mode=s" => \$$opts{profile},
71 "source=s" => \$$opts{source},
72 # Output framing
73 0 ▶ "embed" => sub { $$opts{whatsout} = 'fragment'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
74 "whatsin=s" => \$$opts{whatsin},
75 "whatsout=s" => \$$opts{whatsout},
76 # Daemon options
77 "autoflush=i" => \$$opts{input_limit},
78 "timeout=i" => \$$opts{timeout},
79 "expire=i" => \$$opts{expire},
80 "address=s" => \$$opts{address},
81 "port=i" => \$$opts{port},
82 # Post-processing
83 "post!" => \$$opts{post},
84 "validate!" => \$$opts{validate},
85 "omitdoctype!" => \$$opts{omitdoctype},
86 "numbersections!" => \$$opts{numbersections},
87 "timestamp=s" => \$$opts{timestamp},
88 # Various choices for math processing.
89 # Note: Could want OM embedded in mml annotation, too.
90 # In general, could(?) want multiple math reps within <Math>
91 # OR, multiple math reps combined with <mml:sematics>
92 # or, in fact, _other_ parallel means? (om?, omdoc? ...)
93 # So, need to separate multiple transformations from the combination.
94 # However, IF combining, then will need to support a id/ref mechanism.
95 "mathimagemagnification=f" => \$$opts{mathimagemag},
96 "linelength=i" => \$$opts{linelength},
97 "invisibletimes!" => \$$opts{invisibletimes},
98 "plane1!" => \$$opts{plane1},
99 "hackplane1!" => \$$opts{hackplane1},
100 0 ▶ "mathimages" => sub { addMathFormat($opts, 'images'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 ▶ "nomathimages" => sub { removeMathFormat($opts, 'images'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 ▶ "mathsvg" => sub { addMathFormat($opts, 'svg'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 0 ▶ "nomathsvg" => sub { removeMathFormat($opts, 'svg'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
104 0 ▶ "presentationmathml|pmml" => sub { addMathFormat($opts, 'pmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 ▶ "contentmathml|cmml" => sub { addMathFormat($opts, 'cmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 0 ▶ "openmath|om" => sub { addMathFormat($opts, 'om'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 0 ▶ "keepXMath|xmath" => sub { addMathFormat($opts, 'xmath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 ▶ "nopresentationmathml|nopmml" => sub { removeMathFormat($opts, 'pmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 ▶ "nocontentmathml|nocmml" => sub { removeMathFormat($opts, 'cmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
110 0 ▶ "noopenmath|noom" => sub { removeMathFormat($opts, 'om'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
111 0 ▶ "nokeepXMath|noxmath" => sub { removeMathFormat($opts, 'xmath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
112 0 ▶ "mathtex" => sub { addMathFormat($opts, 'mathtex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
113 0 ▶ "nomathtex" => sub { removeMathFormat($opts, 'mathtex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
114 0 ▶ "unicodemath" => sub { addMathFormat($opts, 'unicodemath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 0 ▶ "nounicodemath" => sub { removeMathFormat($opts, 'unicodemath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
116 "parallelmath!" => \$$opts{parallelmath},
117 # Some general XSLT/CSS/JavaScript options.
118 "stylesheet=s" => \$$opts{stylesheet},
119 5 "xsltparameter=s" => \@{ $$opts{xsltparameters} },
120 5 "css=s" => \@{ $$opts{css} },
121 "defaultresources!" => \$$opts{defaultresources},
122 5 "javascript=s" => \@{ $$opts{javascript} },
123 "icon=s" => \$$opts{icon},
124 # Options for broader document set processing
125 "split!" => \$$opts{split},
126 0 ▶ "splitat=s" => sub { $$opts{splitat} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
127 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
128 0 ▶ "splitpath=s" => sub { $$opts{splitpath} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
129 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
130 0 ▶ "splitnaming=s" => sub { $$opts{splitnaming} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
131 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
132 "scan!" => \$$opts{scan},
133 "crossref!" => \$$opts{crossref},
134 "urlstyle=s" => \$$opts{urlstyle},
135 "navigationtoc=s" => \$$opts{navtoc},
136 "navtoc=s" => \$$opts{navtoc},
137 # Generating indices
138 "index!" => \$$opts{index},
139 "permutedindex!" => \$$opts{permutedindex},
140 "splitindex!" => \$$opts{splitindex},
141 # Generating Bibliographies
142 5 "bibliography=s" => \@{ $$opts{bibliographies} }, # TODO: Document
143 "splitbibliography!" => \$$opts{splitbibliography},
144 # Options for two phase processing
145 "prescan" => \$$opts{prescan},
146 "dbfile=s" => \$$opts{dbfile},
147 "sitedirectory=s" => \$$opts{sitedirectory},
148 "sourcedirectory=s" => \$$opts{sourcedirectory},
149 # For graphics: vaguely similar issues, but more limited.
150 # includegraphics images (eg. ps) can be converted to webimages (eg.png)
151 # picture/pstricks images can be converted to png or possibly svg.
152 "graphicimages!" => \$$opts{dographics},
153 5 "graphicsmap=s" => \@{ $$opts{graphicsmaps} },
154 "svg!" => \$$opts{svg},
155 "pictureimages!" => \$$opts{picimages},
156 # HELP
157 "comments!" => \$$opts{comments},
158 "VERSION!" => \$$opts{showversion},
159 5 "debug=s" => \@{ $$opts{debug} },
160 "documentid=s" => \$$opts{documentid},
161 "help" => \$$opts{help}
162 5 };
163 5 ▶ return ($spec, $opts) unless ($options{type} && ($options{type} eq 'keyvals'));
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"type"} and $options{"type"} eq "keyvals" 5 0 5
Condition33%1/3
$options{"type"} and $options{"type"} eq "keyvals"
!ll&&!rl&&r
500
MC/DC0%0/2
$options{"type"} and $options{"type"} eq "keyvals"
$options{"type"} $options{"type"} eq "keyvals"
Truth table33%1/3
A and B
A= $options{"type"}B= $options{"type"} eq "keyvals"
ABresult
0X0
100
111
164 # Representation use case:
165 0 ▶ my $keyvals = $options{keyvals} || [];
Condition0%0/2
$options{'keyvals'} || []
l!l
00
MC/DC0%0/1
$options{'keyvals'} || []
$options{'keyvals'}
Truth table0%0/2
A
A= $options{'keyvals'}
Aresult
11
00
166 0 my $rep_spec = {}; # Representation specification
167 0 foreach my $key (keys %$spec) {
168 0 ▶ if ($key =~ /^(.+)=\w$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^(.+)=\w$/) { } 0 0 0
169 0 my $name = $1;
170 0 ▶ $$rep_spec{$key} = sub { CORE::push @$keyvals, [$name, $_[1]] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
171 } else {
172 0 ▶ $$rep_spec{$key} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
173 0 my $ctl = $_[0]->{ctl};
174 0 ▶ my $used = ($$ctl[0] ? 'no' : '') . $$ctl[1];
Branch: 1 branch
BranchTrueFalseTotal
$ctl->[0] ? : 0 0 0
175 0 CORE::push @$keyvals, [$used, undef] };
176 }
177 }
178 0 return ($rep_spec, $keyvals);
179 }
180 # TODO: Separate the keyvals scan from getopt_specification()
181 # into its own sub, using @GETOPT_KEYS entirely.
182 5 our @GETOPT_KEYS = keys %{ (getopt_specification())[0] };
183  
184 0 ▶sub read {
Subroutine read: not called CC=19 SCAR=59.4
Pod documented
185 0 my ($self, $argref, %read_options) = @_;
186 0 my $opts = $$self{opts};
187 0 local @ARGV = @$argref;
188 0 my ($spec) = getopt_specification(options => $opts);
189 0 ▶ my $silent = %read_options && $read_options{silent};
Condition0%0/3
%read_options && $read_options{'silent'}
!ll&&!rl&&r
000
MC/DC0%0/2
%read_options && $read_options{'silent'}
%read_options $read_options{'silent'}
Truth table0%0/3
A && B
A= %read_optionsB= $read_options{'silent'}
ABresult
0X0
100
111
190 0 my $getOptions_success = GetOptions(%{$spec});
191 0 ▶ if (!$getOptions_success && !$silent) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($getOptions_success or $silent) 0 0 0
Condition0%0/3
$getOptions_success or $silent
l!l&&r!l&&!r
000
MC/DC0%0/2
$getOptions_success or $silent
$getOptions_success $silent
Truth table0%0/3
A or B
A= $getOptions_successB= $silent
ABresult
1X1
011
000
192 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 1, -verbose => 99,
193 -input => pod_where({ -inc => 1 }, __PACKAGE__),
194 -sections => 'OPTION SYNOPSIS', -output => \*STDERR);
195 }
196 0 ▶ if (!$silent && $$opts{help}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $silent and $opts->{"help"}) 0 0 0
Condition0%0/3
not $silent and $opts->{"help"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $silent and $opts->{"help"}
not $silent $opts->{"help"}
Truth table0%0/3
not(A) and B
A= not $silentB= $opts->{"help"}
ABresult
0X0
100
111
197 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 0, -verbose => 99,
198 -input => pod_where({ -inc => 1 }, __PACKAGE__),
199 -sections => 'OPTION SYNOPSIS', output => \*STDOUT);
200 }
201  
202 # Check that options for system I/O (destination and log) are valid before wasting any time...
203 0 foreach my $IO_option (qw(destination log)) {
204 0 ▶ if ($$opts{$IO_option}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{$IO_option}) 0 0 0
205 0 $$opts{$IO_option} = pathname_canonical($$opts{$IO_option});
206 0 ▶ if (my $dir = pathname_directory($$opts{$IO_option})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = pathname_directory($opts->{$IO_option})) 0 0 0
207 0 ▶ pathname_mkdir($dir) or croak "Couldn't create $IO_option directory $dir: $!"; } } }
Branch: 1 branch
BranchTrueFalseTotal
pathname_mkdir($dir) or croak("Couldn't create $IO_option directory ${dir}: $!") 0 0 0
208 # Removed math formats are irrelevant for conversion:
209 0 delete $$opts{removed_math_formats};
210  
211 0 ▶ if ($$opts{showversion}) { print STDERR "$LaTeXML::IDENTITY\n"; exit(0); }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"showversion"}) 0 0 0
212  
213 0 ▶ $$opts{source} = $ARGV[0] unless $$opts{source};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts->{"source"} 0 0 0
214 # Special source-based guessing needs to happen here,
215 # as we won't have access to the source file/literal/resource later on:
216 0 ▶ if (!$$opts{type} || ($$opts{type} eq 'auto')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"type"} or $opts->{"type"} eq "auto") 0 0 0
Condition0%0/3
not $opts->{"type"} or $opts->{"type"} eq "auto"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $opts->{"type"} or $opts->{"type"} eq "auto"
not $opts->{"type"} $opts->{"type"} eq "auto"
Truth table0%0/3
not(A) or B
A= not $opts->{"type"}B= $opts->{"type"} eq "auto"
ABresult
1X1
011
000
217 0 ▶ $$opts{type} = 'BibTeX' if ($$opts{source} && ($$opts{source} =~ /$is_bibtex/)); }
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/ 0 0 0
Condition0%0/3
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
$opts->{"source"} $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
Truth table0%0/3
A and B
A= $opts->{"source"}B= $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
ABresult
0X0
100
111
218 0 ▶ if (!$$opts{whatsin}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"whatsin"}) 0 0 0
219 0 ▶ $$opts{whatsin} = 'archive' if ($$opts{source} && ($$opts{source} =~ /$is_archive/)); }
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/ 0 0 0
Condition0%0/3
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
$opts->{"source"} $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
Truth table0%0/3
A and B
A= $opts->{"source"}B= $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
ABresult
0X0
100
111
220 0 return $getOptions_success;
221 }
222  
223 0 ▶sub read_keyvals {
Subroutine read_keyvals: not called CC=6 SCAR=37.4
Pod undocumented
224 0 my ($self, $conversion_options, %read_options) = @_;
225 0 my $cmdopts = [];
226 0 ▶ while (my ($key, $value) = splice(@$conversion_options, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@$conversion_options, 0, 2)) 0 0 0
227 # TODO: Is skipping over empty values ever harmful? Do we have non-empty defaults anywhere?
228 0 ▶ next if (!length($value)) && (grep { /^$key\=/ } @GETOPT_KEYS);
Branch: 1 branch
BranchTrueFalseTotal
if not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS 0 0 0
Condition0%0/3
not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
!ll&&!rl&&r
000
MC/DC0%0/2
not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
not length $value grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
Truth table0%0/3
not(A) and B
A= not length $valueB= grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
ABresult
0X0
100
111
229 0 ▶ $key = "--$key" unless $key =~ /^\-\-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^\-\-/ 0 0 0
230 0 ▶ $value = length($value) ? "=$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
length $value ? : 0 0 0
231 0 CORE::push @$cmdopts, "$key$value";
232 }
233 # Read into a Config object:
234 0 return $self->read($cmdopts, %read_options); }
235  
236 0 ▶sub scan_to_keyvals {
Subroutine scan_to_keyvals: not called CC=6 SCAR=37.4
Pod undocumented
237 0 my ($self, $argref, %read_options) = @_;
238 0 local @ARGV = @$argref;
239 0 my ($spec, $keyvals) = getopt_specification(type => 'keyvals');
240 0 ▶ my $silent = %read_options && $read_options{silent};
Condition0%0/3
%read_options && $read_options{'silent'}
!ll&&!rl&&r
000
MC/DC0%0/2
%read_options && $read_options{'silent'}
%read_options $read_options{'silent'}
Truth table0%0/3
A && B
A= %read_optionsB= $read_options{'silent'}
ABresult
0X0
100
111
241 0 my $getOptions_success = GetOptions(%$spec);
242 0 ▶ if (!$getOptions_success && !$silent) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($getOptions_success or $silent) 0 0 0
Condition0%0/3
$getOptions_success or $silent
l!l&&r!l&&!r
000
MC/DC0%0/2
$getOptions_success or $silent
$getOptions_success $silent
Truth table0%0/3
A or B
A= $getOptions_successB= $silent
ABresult
1X1
011
000
243 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 1, -verbose => 99,
244 -input => pod_where({ -inc => 1 }, __PACKAGE__),
245 -sections => 'OPTION SYNOPSIS', -output => \*STDERR);
246 }
247 0 ▶ CORE::push @$keyvals, ['source', $ARGV[0]] if $ARGV[0];
Branch: 1 branch
BranchTrueFalseTotal
if $ARGV[0] 0 0 0
248 0 ▶ return $getOptions_success && $keyvals;
Condition0%0/3
$getOptions_success && $keyvals
!ll&&!rl&&r
000
MC/DC0%0/2
$getOptions_success && $keyvals
$getOptions_success $keyvals
Truth table0%0/3
A && B
A= $getOptions_successB= $keyvals
ABresult
0X0
100
111
249 }
250  
251 ###########################################
252 #### Options Object Hashlike API #####
253 ###########################################
254 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
255 0 my ($self, $key, $value) = @_;
256 0 return $$self{opts}{$key}; }
257  
258 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
259 0 my ($self, $key, $value) = @_;
260 0 $$self{dirty} = 1;
261 0 $$self{opts}{$key} = $value;
262 0 return; }
263  
264 0 ▶sub push {
Subroutine push: not called CC=2 SCAR=17.9
Pod undocumented
265 0 my ($self, $key, $value) = @_;
266 0 $$self{dirty} = 1;
267 0 ▶ $$self{opts}{$key} = [] unless ref $$self{opts}{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"opts"}{$key} 0 0 0
268 0 CORE::push @{ $$self{opts}{$key} }, $value;
269 0 return; }
270  
271 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
272 0 my ($self, $key) = @_;
273 0 $$self{dirty} = 1;
274 0 delete $$self{opts}{$key};
275 0 return; }
276  
277 0 ▶sub exists {
Subroutine exists: not called CC=1 SCAR=6.9
Pod documented
278 0 my ($self, $key) = @_;
279 0 return exists $$self{opts}{$key}; }
280  
281 0 ▶sub defined {
Subroutine defined: not called CC=1 SCAR=6.9
Pod undocumented
282 0 my ($self, $key) = @_;
283 0 return defined $$self{opts}{$key}; }
284  
285 0 ▶sub keys {
Subroutine keys: not called CC=1 SCAR=6.9
Pod documented
286 0 my ($self) = @_;
287 0 return keys %{ $$self{opts} }; }
288  
289 0 ▶sub options {
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
290 0 my ($self) = @_;
291 0 return $$self{opts}; }
292  
293 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
294 0 my ($self) = @_;
295 0 my $clone = LaTeXML::Common::Config->new(%{ $self->options });
296 0 $$clone{dirty} = $$self{dirty};
297 0 return $clone; }
298  
299 ###########################################
300 #### Option Sanity Checking #####
301 ###########################################
302  
303 # Perform all option sanity checks
304 0 ▶sub check {
Subroutine check: not called CC=2 SCAR=17.9
Pod documented
305 0 my ($self) = @_;
306 0 ▶ return unless $$self{dirty};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"dirty"} 0 0 0
307 # 1. Resolve profile
308 0 $self->_obey_profile;
309 # 2. Place sane defaults where needed
310 0 return $self->_prepare_options; }
311  
312 0 ▶sub _obey_profile {
Subroutine _obey_profile: not called CC=14 SCAR=53.5
313 0 my ($self) = @_;
314 0 $$self{dirty} = 1;
315 0 my $opts = $$self{opts};
316 0 ▶ my $profile = lc($$opts{profile} || 'custom');
Condition0%0/2
$opts->{'profile'} || 'custom'
l!l
00
MC/DC0%0/1
$opts->{'profile'} || 'custom'
$opts->{'profile'}
Truth table0%0/2
A
A= $opts->{'profile'}
Aresult
11
00
317 0 $profile =~ s/\.opt$//;
318 # Look at the PROFILES_DB or find a profiles file (otherwise fallback to custom)
319 0 my $profile_opts = {};
320 0 ▶ if ($profile ne 'custom') {
Branch: 1 branch
BranchTrueFalseTotal
if ($profile ne "custom") 0 0 0
321 0 ▶ if (defined $$PROFILES_DB{$profile}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $LaTeXML::Common::Config::PROFILES_DB->{$profile}) { } 0 0 0
elsif (my $file = pathname_find($profile . '.opt', 'paths', $opts->{'paths'}, 'types', scalar [], 'installation_subdir', 'resources/Profiles')) { } 0 0 0
322 0 %$profile_opts = %{ $$PROFILES_DB{$profile} };
323 } elsif (my $file = pathname_find($profile . '.opt', paths => $$opts{paths},
324 types => [], installation_subdir => 'resources/Profiles')) {
325 0 my $conf_tmp = LaTeXML::Common::Config->new;
326 0 $conf_tmp->read(_read_options_file($file));
327 0 $profile_opts = $conf_tmp->options;
328 } else {
329 # Throw an error, fallback to custom
330 0 carp("Warning:unexpected:$profile Profile $profile was not recognized, reverting to 'custom'\n");
331 0 $$opts{profile} = 'custom';
332 0 $profile = 'custom';
333 }
334 }
335 # Erase the profile, save it as cache key
336 0 delete $$opts{profile};
337 0 ▶ $$opts{cache_key} = $profile unless defined $$opts{cache_key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"cache_key"} 0 0 0
338 0 ▶ if (%$profile_opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$profile_opts) 0 0 0
339 # Merge the new options with the profile defaults:
340 0 for my $key (grep { defined $$opts{$_} } (CORE::keys %$opts)) {
341 0 ▶ if ($key =~ /^p(ath|reload)/) { # Paths and preloads get merged in
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^p(ath|reload)/) { } 0 0 0
342 0 ▶ $$profile_opts{$key} = [] unless defined $$profile_opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $profile_opts->{$key} 0 0 0
343 0 foreach my $entry (@{ $$opts{$key} }) {
344 0 my $new = 1;
345 0 foreach (@{ $$profile_opts{$key} }) {
346 0 ▶ if ($entry eq $_) { $new = 0; last; }
Branch: 1 branch
BranchTrueFalseTotal
if ($entry eq $_) 0 0 0
347 }
348 # If new to the array, push:
349 0 ▶ CORE::push(@{ $$profile_opts{$key} }, $entry) if ($new);
Branch: 1 branch
BranchTrueFalseTotal
if $new 0 0 0
350 }
351 } else { # The other options get overwritten
352 0 $$profile_opts{$key} = $$opts{$key};
353 }
354 }
355 0 %$opts = %$profile_opts; # Move back into the user options
356 }
357 0 return; }
358  
359 # TODO: Best way to throw errors when options don't work out?
360 # How about in the case of Extras::ReadOptions?
361 # Error() and Warn() would be neat, but we have to make sure STDERR is caught beforehand.
362 # Also, there is no eval() here, so we might need a softer handling of Error()s.
363 0 ▶sub _prepare_options {
Subroutine _prepare_options: not called CC=125 SCAR=96.6
364 0 my ($self) = @_;
365 0 my $opts = $$self{opts};
366 #======================================================================
367 # I. Sanity check and Completion of Core options.
368 #======================================================================
369 # "safe" and semi-perlcrtic acceptable way to set DEBUG inside arbitrary modules.
370 # Note: 'LaTeXML' refers to the top-level class
371 0 ▶ foreach my $ltx_class (@{ $$opts{debug} || [] }) {
Condition0%0/2
$opts->{'debug'} || []
l!l
00
MC/DC0%0/1
$opts->{'debug'} || []
$opts->{'debug'}
Truth table0%0/2
A
A= $opts->{'debug'}
Aresult
11
00
372 0 ▶ if ($ltx_class eq 'LaTeXML') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ltx_class eq 'LaTeXML') { } 0 0 0
373 0 $LaTeXML::DEBUG{LaTeXML} = 1; }
374 else {
375 0 $LaTeXML::DEBUG{$ltx_class} = 1; } }
376  
377 0 ▶ $$opts{input_limit} = 100 unless defined $$opts{input_limit}; # 100 jobs until restart
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"input_limit"} 0 0 0
378 0 ▶ $$opts{timeout} = 600 unless defined $$opts{timeout}; # 10 minute timeout default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"timeout"} 0 0 0
379 0 ▶ $$opts{expire} = 600 unless defined $$opts{expire}; # 10 minute timeout default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"expire"} 0 0 0
380 0 ▶ $$opts{mathparse} = 'RecDescent' unless defined $$opts{mathparse};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"mathparse"} 0 0 0
381 0 ▶ $$opts{inputencoding} = "utf-8" unless defined $$opts{inputencoding};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"inputencoding"} 0 0 0
382 0 ▶ if ($$opts{mathparse} eq 'no') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"mathparse"} eq "no") 0 0 0
383 0 $$opts{mathparse} = 0;
384 0 $$opts{nomathparse} = 1; } #Backwards compatible
385 ## $$opts{verbosity} = 0 unless defined $$opts{verbosity};
386 0 ▶ $$opts{preload} = [] unless defined $$opts{preload};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"preload"} 0 0 0
387 0 ▶ $$opts{paths} = ['.'] unless defined $$opts{paths};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"paths"} 0 0 0
388 0 @{ $$opts{paths} } = map { pathname_canonical($_) } @{ $$opts{paths} };
389 0 foreach (('destination', 'dbfile', 'sourcedirectory', 'sitedirectory')) {
390 0 ▶ $$opts{$_} = pathname_canonical($$opts{$_}) if defined $$opts{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$_} 0 0 0
391 }
392  
393 0 ▶ if (!defined $$opts{whatsin}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"whatsin"}) 0 0 0
394 0 ▶ if ($$opts{preamble} || $$opts{postamble}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'preamble'} or $opts->{'postamble'}) { } 0 0 0
Condition0%0/3
$opts->{"preamble"} or $opts->{"postamble"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"preamble"} or $opts->{"postamble"}
$opts->{"preamble"} $opts->{"postamble"}
Truth table0%0/3
A or B
A= $opts->{"preamble"}B= $opts->{"postamble"}
ABresult
1X1
011
000
395 # Preamble or postamble imply a fragment whatsin
396 0 $$opts{whatsin} = 'fragment'; }
397 else { # Default input chunk is a document
398 0 $$opts{whatsin} = 'document'; } }
399 0 ▶ $$opts{type} = 'auto' unless defined $$opts{type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"type"} 0 0 0
400 0 ▶ unshift(@{ $$opts{preload} }, ('TeX.pool', 'LaTeX.pool', 'BibTeX.pool')) if ($$opts{type} eq 'BibTeX');
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"type"} eq "BibTeX" 0 0 0
401  
402 # Destination extension might indicate the format:
403 0 ▶ if ((!defined $$opts{extension}) && (defined $$opts{destination})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"extension"} and defined $opts->{"destination"}) 0 0 0
Condition0%0/3
not defined $opts->{"extension"} and defined $opts->{"destination"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"extension"} and defined $opts->{"destination"}
not defined $opts->{"extension"} defined $opts->{"destination"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"extension"}B= defined $opts->{"destination"}
ABresult
0X0
100
111
404 0 ▶ if ($$opts{destination} =~ /\.([^.]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"destination"} =~ /\.([^.]+)$/) 0 0 0
405 0 $$opts{extension} = $1; } }
406 0 ▶ if ((!defined $$opts{format}) && (defined $$opts{extension})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"format"} and defined $opts->{"extension"}) 0 0 0
Condition0%0/3
not defined $opts->{"format"} and defined $opts->{"extension"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"format"} and defined $opts->{"extension"}
not defined $opts->{"format"} defined $opts->{"extension"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"format"}B= defined $opts->{"extension"}
ABresult
0X0
100
111
407 0 $$opts{format} = $$opts{extension}; }
408 0 ▶ if ((!defined $$opts{extension}) && (defined $$opts{format})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"extension"} and defined $opts->{"format"}) 0 0 0
Condition0%0/3
not defined $opts->{"extension"} and defined $opts->{"format"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"extension"} and defined $opts->{"format"}
not defined $opts->{"extension"} defined $opts->{"format"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"extension"}B= defined $opts->{"format"}
ABresult
0X0
100
111
409 0 ▶ if ($$opts{format} =~ /^html/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->{'format'} =~ /^html/) { } 0 0 0
elsif ($opts->{'format'} =~ /^xhtml/) { } 0 0 0
410 0 $$opts{extension} = 'html'; }
411 elsif ($$opts{format} =~ /^xhtml/) {
412 0 $$opts{extension} = 'xhtml'; }
413 else {
414 0 $$opts{extension} = 'xml'; } }
415 0 ▶ if (!defined $$opts{whatsout}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"whatsout"}) 0 0 0
416 0 ▶ if ((defined $$opts{extension}) && ($$opts{extension} eq 'zip')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{'extension'} and $opts->{'extension'} eq 'zip') { } 0 0 0
Condition0%0/3
defined $opts->{"extension"} and $opts->{"extension"} eq "zip"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts->{"extension"} and $opts->{"extension"} eq "zip"
defined $opts->{"extension"} $opts->{"extension"} eq "zip"
Truth table0%0/3
A and B
A= defined $opts->{"extension"}B= $opts->{"extension"} eq "zip"
ABresult
0X0
100
111
417 0 $$opts{whatsout} = 'archive';
418 } else {
419 0 $$opts{whatsout} = 'document';
420 } }
421 0 ▶ if ($$opts{format}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'format'}) { } 0 0 0
422 # Lower-case for sanity's sake
423 0 $$opts{format} = lc($$opts{format});
424 0 ▶ if ($$opts{format} eq 'zip') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'format'} eq 'zip') { } 0 0 0
425 # Not encouraged! But try to produce something sensible anyway...
426 0 $$opts{format} = 'html5';
427 0 $$opts{whatsout} = 'archive'; }
428 else { # Default HTML is 5
429 0 ▶ $$opts{format} = 'html5' if $$opts{format} eq 'html'; }
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "html" 0 0 0
430  
431 0 $$opts{is_html} = ($$opts{format} =~ /^html/);
432 0 $$opts{is_xhtml} = ($$opts{format} =~ /^(xhtml5?|epub|mobi)$/);
433 0 ▶ $$opts{whatsout} = 'archive' if (($$opts{format} eq 'epub') || ($$opts{format} eq 'mobi'));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi" 0 0 0
Condition0%0/3
$opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi"
$opts->{"format"} eq "epub" $opts->{"format"} eq "mobi"
Truth table0%0/3
A or B
A= $opts->{"format"} eq "epub"B= $opts->{"format"} eq "mobi"
ABresult
1X1
011
000
434 } else {
435 0 $$opts{format} = 'xml' # We failed to guess format in any-which-way, so XML is default
436 }
437 #======================================================================
438 # II. Sanity check and Completion of Post options.
439 #======================================================================
440 # Any post switch implies post (TODO: whew, lots of those, add them all!):
441 0 ▶ $$opts{math_formats} = [] unless defined $$opts{math_formats};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"math_formats"} 0 0 0
442 $$opts{post} = 1 if ((!defined $$opts{post}) &&
443 0 ▶ (scalar(@{ $$opts{math_formats} })
Condition0%0/5
$opts->{'format'} || ''
l!l
00
$opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
!ll&&!rl&&r
000
MC/DC0%0/1
$opts->{'format'} || ''
$opts->{'format'}
MC/DC0%0/2
$opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
$opts->{"whatsout"} $opts->{"whatsout"} ne "document"
Truth table0%0/2
A
A= $opts->{'format'}
Aresult
11
00
Truth table0%0/3
A and B
A= $opts->{"whatsout"}B= $opts->{"whatsout"} ne "document"
ABresult
0X0
100
111
444 || ($$opts{stylesheet})
445 || $$opts{is_html}
446 || $$opts{is_xhtml}
447 || (($$opts{format} || '') eq 'jats')
448 0 ▶ || ($$opts{whatsout} && ($$opts{whatsout} ne 'document'))
Branch: 1 branch
BranchTrueFalseTotal
if not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document" 0 0 0
Condition0%0/18
not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document"
!ll&&!rl&&r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"} or ($opts->{"format"} || "") eq "jats" or $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"} or ($opts->{"format"} || "") eq "jats"
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"}
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"}
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"}
l!l&&r!l&&!r
000
MC/DC0%0/7
not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document"
not defined $opts->{"post"} scalar @{$opts->{"math_formats"};} $opts->{"stylesheet"} $opts->{"is_html"} $opts->{"is_xhtml"} ($opts->{"format"} || "") eq "jats" $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
Truth table0%0/8
not(A) and B or C or D or E or F or G
A= not defined $opts->{"post"}B= scalar @{$opts->{"math_formats"};}C= $opts->{"stylesheet"}D= $opts->{"is_html"}E= $opts->{"is_xhtml"}F= ($opts->{"format"} || "") eq "jats"G= $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
ABCDEFGresult
0XXXXXX0
10000000
11XXXXX1
101XXXX1
1001XXX1
10001XX1
100001X1
10000011
449 )
450 );
451 # || ... || ... || ...
452 # $$opts{post}=0 if (defined $$opts{mathparse} && (! $$opts{mathparse})); # No-parse overrides post-processing
453 0 ▶ if ($$opts{post}) { # No need to bother if we're not post-processing
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"post"}) 0 0 0
454 # Default: scan and crossref on, other advanced off
455 0 ▶ $$opts{prescan} = undef unless defined $$opts{prescan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"prescan"} 0 0 0
456 0 ▶ $$opts{dbfile} = undef unless defined $$opts{dbfile};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"dbfile"} 0 0 0
457 0 ▶ $$opts{scan} = 1 unless defined $$opts{scan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"scan"} 0 0 0
458 0 ▶ $$opts{index} = 1 unless defined $$opts{index};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"index"} 0 0 0
459 0 ▶ $$opts{crossref} = 1 unless defined $$opts{crossref};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"crossref"} 0 0 0
460 $$opts{sitedirectory} = defined $$opts{sitedirectory} ? $$opts{sitedirectory}
461 : (defined $$opts{destination} ? pathname_directory($$opts{destination})
462 : (defined $$opts{dbfile} ? pathname_directory($$opts{dbfile})
463 0 ▶ : "."));
Branch: 3 branches
BranchTrueFalseTotal
defined $opts->{'sitedirectory'} ? : 0 0 0
defined $opts->{'destination'} ? : 0 0 0
defined $opts->{'dbfile'} ? : 0 0 0
464 0 ▶ $$opts{sourcedirectory} = undef unless defined $$opts{sourcedirectory};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"sourcedirectory"} 0 0 0
465 0 ▶ $$opts{numbersections} = 1 unless defined $$opts{numbersections};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"numbersections"} 0 0 0
466 0 ▶ $$opts{navtoc} = undef unless defined $$opts{numbersections};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"numbersections"} 0 0 0
467 0 ▶ $$opts{navtocstyles} = { context => 1, normal => 1, none => 1 } unless defined $$opts{navtocstyles};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"navtocstyles"} 0 0 0
468 0 ▶ $$opts{navtoc} = lc($$opts{navtoc}) if defined $$opts{navtoc};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{"navtoc"} 0 0 0
469 0 ▶ delete $$opts{navtoc} if ($$opts{navtoc} && ($$opts{navtoc} eq 'none'));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"navtoc"} and $opts->{"navtoc"} eq "none" 0 0 0
Condition0%0/3
$opts->{"navtoc"} and $opts->{"navtoc"} eq "none"
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"navtoc"} and $opts->{"navtoc"} eq "none"
$opts->{"navtoc"} $opts->{"navtoc"} eq "none"
Truth table0%0/3
A and B
A= $opts->{"navtoc"}B= $opts->{"navtoc"} eq "none"
ABresult
0X0
100
111
470  
471 0 ▶ if ($$opts{navtoc}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"navtoc"}) 0 0 0
472 0 ▶ if (!$$opts{navtocstyles}->{ $$opts{navtoc} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"navtocstyles"}{$opts->{"navtoc"}}) 0 0 0
473 0 croak($$opts{navtoc} . " is not a recognized style of navigation TOC"); }
474 0 ▶ if (!$$opts{crossref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"crossref"}) 0 0 0
475 0 croak("Cannot use option \"navigationtoc\" (" . $$opts{navtoc} . ") without \"crossref\""); } }
476 0 ▶ $$opts{urlstyle} = 'server' unless defined $$opts{urlstyle};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"urlstyle"} 0 0 0
477 0 ▶ $$opts{bibliographies} = [] unless defined $$opts{bibliographies};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"bibliographies"} 0 0 0
478  
479 # Validation:
480 0 ▶ $$opts{validate} = 1 unless defined $$opts{validate};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"validate"} 0 0 0
481 # Graphics:
482 0 ▶ $$opts{mathimagemag} = 1.75 unless defined $$opts{mathimagemag};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"mathimagemag"} 0 0 0
483 0 ▶ if ((defined $$opts{destination}) || ($$opts{whatsout} =~ /^archive/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/) 0 0 0
Condition0%0/3
defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/
defined $opts->{"destination"} $opts->{"whatsout"} =~ /^archive/
Truth table0%0/3
A or B
A= defined $opts->{"destination"}B= $opts->{"whatsout"} =~ /^archive/
ABresult
1X1
011
000
484 # We want the graphics enabled by default, but only when we have a destination
485 0 ▶ $$opts{dographics} = 1 unless defined $$opts{dographics};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"dographics"} 0 0 0
486 $$opts{picimages} = 1 if (($$opts{format} eq "html4") || ($$opts{format} eq "jats"))
487 0 ▶ && !defined $$opts{picimages};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"} 0 0 0
Condition0%0/6
$opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"}
!ll&&!rl&&r
000
$opts->{"format"} eq "html4" or $opts->{"format"} eq "jats"
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"}
$opts->{"format"} eq "html4" $opts->{"format"} eq "jats" not defined $opts->{"picimages"}
Truth table0%0/5
A or B and not(C)
A= $opts->{"format"} eq "html4"B= $opts->{"format"} eq "jats"C= not defined $opts->{"picimages"}
ABCresult
00X0
1X00
0100
1X11
0111
488 }
489 # Split sanity:
490 0 ▶ if ($$opts{split}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"split"}) 0 0 0
491 0 ▶ $$opts{splitat} = 'section' unless defined $$opts{splitat};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitat"} 0 0 0
492 0 ▶ $$opts{splitnaming} = 'id' unless defined $$opts{splitnaming};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitnaming"} 0 0 0
493 $$opts{splitancestors} = {
494 0 part => [qw()],
495 chapter => [qw(part)],
496 section => [qw(part chapter)],
497 subsection => [qw(part chapter section)],
498 subsubsection => [qw(part chapter section subsection)] };
499 0 $$opts{splitback} = [qw(bibliography appendix index)];
500  
501 $$opts{splitnaming} = _checkOptionValue('--splitnaming', $$opts{splitnaming},
502 0 qw(id idrelative label labelrelative));
503 0 $$opts{splitat} = _checkOptionValue('--splitat', $$opts{splitat}, CORE::keys %{ $$opts{splitancestors} });
504 0 ▶ $$opts{splitpath} = make_splitpaths($opts, $$opts{splitat}) unless defined $$opts{splitpath}; }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitpath"} 0 0 0
505 # Check for appropriate combination of split, scan, prescan, dbfile, crossref
506 0 ▶ if ($$opts{split} && (!defined $$opts{destination}) && ($$opts{whatsout} !~ /^archive/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/) 0 0 0
Condition0%0/6
$opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/
!ll&&!rl&&r
000
$opts->{"split"} and not defined $opts->{"destination"}
!ll&&!rl&&r
000
MC/DC0%0/3
$opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/
$opts->{"split"} not defined $opts->{"destination"} not $opts->{"whatsout"} =~ /^archive/
Truth table0%0/4
A and not(B) and not(C)
A= $opts->{"split"}B= not defined $opts->{"destination"}C= not $opts->{"whatsout"} =~ /^archive/
ABCresult
0XX0
10X0
1100
1111
507 0 croak("Must supply --destination when using --split"); }
508 0 ▶ if ($$opts{prescan} && !$$opts{scan}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"prescan"} and not $opts->{"scan"}) 0 0 0
Condition0%0/3
$opts->{"prescan"} and not $opts->{"scan"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"prescan"} and not $opts->{"scan"}
$opts->{"prescan"} not $opts->{"scan"}
Truth table0%0/3
A and not(B)
A= $opts->{"prescan"}B= not $opts->{"scan"}
ABresult
0X0
100
111
509 0 croak("Makes no sense to --prescan with scanning disabled (--noscan)"); }
510 0 ▶ if ($$opts{prescan} && (!defined $$opts{dbfile})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"prescan"} and not defined $opts->{"dbfile"}) 0 0 0
Condition0%0/3
$opts->{"prescan"} and not defined $opts->{"dbfile"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"prescan"} and not defined $opts->{"dbfile"}
$opts->{"prescan"} not defined $opts->{"dbfile"}
Truth table0%0/3
A and not(B)
A= $opts->{"prescan"}B= not defined $opts->{"dbfile"}
ABresult
0X0
100
111
511 0 croak("Cannot prescan documents (--prescan) without specifying --dbfile"); }
512 0 ▶ if (!$$opts{prescan} && $$opts{crossref} && !($$opts{scan} || (defined $$opts{dbfile}))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and $opts->{"crossref"}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'dbfile'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}
not $opts->{"prescan"} $opts->{"crossref"} $opts->{'scan'} defined $opts->{'dbfile'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= $opts->{"crossref"}C= $opts->{'scan'}D= defined $opts->{'dbfile'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
513 0 croak("Cannot cross-reference (--crossref) without --scan or --dbfile "); }
514 0 ▶ if ($$opts{crossref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"crossref"}) 0 0 0
515 0 $$opts{urlstyle} = _checkOptionValue('--urlstyle', $$opts{urlstyle}, qw(server negotiated file)); }
516 0 ▶ if (($$opts{permutedindex} || $$opts{splitindex}) && (!defined $$opts{index})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}) 0 0 0
Condition0%0/6
$opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}
!ll&&!rl&&r
000
$opts->{"permutedindex"} or $opts->{"splitindex"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}
$opts->{"permutedindex"} $opts->{"splitindex"} not defined $opts->{"index"}
Truth table0%0/5
A or B and not(C)
A= $opts->{"permutedindex"}B= $opts->{"splitindex"}C= not defined $opts->{"index"}
ABCresult
00X0
1X00
0100
1X11
0111
517 0 $$opts{index} = 1; }
518 0 ▶ if (!$$opts{prescan} && $$opts{index} && !($$opts{scan} || defined $$opts{crossref})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and $opts->{"index"}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'crossref'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}
not $opts->{"prescan"} $opts->{"index"} $opts->{'scan'} defined $opts->{'crossref'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= $opts->{"index"}C= $opts->{'scan'}D= defined $opts->{'crossref'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
519 0 croak("Cannot generate index (--index) without --scan or --dbfile"); }
520 0 ▶ if (!$$opts{prescan} && @{ $$opts{bibliographies} } && !($$opts{scan} || defined $$opts{crossref})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and @{$opts->{"bibliographies"};}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'crossref'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}
not $opts->{"prescan"} @{$opts->{"bibliographies"};} $opts->{'scan'} defined $opts->{'crossref'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= @{$opts->{"bibliographies"};}C= $opts->{'scan'}D= defined $opts->{'crossref'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
521 0 croak("Cannot generate bibliography (--bibliography) without --scan or --dbfile"); }
522  
523 # There is now a legitimate case to preserve graphics here.
524 # if ((!defined $$opts{destination}) && ($$opts{whatsout} !~ /^archive/)
525 # && (_checkMathFormat($opts, 'images') || _checkMathFormat($opts, 'svg')
526 # || $$opts{dographics} || $$opts{picimages})) {
527 # croak("Must supply --destination unless all auxilliary file writing is disabled"
528 # . "(--nomathimages --nomathsvg --nographicimages --nopictureimages --nodefaultcss)"); }
529  
530 # Format:
531 #Default is XHTML, XML otherwise (TODO: Expand)
532 0 ▶ if (!defined $$opts{format}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"format"}) 0 0 0
533 0 ▶ if ($$opts{stylesheet}) { $$opts{format} = "xml"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'stylesheet'}) { } 0 0 0
534 0 else { $$opts{format} = "xhtml"; }
535 }
536  
537 0 ▶ if (!$$opts{stylesheet}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"stylesheet"}) 0 0 0
538 0 ▶ if ($$opts{format} eq 'xhtml') { $$opts{stylesheet} = "LaTeXML-xhtml.xsl"; }
Branch: 6 branches
BranchTrueFalseTotal
if ($opts->{'format'} eq 'xhtml') { } 0 0 0
elsif ($opts->{'format'} eq 'html4') { } 0 0 0
elsif ($opts->{'format'} =~ /^epub|mobi$/) { } 0 0 0
elsif ($opts->{'format'} eq 'html5') { } 0 0 0
elsif ($opts->{'format'} eq 'jats') { } 0 0 0
elsif ($opts->{'format'} eq 'xml') { } 0 0 0
539 0 elsif ($$opts{format} eq "html4") { $$opts{stylesheet} = "LaTeXML-html4.xsl"; }
540 0 elsif ($$opts{format} =~ /^epub|mobi$/) { $$opts{stylesheet} = "LaTeXML-epub3.xsl"; }
541 0 elsif ($$opts{format} eq "html5") { $$opts{stylesheet} = "LaTeXML-html5.xsl"; }
542 0 elsif ($$opts{format} eq "jats") { $$opts{stylesheet} = "LaTeXML-jats.xsl"; }
543 0 elsif ($$opts{format} eq "xml") { delete $$opts{stylesheet}; }
544 0 else { croak("Unrecognized target format: " . $$opts{format}); }
545 }
546 # Check format and complete math and image options
547 0 ▶ if ($$opts{format} eq 'html4') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"format"} eq "html4") 0 0 0
548 0 ▶ $$opts{svg} = 0 unless defined $$opts{svg}; # No SVG by default in HTML.
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"svg"} 0 0 0
549 0 croak("Default html4 stylesheet only supports math images, not " . join(', ', @{ $$opts{math_formats} }))
550 if (!defined $$opts{stylesheet})
551 0 ▶ && scalar(grep { $_ ne 'images' } @{ $$opts{math_formats} });
Branch: 1 branch
BranchTrueFalseTotal
if not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};}) 0 0 0
Condition0%0/2
not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};})
!ll
00
MC/DC0%0/1
not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};})
not defined $opts->{"stylesheet"}
Truth table0%0/2
not(A)
A= not defined $opts->{"stylesheet"}
Aresult
00
11
552 0 ▶ croak("Default html stylesheet does not support svg") if $$opts{svg};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"svg"} 0 0 0
553 0 $$opts{math_formats} = [];
554 0 maybeAddMathFormat($opts, 'images');
555 }
556 0 ▶ $$opts{svg} = 1 unless defined $$opts{svg}; # If we're not making HTML, SVG is on by default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"svg"} 0 0 0
557 # PMML default if we're HTMLy and all else fails and no mathimages:
558 0 ▶ if (((!defined $$opts{math_formats}) || (!scalar(@{ $$opts{math_formats} })))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats") 0 0 0
Condition0%0/12
not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats"
!ll&&!rl&&r
000
defined $opts->{'math_formats'} && scalar @{$opts->{'math_formats'};}
!ll&&!rl&&r
000
$opts->{"is_html"} or $opts->{"is_xhtml"} or $opts->{"format"} eq "jats"
l!l&&r!l&&!r
000
$opts->{"is_html"} or $opts->{"is_xhtml"}
l!l&&r!l&&!r
000
MC/DC0%0/5
not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats"
defined $opts->{'math_formats'} scalar @{$opts->{'math_formats'};} $opts->{"is_html"} $opts->{"is_xhtml"} $opts->{"format"} eq "jats"
Truth table0%0/9
not(A && B) and C or D or E
A= defined $opts->{'math_formats'}B= scalar @{$opts->{'math_formats'};}C= $opts->{"is_html"}D= $opts->{"is_xhtml"}E= $opts->{"format"} eq "jats"
ABCDEresult
11XXX0
0X0000
100000
0X1XX1
0X01X1
0X0011
101XX1
1001X1
100011
559 && ($$opts{is_html} || $$opts{is_xhtml} || ($$opts{format} eq 'jats'))) {
560 0 CORE::push @{ $$opts{math_formats} }, 'pmml';
561 }
562 # use parallel markup if there are multiple formats requested.
563 0 ▶ $$opts{parallelmath} = 1 if ($$opts{math_formats} && (@{ $$opts{math_formats} } > 1));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1 0 0 0
Condition0%0/3
$opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1
$opts->{"math_formats"} @{$opts->{"math_formats"};} > 1
Truth table0%0/3
A and B
A= $opts->{"math_formats"}B= @{$opts->{"math_formats"};} > 1
ABresult
0X0
100
111
564 }
565 # If really nothing hints to define format, then default it to XML
566 0 ▶ $$opts{format} = 'xml' unless defined $$opts{format};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"format"} 0 0 0
567 0 $$self{dirty} = 0;
568 0 return; }
569  
570 ## Public Utilities:
571  
572 0 ▶sub addMathFormat {
Subroutine addMathFormat: not called CC=4 SCAR=30.0
Pod undocumented
573 0 my ($opts, $fmt) = @_;
574 0 ▶ $$opts{math_formats} = [] unless defined $$opts{math_formats};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"math_formats"} 0 0 0
575 0 CORE::push(@{ $$opts{math_formats} }, $fmt)
576 0 ▶ unless (grep { $_ eq $fmt } @{ $$opts{math_formats} }) || $$opts{removed_math_formats}->{$fmt};
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt} 0 0 0
Condition0%0/3
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} $opts->{"removed_math_formats"}{$fmt}
Truth table0%0/3
A or B
A= grep {$_ eq $fmt;} @{$$opts{"math_formats"};}B= $opts->{"removed_math_formats"}{$fmt}
ABresult
1X1
011
000
577 0 return; }
578  
579 0 ▶sub removeMathFormat {
Subroutine removeMathFormat: not called CC=1 SCAR=6.9
Pod undocumented
580 0 my ($opts, $fmt) = @_;
581 0 @{ $$opts{math_formats} } = grep { $_ ne $fmt } @{ $$opts{math_formats} };
582 0 $$opts{removed_math_formats}->{$fmt} = 1;
583 0 return; }
584  
585 # Add a default math format, when no math formatter is requested, unless specifically forbidden
586 0 ▶sub maybeAddMathFormat {
Subroutine maybeAddMathFormat: not called CC=3 SCAR=24.8
Pod undocumented
587 0 my ($opts, $fmt) = @_;
588 0 unshift(@{ $$opts{math_formats} }, $fmt)
589 0 ▶ unless @{ $$opts{math_formats} } || $$opts{removed_math_formats}{$fmt};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$opts->{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt} 0 0 0
Condition0%0/3
@{$opts->{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$opts->{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
@{$opts->{"math_formats"};} $opts->{"removed_math_formats"}{$fmt}
Truth table0%0/3
A or B
A= @{$opts->{"math_formats"};}B= $opts->{"removed_math_formats"}{$fmt}
ABresult
1X1
011
000
590 0 return; }
591  
592 0 ▶sub _checkMathFormat {
Subroutine _checkMathFormat: not called CC=1 SCAR=6.9
593 0 my ($opts, $fmt) = @_;
594 0 return grep { $_ eq $fmt } @{ $$opts{math_formats} }; }
595  
596 ## Utilities:
597  
598 0 ▶sub _checkOptionValue {
Subroutine _checkOptionValue: not called CC=4 SCAR=30.0
599 0 my ($option, $value, @choices) = @_;
600 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 0 0 0
601 0 foreach my $choice (@choices) {
602 0 ▶ return $choice if substr($choice, 0, length($value)) eq $value; } }
Branch: 1 branch
BranchTrueFalseTotal
if substr($choice, 0, length $value) eq $value 0 0 0
603 0 croak("Value for $option, $value, doesn't match " . join(', ', @choices)); }
604  
605 # Contrived xpath, since backmatter can now be at any level!
606 0 ▶sub make_splitpaths {
Subroutine make_splitpaths: not called CC=4 SCAR=30.0
Pod undocumented
607 0 my ($opts, $splitat) = @_;
608 0 my @paths = ();
609 0 my $anc = $$opts{splitancestors}{$splitat};
610 0 ▶ foreach my $unit ($splitat, ($anc ? @$anc : ())) {
Branch: 1 branch
BranchTrueFalseTotal
$anc ? : 0 0 0
611 0 CORE::push(@paths, "//ltx:$unit");
612 0 foreach my $back (@{ $$opts{splitback} }) {
613 CORE::push(@paths, "//ltx:$back\["
614 . join(' or ', "preceding-sibling::ltx:$unit",
615 0 map { "parent::ltx:$_"; } @{ $$opts{splitancestors}{$unit} })
616 . "]"); } }
617 0 return join(' | ', @paths); }
618  
619 ### This is from t/lib/TestDaemon.pm and ideally belongs in Util::Pathname
620 0 ▶sub _read_options_file {
Subroutine _read_options_file: not called CC=14 SCAR=53.5
621 0 my ($file) = @_;
622 0 my $opts = [];
623 0 my $OPT;
624 #### Now can we report status to right places before we've gotten configuration??? (verbosity, logfile...)
625 #### ProgressSpinup("Loading profile $file");
626 0 ▶ unless (open($OPT, "<", $file)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $OPT, "<", $file) 0 0 0
627 0 Error('expected', $file, "Could not open options file '$file'");
628 0 return; }
629 0 ▶ while (my $line = <$OPT>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $OPT)) 0 0 0
630 # Cleanup comments, padding on the input line.
631 0 $line =~ s/(?<!\\)#.*$//; # Strip trailing comments starting w/ # (but \# is quoted)
632 0 $line =~ s/\\#/#/g; # unslashify any \#
633 0 $line =~ s/^\s+//; # Trim leading & trailing whitespace
634 0 $line =~ s/\s+$//;
635 0 ▶ next unless $line; # if line isn't empty, after that.....
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 0 0
636 0 chomp($line);
637 0 ▶ if ($line =~ /(\S+)\s*=\s*(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(\S+)\s*=\s*(.*)/) { } 0 0 0
638 0 ▶ my ($key, $value) = ($1, $2 || '');
Condition0%0/2
$2 || ''
l!l
00
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
Aresult
11
00
639 0 $value =~ s/\s+$//;
640 # Special treatment for --path=$env:
641 0 ▶ if ($value =~ /^\$(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\$(.+)$/) { } 0 0 0
642 0 my @values = ();
643 0 my $env_name = $1;
644 0 my $env_value;
645 # Allow $env/foo paths, starting with $env prefixes
646 0 ▶ if ($env_name =~ /^([^\/]+)(\/+)(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env_name =~ m[^([^/]+)(/+)(.+)$]) { } 0 0 0
647 0 my $trailer = $3;
648 0 ▶ if (my $env_path = $ENV{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $env_path = $ENV{$1}) 0 0 0
649 0 ▶ $env_path .= '/' unless $env_path =~ /\/$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $env_path =~ m[/$] 0 0 0
650 0 CORE::push @values, $env_path . $trailer; } }
651 else {
652 # But also the standard behaviour, where the $env is an array of paths
653 0 $env_value = $ENV{$env_name};
654 0 ▶ next unless $env_value;
Branch: 1 branch
BranchTrueFalseTotal
unless $env_value 0 0 0
655 0 @values = grep { -d $_ } reverse(split(':', $env_value));
656 0 ▶ next unless @values; }
Branch: 1 branch
BranchTrueFalseTotal
unless @values 0 0 0
657 0 CORE::push(@$opts, "--$key=$_") foreach (@values); }
658 else {
659 0 ▶ $value = $value ? "=$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
660 0 CORE::push @$opts, "--$key" . $value; } }
661 else {
662 0 Warning('unexpected', $line, undef,
663 "Unrecognized configuration data '$line'"); }
664 }
665 0 close $OPT;
666 #### ProgressSpindown("Loading profile $file");
667 0 return $opts; }
668  
669 5 1;
670  
671 __END__
« lib/LaTeXML/MathGrammar.pm ↑ Summary lib/LaTeXML/Util/Image.pm »