| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of Docbook::Convert. | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Full license text is available at: | ||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||
| 11 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # Package Constants | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | package Docbook::Convert::Constant; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # Compiler Pragma | ||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT %Constant); ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | no warnings qw(uninitialized); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # External modules | ||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||
| 30 | 5 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Data Dumper formatting | ||||||||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||||||||
| 36 | 5 | $Data::Dumper::Indent=1; | |||||||||||||||||||||||||||
| 37 | 5 | $Data::Dumper::Terse=1; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # Version information in a format suitable for CPAN etc. Must be | ||||||||||||||||||||||||||||
| 41 | # all on one line | ||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||
| 43 | 5 | $VERSION='1.012'; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | #=================================================================================================== | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # Get module file name and path, derive name of file where local constants stored. e.g. | ||||||||||||||||||||||||||||
| 50 | # <perl lib>/Package/Constant.local will override anything in Constant.pm | ||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||
| 52 | 5 | my $module_fn=abs_path(__FILE__); | |||||||||||||||||||||||||||
| 53 | 5 | my $constant_local_fn="${module_fn}.local"; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Constants | ||||||||||||||||||||||||||||
| 57 | # <<< | ||||||||||||||||||||||||||||
| 58 | %Constant=( | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # XML Data array index locations | ||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||
| 62 | NODE_IX => 0, | ||||||||||||||||||||||||||||
| 63 | CHLD_IX => 1, | ||||||||||||||||||||||||||||
| 64 | ATTR_IX => 2, | ||||||||||||||||||||||||||||
| 65 | LINE_IX => 3, | ||||||||||||||||||||||||||||
| 66 | COLM_IX => 4, | ||||||||||||||||||||||||||||
| 67 | PRNT_IX => 5, | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | # Handler nicknames | ||||||||||||||||||||||||||||
| 71 | # | ||||||||||||||||||||||||||||
| 72 | HANDLER_HR => { | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | markdown => 'Docbook::Convert::Markdown', | ||||||||||||||||||||||||||||
| 75 | md => 'Docbook::Convert::Markdown' | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # Default handler | ||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||
| 82 | HANDLER_DEFAULT => 'markdown', | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # Markdown separators | ||||||||||||||||||||||||||||
| 86 | # | ||||||||||||||||||||||||||||
| 87 | CR => $/, | ||||||||||||||||||||||||||||
| 88 | CR2 => $/ x 2, | ||||||||||||||||||||||||||||
| 89 | SP => ' ', | ||||||||||||||||||||||||||||
| 90 | SP4 => ' ' x 4, | ||||||||||||||||||||||||||||
| 91 | SP8 => ' ' x 8, | ||||||||||||||||||||||||||||
| 92 | NULL => \undef, | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # Don't escape the following Docbook tags in Markdown converter | ||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||
| 97 | MD_DONT_ESCAPE_AR => [qw( | ||||||||||||||||||||||||||||
| 98 | command | ||||||||||||||||||||||||||||
| 99 | screen | ||||||||||||||||||||||||||||
| 100 | arg | ||||||||||||||||||||||||||||
| 101 | markup | ||||||||||||||||||||||||||||
| 102 | programlisting | ||||||||||||||||||||||||||||
| 103 | term | ||||||||||||||||||||||||||||
| 104 | code | ||||||||||||||||||||||||||||
| 105 | option | ||||||||||||||||||||||||||||
| 106 | ) | ||||||||||||||||||||||||||||
| 107 | ], | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | # Anything below these tags is plaintext - don't markup further | ||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||
| 112 | MD_PLAINTEXT_HR => { | ||||||||||||||||||||||||||||
| 113 | 15 | map {$_ => 1} | |||||||||||||||||||||||||||
| 114 | qw( | ||||||||||||||||||||||||||||
| 115 | table | ||||||||||||||||||||||||||||
| 116 | screen | ||||||||||||||||||||||||||||
| 117 | programlisting | ||||||||||||||||||||||||||||
| 118 | ) | ||||||||||||||||||||||||||||
| 119 | }, | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # Adminition Text | ||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||
| 124 | ADMONITION_TEXT_HR => { | ||||||||||||||||||||||||||||
| 125 | note => 'NOTE', | ||||||||||||||||||||||||||||
| 126 | warning => 'WARNING', | ||||||||||||||||||||||||||||
| 127 | caution => 'CAUTION', | ||||||||||||||||||||||||||||
| 128 | tip => 'TIP', | ||||||||||||||||||||||||||||
| 129 | important => 'IMPORTANT' | ||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | # Refentry Text | ||||||||||||||||||||||||||||
| 134 | # | ||||||||||||||||||||||||||||
| 135 | REFENTRY_TEXT_HR => { | ||||||||||||||||||||||||||||
| 136 | synopsis => 'SYNOPSIS', | ||||||||||||||||||||||||||||
| 137 | name => 'NAME' | ||||||||||||||||||||||||||||
| 138 | }, | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # Tag synonyms for Markdown | ||||||||||||||||||||||||||||
| 142 | # | ||||||||||||||||||||||||||||
| 143 | MD_TAG_SYNONYM_HR => { | ||||||||||||||||||||||||||||
| 144 | _text => [qw(replaceable)] | ||||||||||||||||||||||||||||
| 145 | }, | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | # Common tag synonyms | ||||||||||||||||||||||||||||
| 149 | # | ||||||||||||||||||||||||||||
| 150 | ALL_TAG_SYNONYM_HR => { | ||||||||||||||||||||||||||||
| 151 | command => [qw(classname parameter filename markup)], | ||||||||||||||||||||||||||||
| 152 | sect1 => [qw(section)], | ||||||||||||||||||||||||||||
| 153 | refsection => [qw(refsect1)], | ||||||||||||||||||||||||||||
| 154 | para => [qw(simpara)], | ||||||||||||||||||||||||||||
| 155 | warning => [qw(caution important note tip)], | ||||||||||||||||||||||||||||
| 156 | code => [qw(option varname tag)], | ||||||||||||||||||||||||||||
| 157 | link => [qw(xref application)], | ||||||||||||||||||||||||||||
| 158 | term => [qw(guilabel guibutton)], | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | #figure => [qw(screenshot)], | ||||||||||||||||||||||||||||
| 161 | article => [qw(refentry)], | ||||||||||||||||||||||||||||
| 162 | _text => [qw(literallayout orgname firstname surname example qandaentry)], | ||||||||||||||||||||||||||||
| 163 | _data => [qw(imageobject)], | ||||||||||||||||||||||||||||
| 164 | _null => [qw(refentryinfo articleinfo tgroup)], | ||||||||||||||||||||||||||||
| 165 | _meta => [qw(author affiliation pubdate address copyright)] | ||||||||||||||||||||||||||||
| 166 | }, | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # Delay render of mediaobject tag if any of these in parent - potentially | ||||||||||||||||||||||||||||
| 170 | # allows more info to be build into image | ||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||
| 172 | MEDIAOBJECT_DELAY_RENDER_AR => [ | ||||||||||||||||||||||||||||
| 173 | qw(figure) | ||||||||||||||||||||||||||||
| 174 | ], | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # Metadata render options | ||||||||||||||||||||||||||||
| 178 | # | ||||||||||||||||||||||||||||
| 179 | META_DISPLAY_TOP => 0, | ||||||||||||||||||||||||||||
| 180 | META_DISPLAY_BOTTOM => 0, | ||||||||||||||||||||||||||||
| 181 | META_DISPLAY_TITLE => undef, | ||||||||||||||||||||||||||||
| 182 | META_DISPLAY_TITLE_H_STYLE => 'h2', | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # Default formatting/output options | ||||||||||||||||||||||||||||
| 186 | # | ||||||||||||||||||||||||||||
| 187 | NO_HTML => 0, | ||||||||||||||||||||||||||||
| 188 | NO_IMAGE_FETCH => 0, | ||||||||||||||||||||||||||||
| 189 | NO_WARN_UNHANDLED => 0, | ||||||||||||||||||||||||||||
| 190 | XMLSUFFIX => '.xml', | ||||||||||||||||||||||||||||
| 191 | VERBOSE => 0, | ||||||||||||||||||||||||||||
| 192 | DEBUG => 0, | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # Constants that can be set via getopt | ||||||||||||||||||||||||||||
| 196 | # | ||||||||||||||||||||||||||||
| 197 | GETOPT_CONSTANT_HR => { | ||||||||||||||||||||||||||||
| 198 | meta_display_top => undef, | ||||||||||||||||||||||||||||
| 199 | meta_display_bottom => undef, | ||||||||||||||||||||||||||||
| 200 | meta_display_title => '=s', | ||||||||||||||||||||||||||||
| 201 | meta_display_title_h_style => '=s', | ||||||||||||||||||||||||||||
| 202 | md_section_num => undef, | ||||||||||||||||||||||||||||
| 203 | no_html => undef, | ||||||||||||||||||||||||||||
| 204 | no_image_fetch => undef, | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | #no_warn_unhandled => undef, | ||||||||||||||||||||||||||||
| 207 | xmlsuffix => '|x=s', | ||||||||||||||||||||||||||||
| 208 | }, | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # Other options | ||||||||||||||||||||||||||||
| 212 | # | ||||||||||||||||||||||||||||
| 213 | GETOPT_AR => [ | ||||||||||||||||||||||||||||
| 214 | ( | ||||||||||||||||||||||||||||
| 215 | 'help|?', | ||||||||||||||||||||||||||||
| 216 | 'man', | ||||||||||||||||||||||||||||
| 217 | 'version|V', | ||||||||||||||||||||||||||||
| 218 | 'dump', | ||||||||||||||||||||||||||||
| 219 | 'dumpopt', | ||||||||||||||||||||||||||||
| 220 | 'outfile|out|o=s', | ||||||||||||||||||||||||||||
| 221 | 'infile|in|f=s@', | ||||||||||||||||||||||||||||
| 222 | 'recurse|r', | ||||||||||||||||||||||||||||
| 223 | 'recursedir|d=s', | ||||||||||||||||||||||||||||
| 224 | 'markdown|md', | ||||||||||||||||||||||||||||
| 225 | 'no_warn_unhandled|silent|quiet|s|q', | ||||||||||||||||||||||||||||
| 226 | 'handler|h=s', | ||||||||||||||||||||||||||||
| 227 | 'verbose', | ||||||||||||||||||||||||||||
| 228 | 'debug' | ||||||||||||||||||||||||||||
| 229 | ) | ||||||||||||||||||||||||||||
| 230 | ], | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # Detailed backtrace ? | ||||||||||||||||||||||||||||
| 234 | # | ||||||||||||||||||||||||||||
| 235 | ERR_BACKTRACE => 0, | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | # Table/Text wrap columns size (i.e. max col width of text in a single cell) | ||||||||||||||||||||||||||||
| 239 | # | ||||||||||||||||||||||||||||
| 240 | TABLE_WRAP_COLUMNS => 40, | ||||||||||||||||||||||||||||
| 241 | TABLE_WRAP_HUGE => 'overflow', | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # LWP Timeout | ||||||||||||||||||||||||||||
| 245 | # | ||||||||||||||||||||||||||||
| 246 | LWP_TIMEOUT => 10, | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # Local constants override anything above | ||||||||||||||||||||||||||||
| 250 | # | ||||||||||||||||||||||||||||
| 251 | 5 | %{do($constant_local_fn)} | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | # >>> | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | # Export constants to namespace, place in export tags | ||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||
| 260 | 5 | require Exporter; | |||||||||||||||||||||||||||
| 261 | 5 | @ISA=qw(Exporter); | |||||||||||||||||||||||||||
| 262 | 5 | ▶ | foreach (keys %Constant) {${$_}=defined $ENV{$_} ? $Constant{$_}=eval($ENV{$_}) || $ENV{$_} : $Constant{$_}} ## no critic | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
eval $ENV{$_} || $ENV{$_}
MC/DC0%0/2
eval $ENV{$_} || $ENV{$_}
eval $ENV{$_}
$ENV{$_}
Truth table0%0/3
A || B
A= eval $ENV{$_}B= $ENV{$_}
| |||||||||||||||||||||||||||||
| 263 | 5 | @EXPORT=map {'$' . $_} keys %Constant; | |||||||||||||||||||||||||||
| 264 | 5 | @EXPORT_OK=@EXPORT; | |||||||||||||||||||||||||||
| 265 | 5 | %EXPORT_TAGS=(all => [@EXPORT_OK]); | |||||||||||||||||||||||||||
| 266 | 5 | $_=\%Constant; | |||||||||||||||||||||||||||
| 267 | 5 | 1; | |||||||||||||||||||||||||||
| 268 | __END__ | ||||||||||||||||||||||||||||