File Coverage

lib/Pod/WikiText.pm
Criterion Covered Total %
statement 273 615 44.3
branch 56 194 28.8
condition 25 56 44.6
subroutine 30 48 62.5
pod 0 40 0.0
total 384 953 40.2


line stmt bran cond sub pod time code
1             package Pod::WikiText;
2              
3             =head1 NAME
4              
5             Pod::WikiText - Support for the use of Wiki markup.
6              
7             =head1 SUMMARY
8              
9             Support the use of Wiki markup for general documentation purposes. This
10             module uses the Text-Tiki module for markup support. The purpose of this
11             module is to provide a convenient way to incorporate Wiki markup into
12             lots of different types of documents including, but not limited to, your
13             own Perl source files.
14              
15             =head1 SYNOPSIS
16              
17             use Pod::WikiText;
18              
19             my $formatter = Pod::WikiText->new(
20             format => 'html',
21             author => 'Brad Adkins',
22             infile => 'test.pl',
23             outfile => 'stdout',
24             title => 'Example',
25             );
26              
27             $formatter->format;
28              
29             You can create multiple Pod::WikiText objects if needed.
30              
31             =head1 RATIONALE
32              
33             Provided an alternative for documentation of Perl source files which allows
34             the use of a robust flavor of Wiki markup in place of POD markup. This
35             allows the creation of more expressive POD in your Perl source files, and
36             hence better documentation when published.
37              
38             =head1 DESCRIPTION
39              
40             POD sections in source files are marked in the standard way with 'begin' and
41             'cut' tags. The 'begin' tag must be followed by the keyword 'wiki', as in:
42             "=begin wiki". (See this source file for examples.)
43              
44             This module can be used for many purporses beyond Perl source documentation.
45             Presentations and other forms of documentaiton are candiates for use. This is
46             possible because the markup support provided by the Text::Tiki module is very
47             good, and several options are provided by Pod::WikiText specifically with
48             general documentation purposes in mind.
49              
50             Caveat: You should probably not use WikiText as POD in source files that you
51             plan to upload to CPAN, unless you include normal POD as well. :-)
52              
53             =head1 ADDITIONAL INFORMATION
54              
55             Please see the WikiText documentation embedded in this source file for additional
56             details on how to use WikiText.pm. You can view this documentation using
57             WikiText.pm itself to format the WikiText content in this file. Hint: download and
58             install WikiText.pm.
59              
60             Thank you!
61              
62             =head1 COPYRIGHT
63              
64             Copyright 2008 Brad Adkins .
65              
66             Permission is granted to copy, distribute and/or modify this document under the
67             terms of the GNU Free Documentation License, published by the Free Software
68             Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no
69             Back-Cover Texts.
70              
71             =head1 AUTHOR
72              
73             Brad Adkins, dbijcl@gmail.com
74              
75             =cut
76              
77             =begin wiki
78              
79             !1 NAME
80              
81             Pod::WikiText.pm
82              
83             Support for Wiki markup in POD.
84              
85             ----
86              
87             !1 SYNOPSIS
88              
89             % language=Perl
90             % use Pod::WikiText;
91             %
92             % my $formatter = Pod::WikiText->new(
93             % author => 'Brad Adkins',
94             % infile => 'test.pl',
95             % outfile => 'stdout'
96             % title => 'Example'
97             % );
98             %
99             % $formatter->format;
100             %%
101              
102             You can create multiple Pod::WikiText objects if needed.
103              
104             ----
105              
106             !1 RATIONALE
107              
108             Provided an alternative for documentation of Perl source files which allows \
109             the use of a robust flavor of Wiki markup in place of POD markup. This \
110             allows the creation of more expressive POD in your Perl source files, and \
111             hence better documentation when published.
112              
113             ----
114              
115             !1 DESCRIPTION
116              
117             POD sections in source files are marked in the standard way with 'begin' \
118             and 'cut' tags. The 'begin' tag must be followed by the keyword 'wiki', as in: \
119             "=begin wiki". (See this source file for examples.)
120              
121             This module can be used for many purporses beyond Perl source documentation. \
122             Presentations and other forms of documentaiton are candiates for use. This is \
123             possible because the markup support provided by the Text::Tiki module is very \
124             good, and several options are provided by Pod::WikiText specifically with \
125             general documentation purposes in mind.
126              
127             ----
128              
129             !1 OPTIONS
130              
131             The primary option is the /format/ option. This options is used to select the \
132             output format.
133              
134             Usage: -format=/option_value/
135              
136             |*option values*|*description*|
137             |/html/ | Output embedded pod as html|
138             |/text/ | Output embedded pod as text|
139             |/slideshow/ | Output embedded pod as html slideshow|
140             |/reference/ | Output embedded pod and code as html|
141             |/codetext/ | Output code as text|
142             |/codehtml/ | Output code as html|
143              
144             The remaining options are used to tailor the output generated by the selected \
145             format.
146              
147             ----
148              
149             !1 AUTOMATION
150              
151             To process multiple files, you simply create a new WikiText object for each \
152             file. Something like this should suffice.
153              
154             % language=Perl
155             % foreach my $file ( @files ) {
156             % my $formatter = Pod::WikiText->new( format => 'html',
157             % author => 'Brad Adkins',
158             % infile => $file,
159             % outfile => 'stdout'
160             % title => 'Example'
161             % );
162             % $formatter->format;
163             % undef $formatter;
164             % }
165             %%
166              
167             Using undef on the old WikiText object saves a small amount of memory when \
168             creating multiple objects.
169              
170             ----
171              
172             !1 WIKI MARKUP
173              
174             Pod::WikiText uses the Text::Tiki module for base markup processing. Please \
175             refer to the POD in that module for additional details and explanation of the \
176             markup capabilities provided by Text::Tiki.
177              
178             ----
179              
180             !1 ADDITIONAL MARKUP
181              
182             Several customizations to the Tiki html output are implemented in this module.
183              
184             /*Genearating a Table of Contents*/
185              
186             If the 'toc' parameter is set to 'yes' when creating a new Pod::WikiText \
187             object, a Table of Contents will be inserted at the beginning of the html \
188             output. Level 1 thru level 4 headings in the source document will generate \
189             entries in the Table of Contents.
190              
191             /*Syntax highlighting of code blocks*/
192              
193             Code blocks prefaced with ' % ' starting in column 1 will be syntax highlighted. \
194             You will need to install the Syntax::Highlight::Engine::Kate module. This module \
195             provides syntax highlighting as implemented in the Kate text editor.
196              
197             The first line of a code block to be highlighted is a command that tells the
198             highlighter what language to use, here is an example for Perl.
199              
200             % language=Perl
201             % if ( $self->{_toc} ) {
202             % $html = $self->create_toc . $html;
203             % }
204             %%
205              
206             /*Insert non-breaking space into table cells for better padding*/
207              
208             Non-breaking spaces are added around cell contents to provide visual appeal.
209              
210             /*Allow cells which contain a period in column one to be empty cells*/
211              
212             This:
213              
214             |col1|col2 is longer|col3|
215             |col1|.|col3|
216             |.|col2|col3 is longer too|
217              
218             Will produce:
219              
220             |col1|col2 is longer|col3|
221             |col1|.|col3|
222             |.|col2|col3 is longer too|
223              
224             /*Allow line breaks inside table cells*/
225              
226             Allow a line break within a table cell using the break macro '##BR##'.
227              
228             This:
229              
230             |col1|col2 is longer|col3|
231             |col1|col2|col3|
232             |col1|col2|col3 is longer too##BR##And has multiple##BR##lines of text|
233              
234             Will produce:
235              
236             |col1|col2 is longer|col3|
237             |col1|col2|col3|
238             |col1|col2|col3 is longer too##BR##And has multiple##BR##lines of text|
239              
240             /*Add support for table borders*/
241              
242             Use the parameter 'borders' when creating Pod::WikiText objects to control the \
243             use of borders on all html tables.
244              
245             /* Add support for table borders on a table-by-table basis*/
246              
247             Allow borders to be defined for individual tables using the border macros \
248             '##BORDER 0##' and '##BORDER 1##' for no borders and borders, respectively.
249              
250             This:
251              
252             Will produce:
253              
254             /*Add support for table row background color*/
255              
256             Allow a table row to have a specified background color using the macro \
257             '##BGxxxxxx###', where 'xxxxxx' is a hex color code.
258              
259             This:
260              
261             Will produce:
262              
263             ----
264              
265             !1 META TAGS
266              
267             Pod::WikiText supports several meta tags that can be used in source files for \
268             various purposes.
269              
270             The first set of meta tags are used to support source files maintained using \
271             the Foldmaster programmer's editor (http://foldmaster.de). These tags are used \
272             by Foldmaster to indicate explicit folds within the source file. These are:
273              
274             | *Meta Tag* |*Description*|
275             | %##{{{% |start fold in .pl and .pm files|
276             | %##}}}% |end fold in .pl and .pm files|
277             | %(*{{{% |start fold in .wiki and .txt files|
278             | %(*}}}% |end fold in lwiki and .txt files|
279              
280             The second set of meta tags can be inserted in the source document to provide \
281             file specific options. These tags must begin in column 1.
282              
283             | *Meta Tag* |*Description*|
284             | %##file:% |file name (not used at this time)|
285             | %##dir:% |file path (not used at this time)|
286             | %##remote:% |remote path (not used at this time)|
287             | %##clearcase:% |ClearCase path (not used at this time)|
288             | %##head:% |header (overrides header parameter)|
289             | %##foot:% |footer (overrides footer parameter)|
290             | %##url:% |for web browser invocation|
291             | %##publish:% |for publishing generated html|
292             | %##author:% |for the html header|
293             | %##title:% |for the html header|
294              
295             These are all tags recognized in the source file when processed. Those not \
296             yet implemented are simply ignored.
297              
298             ----
299              
300             !1 Development Notes
301              
302             The following notes are largely intended for the developer (me), but you may
303             find them informative.
304              
305             !2 Format Option
306              
307             * /V/ html
308             * /V/ text
309             * /V/ reference
310             * /V/ codetext
311             * /V/ codehtml
312              
313             !2 Additional Options
314              
315             * /V/ section
316             * /V/ infile
317             * /V/ outfile
318             * /V/ author
319             * /V/ title
320             * /V/ useheader
321             * /V/ header
322             * /V/ usefooter
323             * /V/ footer
324             * /V/ toc
325             * /V/ navigation
326             * /V/ borders
327             * /V/ wrapcol
328             * /V/ codelabels
329             * /V/ language
330             * /V/ startinpod
331             * /V/ linkback
332             * /V/ debug
333              
334             !2 Current Enhancements
335              
336             * /V/ Html header and footer
337             * /V/ Genearate a Table of Contents
338             * /V/ Syntax Highlighting of code blocks
339             * /V/ Insert space into table cells for better padding
340             * /V/ Allow cells which contain a period in column one to be empty cells
341             * /V/ Allow line breaking inside of table cells
342             * /V/ Allow global document setting of table borders
343             * /V/ Support for replacement after Tiki markup
344             * /V/ Support for borders/noborders within table source
345             * /V/ Support for linkback html at beginning of document
346             * /V/ Variable substitution in document header and footer
347             * /V/ Provided a full complement of "setters"
348             * /V/ Add support for table row background color
349             * /V/ Add support for table cell background color
350             * /V/ Correct problem where table is followed immediately by
351             * /V/ Support use of an svg "checkmark" image
352              
353             /V/ = Latin for Veritas, or "truth", signifying the item has been completed.
354              
355             !2 To Do - Support Scripts
356              
357             * wthtml.pl
358             * wttext.pl
359             * wtreference.pl
360             * wtcodetext.pl
361             * wtcodehtml.pl
362              
363             These will gather the appropriate command line parameters. Provide format \
364             specific help, and invoke Pod::WikiText for that particular format type.
365              
366             These utilities also provide conf file storage for their respective defaults.
367              
368             !2 Documentation
369              
370             * Show this table for all options that are specific to only certain table \
371             types, just give a list of the others.
372              
373             |*format* |*option1*|*option2*|*option3*|*option4*|
374             |html |yes |no |yes |no |
375             |text |yes |no |yes |no |
376             |reference|yes |no |yes |no |
377             |codetext |yes |no |yes |no |
378             |codehtml |yes |no |yes |no |
379              
380             !2 Tests
381              
382             Tests beyond the basic "can load" need to be written.
383              
384             !2 Future Enhancements
385              
386             * Allow user specified ignore "meta tags"
387             * Allow optional custom style sheet (external style sheet)
388             * Allow optional background image (format html only)
389              
390             ----
391              
392             =cut
393              
394 2     2   62184 use strict;
  2         5  
  2         71  
395 2     2   18 use warnings;
  2         3  
  2         60  
396 2     2   18 use Carp;
  2         3  
  2         177  
397 2     2   11 use Cwd;
  2         17  
  2         118  
398 2     2   10 use File::Spec;
  2         3  
  2         48  
399 2     2   2725 use Text::Wrap;
  2         6795  
  2         136  
400 2     2   2205 use Text::Tiki;
  2         13735  
  2         91  
401 2     2   10583 use Syntax::Highlight::Engine::Kate;
  2         42596  
  2         17147  
402              
403             our $VERSION = "0.12";
404             our $PROGRAMNAME = "WikiText";
405              
406             my (%docinfo,@aotoc,%hotoc,@inpod,@lines,@format,@nonformat);
407             my $debug = 0;
408             my $sysdate = localtime();
409             $sysdate =~ s/ \d\d:\d\d:\d\d/,/;
410             $sysdate =~ s/ / /g;
411             my @file_management_keys = (
412             "file","directory","clearcase","ftp","publish","url"
413             );
414             my @object_param_keys = (
415             "format","section","infile","outfile","author","title","header","useheader",
416             "footer","usefooter","toc","navigation","borders","wrapcol","codelabels",
417             "usesvg","language","startinpod","linkback","debug","outdir"
418             );
419              
420             =begin wiki
421              
422             !1 METHODS
423              
424             !2 Public Methods
425              
426             !3 Method new
427              
428             /Parameters/
429              
430             The constructor method supports the following named arguments.
431              
432             |*Parameter* |*Default* |*Value*|
433             |%format% |required |valid opiton ^1^|
434             |%section% |none |a level 1 heading|
435             |%infile% |required |filename|
436             |%outfile% |required |filename|
437             |%outdir% |optional |directory|
438             |%author% |none |html meta author|
439             |%title% |none |html title|
440             |%header% |none |WikiText markup|
441             |%useheader% |no |yes/no|
442             |%footer% |basic footer |WikiText markup|
443             |%usefooter% |yes |yes/no|
444             |%toc% |yes |yes/no|
445             |%navigation% |no |yes/no|
446             |%borders% |yes |yes/no|
447             |%wrapcol% |72 |numeric|
448             |%codelabels% |yes |yes/no|
449             |%usesvg% |yes |yes/no|
450             |%startinpod% |no |yes/no|
451             |%linkback% |none |html|
452             |%debug% |no |yes/no|
453              
454             ^1^ Valid format options: html, text, reference, codetext, codehtml
455              
456             /Description/
457              
458             This is the class constructor. Use this method to create new Pod::WikiText \
459             objects.
460              
461             /Test/
462              
463             %insert name of test script here%
464              
465             =cut
466              
467             sub new {
468 2     2 0 1859 my ($class, %arg) = @_;
469              
470 2         13 my $sig = "

Created using $PROGRAMNAME, Version $VERSION
$sysdate

";
471              
472 2   50     1746 my $podwikitext = bless {
      50        
      33        
      100        
      50        
      50        
      50        
      50        
      50        
      33        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
      50        
473             _format => lc($arg{format}) || "html",
474             _section => $arg{section} || '',
475             _infile => $arg{infile} || croak("no infile given"),
476             _outfile => $arg{outfile} || "stdout",
477             _outdir => $arg{outdir} || '',
478             _author => $arg{author} || '', ## for html head
479             _title => $arg{title} || '', ## for html head
480             _header => $arg{header} || '',
481             _useheader => lc($arg{useheader}) || "no",
482             _footer => $arg{footer} || $sig,
483             _usefooter => lc($arg{usefooter}) || "yes",
484             _toc => lc($arg{toc}) || "yes",
485             _navigation => lc($arg{navigation}) || "no",
486             _borders => lc($arg{borders}) || "yes",
487             _wrapcol => $arg{wrapcol} || 72,
488             _codelabels => lc($arg{codelabels}) || "yes",
489             _usesvg => lc($arg{usesvg}) || "yes",
490             _language => $arg{language} || "Perl",
491             _startinpod => lc($arg{startinpod}) || "no",
492             _linkback => $arg{linkback} || "",
493             _debug => lc($arg{debug}) || "no",
494             }, $class;
495              
496 2 50       47 croak("param 'format' invalid") unless $podwikitext->{_format} =~ /html|text|reference|codetext|codehtml/;
497 2 50       50 croak("param 'infile' not found") unless -e $podwikitext->{_infile};
498 2 50       16 croak("param 'useheader' invalid") unless $podwikitext->{_useheader} =~ /yes|no/;
499 2 50       13 croak("param 'usefooter' invalid") unless $podwikitext->{_usefooter} =~ /yes|no/;
500 2 50       14 croak("param 'toc' invalid") unless $podwikitext->{_toc} =~ /yes|no/;
501 2 50       12 croak("param 'navigation' invalid") unless $podwikitext->{_navigation} =~ /yes|no/;
502 2 50       13 croak("param 'borders' invalid") unless $podwikitext->{_borders} =~ /yes|no/;
503 2 50       13 croak("param 'codelabels' invalid") unless $podwikitext->{_codelabels} =~ /yes|no/;
504 2 50       13 croak("param 'usesvg' invalid") unless $podwikitext->{_usesvg} =~ /yes|no/;
505 2 50       14 croak("param 'startinpod' invalid") unless $podwikitext->{_startinpod} =~ /yes|no/;
506 2 50       12 croak("param 'debug' invalid") unless $podwikitext->{_debug} =~ /yes|no/;
507              
508             ## may also be specified in the source document
509 2         6 $docinfo{author} = $podwikitext->{_author};
510 2         5 $docinfo{title} = $podwikitext->{_title};
511 2         7 $docinfo{linkback} = $podwikitext->{_linkback};
512              
513 2         4 $podwikitext->{_bordertype} = 'hidden';
514 2 50       9 if ( $podwikitext->{_borders} eq "yes" ) {
515 2         6 $podwikitext->{_bordertype} = 'solid';
516             }
517              
518 2 50       12 if ( $podwikitext->{_debug} eq 'yes' ) { $debug = 1; } ## turn debug on
  0         0  
519              
520 2         9 return $podwikitext;
521             }
522              
523             =begin wiki
524              
525             !3 Method get_param
526              
527             /Parameters/
528              
529             * %$self% - reference to our object
530             * %$key% - the parameter name
531              
532             /Description/
533              
534             Return the value associated with parameter $key.
535              
536             /Test/
537              
538             %insert name of test script here%
539              
540             =cut
541              
542             sub get_param {
543 0     0 0 0 my ($self, $ukey) = @_;
544 0         0 my $val = '';
545              
546 0         0 my $key = '_'.$ukey;
547 0 0       0 if ( defined $self->{$key} ) { $val = $self->{$key}; }
  0         0  
548 0         0 return $val;
549             }
550              
551             =begin wiki
552              
553             !3 Method set_param
554              
555             /Parameters/
556              
557             * %$self% - reference to our object
558             * %$key% - the parameter name
559             * %$val% - the value to use
560              
561             /Description/
562              
563             Set a new value for the parameter $key using value $val.
564              
565             /Test/
566              
567             %insert name of test script here%
568              
569             =cut
570              
571             sub set_param {
572 0     0 0 0 my ($self, $ukey, $val) = @_;
573              
574 0         0 my $key = '_'.$ukey;
575 0 0       0 if ( is_valid_param( $key ) ) {
576 0         0 $self->{$key} = $val;
577             } else {
578 0         0 $val = '';
579             }
580 0         0 return $val;
581             }
582              
583             =begin wiki
584              
585             !3 Method get_sections
586              
587             /Parameters/
588              
589             * %$self% - reference to our object
590              
591             /Description/
592              
593             Return a list of all the level one heading titless contained within the \
594             current document.
595              
596             /Test/
597              
598             %insert name of test script here%
599              
600             =cut
601              
602             sub get_sections {
603 0     0 0 0 my $self = shift;
604 0         0 my @sections;
605              
606 0         0 $self->read_input;
607              
608 0         0 foreach my $toce ( @aotoc ) {
609 0         0 my $title = $toce->{line};
610 0 0       0 next unless $toce->{line} =~ /^!1 /;
611 0         0 $title =~ s/^![1-4]{1,1} //;
612 0         0 push @sections, $title;
613             }
614              
615 0         0 return @sections;
616             }
617              
618             =begin wiki
619              
620             !3 Method set_section
621              
622             /Parameters/
623              
624             * %$self% - reference to our object
625             * %$section% - Title of section to set
626              
627             /Description/
628              
629             Set the section title to the desired title.
630              
631             /Test/
632              
633             %insert name of test script here%
634              
635             =cut
636              
637             sub set_section {
638 0     0 0 0 my ($self,$section) = @_;
639 0         0 $self->{_section} = $section;
640 0         0 return 0;
641             }
642              
643             =begin wiki
644              
645             !3 Method is_section
646              
647             /Parameters/
648              
649             * %$self% - reference to our object
650             * %section% - A level one heading to verify
651              
652             /Description/
653              
654             Verify that the level one heading provided exists in the current document.
655              
656             /Test/
657              
658             %insert name of test script here%
659              
660             =cut
661              
662             sub is_section {
663 0     0 0 0 my ($self,$section) = @_;
664              
665 0         0 $self->read_input;
666              
667 0         0 my $found = 0;
668 0         0 foreach my $toce ( @aotoc ) {
669 0         0 my $title = $toce->{line};
670 0 0       0 if ( $toce->{line} =~ /^!1 / ) {;
671 0         0 $title =~ s/^!1 //;
672 0 0       0 if ( $title eq $section ) {
673 0         0 $found = 1;
674 0         0 last;
675             }
676             }
677             }
678              
679 0         0 return $found;
680             }
681              
682             =begin wiki
683              
684             !3 Method format
685              
686             /Parameters/
687              
688             * %$self% - reference to our object
689              
690             /Description/
691              
692             /Test/
693              
694             %insert name of test script here%
695              
696             =cut
697              
698             sub format {
699 1     1 0 6 my $self = shift;
700              
701 1         6 $self->read_input;
702 1 50       9 if ( $debug ) { $self->debug_read; }
  0         0  
703              
704 1 50       5 if ( $self->{_format} eq "html" ) {
705 1         5 $self->format_html;
706             }
707 1 50       5 if ( $self->{_format} eq "text" ) {
708 0         0 $self->format_text;
709             }
710 1 50       5 if ( $self->{_format} eq "reference" ) {
711 0         0 $self->format_reference;
712             }
713 1 50       4 if ( $self->{_format} eq "codetext" ) {
714 0         0 $self->format_codetext;
715             }
716 1 50       7 if ( $self->{_format} eq "codehtml" ) {
717 0         0 $self->format_codehtml;
718             }
719             }
720              
721             =begin wiki
722              
723             !2 Private Methods
724              
725             /Test/
726              
727             %insert name of test script here%
728              
729             !3 Function is_valid_param
730              
731             /Parameters/
732              
733             * %$key% - paramater to check
734              
735             /Description/
736              
737             Check object supplied value to see if it is a valid object paramter.
738              
739             /Test/
740              
741             %insert name of test script here%
742              
743             =cut
744              
745             sub is_valid_param {
746 0     0 0 0 my $key = shift;
747              
748 0         0 $key =~ s/^_//;
749 0 0       0 if ( $key =~ /format|section|infile|outfile|author|title|header|useheader|
750             footer|usefooter|toc|navigation|borders|wrapcol|startinpod|
751             linkback|debug|outdir/x ) {
752 0         0 return 1;
753             }
754 0         0 return 0;
755             }
756              
757             =begin wiki
758              
759             !3 Function init_stores
760              
761             /Parameters/
762              
763             None
764              
765             /Description/
766              
767             Initialize module level data stores to empty state.
768              
769             /Test/
770              
771             %insert name of test script here%
772              
773             =cut
774              
775             sub init_stores {
776 1     1 0 2 my $self = shift;
777              
778 1         2 @aotoc = ();
779 1         2 %hotoc = ();
780 1         2 @inpod = ();
781 1         2 @lines = ();
782 1         2 @format = ();
783 1         2 @nonformat = ();
784              
785 1         2 return 0;
786             }
787              
788             =begin wiki
789              
790             !3 Function read_input
791              
792             /Parameters/
793              
794             * %$self% - reference to our object
795              
796             Sets:
797              
798             * %@lines% - all lines from input file
799             * %@aotoc% - array of header line information
800             * %@hotoc% - hash of header line information
801             * %@inpod% - flags indicating pod or non-pod line
802              
803             /Description/
804              
805             Read the contents of the file into three arrays. These arrays form the raw \
806             data for input to Text::Tiki.
807              
808             /Test/
809              
810             %insert name of test script here%
811              
812             =cut
813              
814             sub read_input {
815 1     1 0 31 my $self = shift;
816              
817 1         3 my $infile = $self->{_infile};
818              
819 1         4 $self->init_stores;
820              
821 1         1 my $inpod = 0;
822              
823 1         2 my $beginfold = '^beginfold\{\{\{'; ## default
824 1         2 my $endfold = '^endfold\}\}\}'; ## default
825              
826             ## initialize source editor meta tags
827 1 50       23 if ( $infile =~ /\.pl$|\.pm$/ ) { ## recognize Foldmaster 'source' files
828 0         0 $beginfold = '^\#{1,2}\{\{\{';
829 0         0 $endfold = '^\#{1,2}\}\}\}';
830 0         0 $inpod = 0;
831             }
832 1 50       7 if ( $infile =~ /\.txt$|\.wiki$/ ) { ## recognize Foldmaster 'text' files
833 1         2 $beginfold = '^\(\*\{\{\{';
834 1         1 $endfold = '^\(\*\}\}\}';
835 1         2 $inpod = 1;
836             }
837              
838 1 50       4 if ( $self->{_startinpod} eq "yes" ) {
839 0         0 $inpod = 1;
840             }
841              
842 1         1 my $line = ''; ## line continuation buffer
843 1         1 my $linenum = 0; ## current line number
844 1         2 my $prevtoc = 0; ## previous toc entry
845              
846 1 50       40 open(my $fh, "<", $infile) or die "unable to open $infile";
847 1         26 while ( <$fh> ) {
848 24         26 chomp;
849              
850             ## check for source editor meta tags
851 24 50       74 if ( /$beginfold/ ) {
852 0         0 push @lines, "";
853 0         0 next;
854             }
855 24 50       57 if ( /$endfold/ ) {
856             ##push @lines, "";
857 0         0 next;
858             }
859              
860             ## depricated tags
861 24 50       44 if ( /^\#\#(\@\@|\$\$|\/\/)/ ) { ##@@, @@$$ ##// are depricated
862 0         0 next;
863             }
864              
865             ## comment tag
866 24 50       37 if ( /^\#\#:/ ) { ##: is a comment tag
867 0         0 next;
868             }
869              
870             ## load document information from meta tags
871 24 100       47 if ( /^\#\#([a-z]+):(.*)/ ) {
872 5         12 my $key = $1;
873 5         8 my $val = $2;
874 5         9 $val =~ s/\s+$//;
875 5         11 $docinfo{$key} = $val;
876 5         21 next;
877             }
878              
879             ## check for pod status
880 19 100       32 if ( /^=begin wiki/ ) { $inpod = 1; next; } ## =cut
  1         3  
  1         3  
881 18 50       29 if ( /^=cut/ ) { $inpod = 0; next; }
  0         0  
  0         0  
882              
883             ## save headings information
884 18 100       36 if ( /^!([1-4]{1,1}) / ) {
885 4         11 my $toc_entry = $_;
886 4         7 my $toc_level = $1;
887 4         5 my $id = $_;
888 4         12 $id =~ s/^![1-4]{1,1} //; ## remove header markup
889 4         8 $id =~ s/[^\s\w\d]+//g; ## remove non alpha/ws characters
890 4         10 $id =~ s/\b([a-z])/\u\L$1/g; ## proper case
891 4         15 $id =~ s/\s+//g; ## remove whitespace
892 4         21 push @aotoc, { ## array of toc entries
893             line => $toc_entry,
894             anchor => $id,
895             level => $toc_level,
896             };
897 4         11 my $key = sprintf("%05d", $linenum);
898 4 100       10 if ( $toc_level == 1 ) { ## hash of level 1 toc entries
899 1         5 $hotoc{$key} = {
900             line => $toc_entry,
901             anchor => $id,
902             prevtoc => $prevtoc,
903             nexttoc => 0,
904             };
905 1         7 $prevtoc = $key;
906             }
907 4         8 push @lines, $key.':'.$toc_entry; ## "key" the heading
908 4         5 push @inpod, $inpod;
909 4         4 $linenum++;
910 4         11 next;
911             }
912              
913             ## store the line or cat to line continuation buffer
914 14         17 $line .= $_;
915 14 50       27 if ( /\\$|\\\s+$/ ) { ## line continuation found
916 0         0 $line =~ s/\\\s+$/ /; ## replace \ + ws
917 0         0 $line =~ s/\s+\\\n$/ /; ## replace ws + \ + \n
918 0         0 $line =~ s/\s+\\$/ /; ## replace ws + \
919 0         0 next;
920             } else {
921 14         19 push @lines, $line;
922 14         16 push @inpod, $inpod;
923 14         16 $line = '';
924 14         37 $linenum++;
925             }
926             }
927 1         13 close $fh;
928              
929             ## finish headings linked list
930 1         5 foreach my $toc ( reverse sort keys %hotoc ) {
931 1         3 my $prevtoc = $hotoc{$toc}{prevtoc};
932 1 50       6 if ( $prevtoc > 0 ) {
933 0         0 $hotoc{$prevtoc}{nexttoc} = $toc;
934             }
935             }
936              
937             ## update object params from doc info, all params are fair game
938 1         4 foreach my $key ( keys %docinfo ) {
939 6         12 $key = lc($key);
940 6         14 $self->{'_'.$key} = $docinfo{$key};
941             }
942              
943 1 50       6 if ( $self->{_debug} eq "yes" ) { $self->debug_params; }
  0         0  
944              
945 1         5 return 0;
946             }
947              
948             =begin wiki
949              
950             !3 Function format_html
951              
952             /Parameters/
953              
954             /Description/
955              
956             /Test/
957              
958             %insert name of test script here%
959              
960             =cut
961              
962             sub format_html {
963 1     1 0 2 my $self = shift;
964              
965 1 50       4 if ( $self->{_section} ) {
966 0         0 $self->prep_html_section;
967             } else {
968 1         5 $self->prep_html;
969             }
970 1 50       4 if ( $debug ) { $self->debug_prep; }
  0         0  
971              
972 1         19 my $formatter = Text::Tiki->new;
973 1         41 my $html = $formatter->format(\@format);
974              
975 1 50 33     2299 if ( ( $self->{_toc} eq "yes" ) && ( ! $self->{_section} ) ) {
976 1         6 $html = $self->create_toc . $html;
977             }
978              
979 1         7 $self->post_process( \$html );
980 1         10 $self->output_format( \$html );
981              
982 1         25 return 0;
983             }
984              
985             =begin wiki
986              
987             !3 Function format_text
988              
989             /Parameters/
990              
991             /Description/
992              
993             /Test/
994              
995             %insert name of test script here%
996              
997             =cut
998              
999             sub format_text {
1000 0     0 0 0 my $self = shift;
1001              
1002 0 0       0 if ( $self->{_section} ) {
1003 0         0 $self->prep_html_section;
1004             } else {
1005 0         0 $self->prep_html;
1006             }
1007 0 0       0 if ( $debug ) { $self->debug_prep; }
  0         0  
1008              
1009 0         0 $self->text_wrap( \@format );
1010 0         0 my $text = join "\n", @format;
1011 0         0 $self->output_format( \$text );
1012              
1013 0         0 return 0;
1014             }
1015              
1016             =begin wiki
1017              
1018             !3 Function format_reference
1019              
1020             /Parameters/
1021              
1022             * %$self% - reference to our object
1023              
1024             /Description/
1025              
1026             This function uses both the @format array and the @nonformat array to build a \
1027             new array of lines to be submitted to the Tiki formatter. Lines in the @nonformat \
1028             array have the 'preformat' string appended to the start of each line. Each \
1029             section of non-pod has a language tag inserted at the beginning of the section. \
1030             The default language is 'Perl', but this can be controlled by the user as a \
1031             parameter when the Pod::WikiText object is created. The key to combining both \
1032             input sources is the @inpod array.
1033              
1034             /Test/
1035              
1036             %insert name of test script here%
1037              
1038             =cut
1039              
1040             sub format_reference {
1041 0     0 0 0 my $self = shift;
1042              
1043 0         0 $self->prep_html;
1044 0 0       0 if ( $debug ) { $self->debug_prep; }
  0         0  
1045              
1046 0         0 my $language = $self->{_language};
1047 0         0 my @rformat = ();
1048 0         0 my $podblock = 1;
1049 0         0 my $line;
1050 0         0 my $i = 0;
1051 0         0 foreach my $ispod ( @inpod ) {
1052 0 0       0 if ( $ispod++ ) {
1053 0 0       0 if ( ! $podblock ) { ## entering first line of pod block
1054 0         0 push @rformat, " %%"; ## end previous code block
1055 0         0 push @rformat, "";
1056 0         0 push @rformat, "/end code block/";
1057 0         0 push @rformat, "";
1058 0         0 $podblock = 1;
1059             }
1060 0         0 $line = shift @format;
1061 0         0 push @rformat, $line;
1062             } else {
1063 0 0       0 if ( $podblock ) { ## entering first line of code block
1064 0         0 push @rformat, ""; ## start a new code block
1065 0         0 push @rformat, "/begin code block/";
1066 0         0 push @rformat, "";
1067 0         0 push @rformat, " % language=$language";
1068 0         0 $podblock = 0;
1069             }
1070 0         0 $line = shift @nonformat;
1071 0         0 push @rformat, " % $line";
1072             }
1073             }
1074              
1075 0 0       0 if ( ! $podblock ) {
1076 0         0 push @rformat, " %%"; ## end previous code block
1077 0         0 push @rformat, "";
1078 0         0 push @rformat, "/end code block/";
1079 0         0 push @rformat, "";
1080             }
1081              
1082 0         0 my $formatter = Text::Tiki->new;
1083 0         0 my $html = $formatter->format(\@rformat);
1084              
1085 0 0       0 if ( $self->{_toc} ) {
1086 0         0 $html = $self->create_toc . $html;
1087             }
1088              
1089 0         0 $self->post_process( \$html );
1090 0         0 $self->html_codeblock_tags( \$html );
1091 0         0 $self->output_format( \$html );
1092              
1093 0         0 return 0;
1094             }
1095              
1096             =begin wiki
1097              
1098             !3 Function format_codetext
1099              
1100             /Parameters/
1101              
1102             /Description/
1103              
1104             /Test/
1105              
1106             %insert name of test script here%
1107              
1108             =cut
1109              
1110             sub format_codetext {
1111 0     0 0 0 my $self = shift;
1112              
1113 0 0       0 if ( $self->{_section} ) {
1114 0         0 $self->prep_html_section;
1115             } else {
1116 0         0 $self->prep_html;
1117             }
1118 0 0       0 if ( $debug ) { $self->debug_prep; }
  0         0  
1119              
1120 0         0 my $text = join "\n", @nonformat;
1121 0         0 $self->output_format( \$text );
1122              
1123 0         0 return 0;
1124             }
1125              
1126             =begin wiki
1127              
1128             !3 Function format_codehtml
1129              
1130             /Parameters/
1131              
1132             /Description/
1133              
1134             /Test/
1135              
1136             %insert name of test script here%
1137              
1138             =cut
1139              
1140             sub format_codehtml {
1141 0     0 0 0 my $self = shift;
1142              
1143 0 0       0 if ( $self->{_section} ) {
1144 0         0 $self->prep_html_section;
1145             } else {
1146 0         0 $self->prep_html;
1147             }
1148 0 0       0 if ( $debug ) { $self->debug_prep; }
  0         0  
1149              
1150 0         0 my @html = map { " % " . $_ . "\n" } @nonformat;
  0         0  
1151 0         0 my $language = " % language=" . $self->{_language} . "\n";
1152 0         0 unshift @html, $language;
1153 0         0 push @html, " %%\n";
1154              
1155 0         0 my $html = join "", @html;
1156              
1157 0         0 $self->html_syntax_highlight( \$html );
1158 0         0 $self->output_format( \$html );
1159              
1160 0         0 return 0;
1161             }
1162              
1163             =begin wiki
1164              
1165             !3 Function prep_html
1166              
1167             /Parameters/
1168              
1169             /Description/
1170              
1171             /Test/
1172              
1173             %insert name of test script here%
1174              
1175             =cut
1176              
1177             sub prep_html {
1178 1     1 0 2 my $self = shift;
1179              
1180 1         2 @format = ();
1181 1         2 @nonformat = ();
1182 1         2 my $i = 0;
1183 1         2 foreach my $line ( @lines ) {
1184 18 50       26 if ( $inpod[$i++] ) {
1185 18 100       34 if ( $line =~ /^(\d{5,5}):!(\d){1,1} / ) { ## level 1 heading
1186 4         7 my $key = $1;
1187 4         5 my $level = $2;
1188 4         14 $line =~ s/^\d{5,5}://;
1189 4 50 66     16 if ( $level == 1 && $self->{_navigation} eq "yes" ) { ## insert nav line
1190 0         0 push @format, $line;
1191 0         0 push @format, ' ';
1192              
1193 0         0 my $nextlink = "Next";
1194 0         0 my $prevlink = "Prev";
1195 0         0 my $nextkey = $hotoc{$key}{nexttoc};
1196 0         0 my $prevkey = $hotoc{$key}{prevtoc};
1197 0 0       0 if ( $nextkey > 0 ) {
1198 0         0 my $nextanchor = "#".$hotoc{$nextkey}{anchor};
1199 0         0 $nextlink = "[Next]:$nextanchor";
1200             }
1201 0 0       0 if ( $prevkey > 0 ) {
1202 0         0 my $prevanchor = "#".$hotoc{$prevkey}{anchor};
1203 0         0 $prevlink = "[Prev]:$prevanchor";
1204             }
1205 0         0 push @format, "$prevlink | $nextlink | [Index]:#WikiIndex00000";
1206 0         0 next;
1207             }
1208             }
1209 18         30 push @format, $line;
1210             } else {
1211 0         0 push @nonformat, $line;
1212             }
1213             }
1214              
1215 1         2 return 0;
1216             }
1217              
1218             =begin wiki
1219              
1220             !3 Function prep_html_section
1221              
1222             /Parameters/
1223              
1224             /Description/
1225              
1226             /Test/
1227              
1228             %insert name of test script here%
1229              
1230             =cut
1231              
1232             sub prep_html_section {
1233 0     0 0 0 my $self = shift;
1234              
1235 0         0 my $section = '!1 ' . $self->{_section};
1236 0         0 my $insection = 0;
1237              
1238 0         0 @format = ();
1239 0         0 my $i = 0;
1240 0         0 foreach my $line ( @lines ) {
1241 0 0       0 if ( $inpod[$i++] ) {
1242 0 0       0 if ( $line =~ /^(\d{5,5}):!(\d){1,1} / ) { ## level 1 heading
1243 0         0 my $key = $1;
1244 0         0 my $level = $2;
1245 0         0 $line =~ s/^\d{5,5}://;
1246 0 0 0     0 if ( $level == 1 && $line eq $section ) {
1247 0         0 $insection = 1;
1248 0         0 push @format, $line;
1249 0         0 push @format, ' ';
1250 0         0 next;
1251             }
1252 0 0 0     0 if ( $level == 1 && $insection ) {
1253 0         0 last;
1254             }
1255             }
1256 0 0       0 if ( $insection ) { push @format, $line; }
  0         0  
1257             }
1258             }
1259              
1260 0         0 return 0;
1261             }
1262              
1263             =begin wiki
1264              
1265             !3 Function post_process
1266              
1267             /Parameters/
1268              
1269             * %$self% - reference to our object
1270             * %$html% - reference to the generated html
1271              
1272             /Description/
1273              
1274             =cut
1275              
1276             sub post_process {
1277 1     1 0 3 my ($self, $html) = @_;
1278              
1279 1 50       5 if ( $self->{_useheader} ) {
1280 1         6 $self->header_vars;
1281 1         4 $$html = $self->{_header} . $$html;
1282             }
1283 1 50       5 if ( $self->{_usefooter} ) {
1284 1         4 $self->footer_vars;
1285 1         3 $$html .= $self->{_footer};
1286             }
1287              
1288 1         7 $self->html_add_cell_spacing( $html );
1289 1         5 $self->html_pad_empty_cells( $html );
1290 1         4 $self->html_insert_checkmarks( $html );
1291 1         4 $self->html_insert_line_breaks( $html );
1292 1         11 $self->html_set_borders( $html );
1293 1         5 $self->html_set_bgcolors( $html );
1294 1         4 $self->html_replace_nul( $html );
1295 1         10 $self->html_fixes( $html );
1296 1         5 $self->html_syntax_highlight( $html );
1297 1         4 $self->html_add_header( $html );
1298 1         4 $self->html_add_footer( $html );
1299              
1300 1         1 return 0;
1301             }
1302              
1303             =begin wiki
1304              
1305             !3 Function output_format
1306              
1307             /Parameters/
1308              
1309             * %$self% - reference to our object - object
1310             * %$output% - reference to output lines
1311              
1312             /Description/
1313              
1314             Write to file.
1315              
1316             =cut
1317              
1318             sub output_format {
1319 1     1 0 2 my ($self, $output) = @_;
1320              
1321 1         3 my $outfile = $self->{_outfile};
1322 1 50       5 if ( $self->{_outdir} ) {
1323 0         0 $outfile = $self->{_outdir} . $outfile;
1324             }
1325 1 50       5 if ( $outfile =~ /stdout/i ) {
1326 0         0 print $$output;
1327             } else {
1328 1 50       161 open(my $fh, ">", $outfile) or die "unable to create $outfile";
1329 1         21 print $fh $$output;
1330 1         63 close $fh;
1331             }
1332              
1333 1         3 return 0;
1334             }
1335              
1336             =begin wiki
1337              
1338             !3 Function create_toc
1339              
1340             /Parameters/
1341              
1342             * %$self% - reference to our object
1343              
1344             /Description/
1345              
1346             Create table of contents html based on entries stored in the @aotoc array.
1347              
1348             /Test/
1349              
1350             %insert name of test script here%
1351              
1352             =cut
1353              
1354             sub create_toc {
1355 1     1 0 3 my $self = shift;
1356              
1357 1         2 my $plevel = 0;
1358 1         2 my $indent = 0;
1359 1         2 my $i = 0;
1360 1         1 my @toclines;
1361              
1362 1         3 my $beginlist = '
    ';
1363 1         2 my $endlist = '';
1364              
1365 1         2 push @toclines, "";
1366 1         3 foreach my $toce ( @aotoc ) {
1367 4         22 my $line = $toce->{line};
1368 4         16 $line =~ s/^![1-4]{1,1} //; ## remove wiki markup
1369 4         6 my $anchor = $toce->{anchor};
1370 4         9 my $level = $toce->{level};
1371              
1372 4 50       11 if ( $level > $plevel ) {
1373 4         6 my $ntags = $level - $plevel;
1374 4         10 for (my $i=1; $i<=$ntags; $i++) {
1375 4         16 push @toclines, ' ' x ($level * 2) . $beginlist;
1376             }
1377 4         15 push @toclines, ' ' x ($level * 2) . "
  • $line
  • ";
    1378             }
    1379 4 50       10 if ( $level == $plevel ) {
    1380 0         0 push @toclines, ' ' x ($level * 2) . "
  • $line
  • ";
    1381             }
    1382 4 50       10 if ( $level < $plevel ) {
    1383 0         0 my $ntags = $plevel - $level;
    1384 0         0 for (my $i=1; $i<=$ntags; $i++) {
    1385 0         0 push @toclines, ' ' x ($level * 2) . $endlist;
    1386             }
    1387 0         0 push @toclines, ' ' x ($level * 2) . "
  • $line
  • ";
    1388             }
    1389             ## next iteration
    1390 4         5 $plevel = $level;
    1391 4         8 $i++;
    1392             }
    1393 1         6 for (my $i=$plevel; $i>0; $i--) {
    1394 4         21 push @toclines, ' ' x ($i * 2) . $endlist;
    1395             }
    1396 1         3 push @toclines, "";
    1397 1         2 push @toclines, "
    ";
    1398              
    1399 1         9 return join("\n", @toclines);
    1400             }
    1401              
    1402             =begin wiki
    1403              
    1404             !3 Function debug_read
    1405              
    1406             /Parameters/
    1407              
    1408             None
    1409              
    1410             /Description/
    1411              
    1412             This function is used to dump the contents of @lines, @aotoc, %hotoc, and \
    1413             @inpod to individual files for inspection.
    1414              
    1415             =cut
    1416              
    1417             sub debug_read {
    1418 0     0 0 0 my $self = shift;
    1419 0         0 my ($db, $i);
    1420              
    1421 0         0 $i = 0;
    1422 0         0 my $file = "_debug_lines.debug";
    1423 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1424 0         0 foreach my $line ( @lines ) {
    1425 0         0 print $db $line, "\n";
    1426             }
    1427 0         0 close($db);
    1428              
    1429 0         0 $i = 0;
    1430 0         0 $file = "_debug_aotoc.debug";
    1431 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1432 0         0 foreach my $toc ( @aotoc ) {
    1433 0         0 print $db "line :";
    1434 0         0 print $db $toc->{line}, "\n";
    1435 0         0 print $db "anchor :";
    1436 0         0 print $db $toc->{anchor}, "\n";
    1437 0         0 print $db "level :";
    1438 0         0 print $db $toc->{level}, "\n";
    1439 0         0 $i++;
    1440             }
    1441 0         0 close($db);
    1442              
    1443 0         0 $i = 0;
    1444 0         0 $file = "_debug_hotoc.debug";
    1445 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1446 0         0 foreach my $toc ( sort keys %hotoc ) {
    1447 0         0 print $db "key :";
    1448 0         0 print $db $toc, "\n";
    1449 0         0 print $db "line :";
    1450 0         0 print $db $hotoc{$toc}{line}, "\n";
    1451 0         0 print $db "anchor :";
    1452 0         0 print $db $hotoc{$toc}{anchor}, "\n";
    1453 0         0 print $db "prevtoc:";
    1454 0         0 print $db $hotoc{$toc}{prevtoc}, "\n";
    1455 0         0 print $db "nexttoc:";
    1456 0         0 print $db $hotoc{$toc}{nexttoc}, "\n";
    1457 0         0 $i++;
    1458             }
    1459 0         0 close($db);
    1460              
    1461 0         0 $i = 0;
    1462 0         0 $file = "_debug_inpod.debug";
    1463 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1464 0         0 foreach my $inpod ( @inpod ) {
    1465 0         0 print $db $inpod, "\n";
    1466             }
    1467 0         0 close($db);
    1468              
    1469 0         0 return 0;
    1470             }
    1471              
    1472             =begin wiki
    1473              
    1474             !3 Function debug_prep
    1475              
    1476             /Parameters/
    1477              
    1478             None
    1479              
    1480             /Description/
    1481              
    1482             This function is used to dump the contents of @format to an individual file \
    1483             for inspection.
    1484              
    1485             =cut
    1486              
    1487             sub debug_prep {
    1488 0     0 0 0 my $self = shift;
    1489 0         0 my ($db, $i);
    1490              
    1491 0         0 $i = 0;
    1492 0         0 my $file = "_debug_format.debug";
    1493 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1494 0         0 foreach my $line ( @format ) {
    1495 0         0 print $db $line, "\n";
    1496             }
    1497 0         0 close($db);
    1498              
    1499 0         0 $i = 0;
    1500 0         0 $file = "_debug_nonformat.debug";
    1501 0 0       0 open($db, ">", $file) or die "unable to open $file";
    1502 0         0 foreach my $line ( @nonformat ) {
    1503 0         0 print $db $line, "\n";
    1504             }
    1505 0         0 close($db);
    1506              
    1507 0         0 return 0;
    1508             }
    1509              
    1510             =begin wiki
    1511              
    1512             !3 Function debug_params
    1513              
    1514             /Parameters/
    1515              
    1516             None
    1517              
    1518             /Description/
    1519              
    1520             This function is used to dump the contents of the document info hash and \
    1521             the object parameters.
    1522              
    1523             =cut
    1524              
    1525             sub debug_params {
    1526 0     0 0 0 my $self = shift;
    1527              
    1528 0         0 my $width = 0;
    1529 0         0 foreach my $key ( @object_param_keys ) {
    1530 0 0       0 if ( length($key) > $width ) { $width = length($key); }
      0         0  
    1531             }
    1532              
    1533 0         0 foreach my $key ( sort @object_param_keys ) {
    1534 0         0 printf("%-${width}s docinfo: ", $key);
    1535 0 0       0 if ( defined $docinfo{$key} ) {
    1536 0         0 print $docinfo{$key};
    1537             } else {
    1538 0         0 print "UNDEFINED";
    1539             }
    1540 0         0 print "\n";
    1541 0         0 printf("%-${width}s object : ", '');
    1542 0 0       0 if ( defined $self->{'_'.$key} ) {
    1543 0         0 print $self->{'_'.$key};
    1544             } else {
    1545 0         0 print "UNDEFINED";
    1546             }
    1547 0         0 print "\n", '-'x(19), "\n";
    1548             }
    1549              
    1550 0         0 return 0;
    1551             }
    1552              
    1553             =begin wiki
    1554              
    1555             !3 Function html_add_cell_spacing
    1556              
    1557             /Parameters/
    1558              
    1559             * %$self% - reference to our object
    1560             * %$html% - reference to the html to be modified
    1561              
    1562             /Description/
    1563              
    1564             /Test/
    1565              
    1566             %insert name of test script here%
    1567              
    1568             =cut
    1569              
    1570             sub html_add_cell_spacing {
    1571 1     1 0 3 my ($self, $html) = @_;
    1572              
    1573 1         3 $$html =~ s//  /gm;
    1574 1         4 $$html =~ s/<\/td>/  <\/td>/gm;
    1575              
    1576 1         2 return 0;
    1577             }
    1578              
    1579             =begin wiki
    1580              
    1581             !3 Function html_pad_empty_cells
    1582              
    1583             /Parameters/
    1584              
    1585             * %$self% - reference to our object
    1586             * %$html% - reference to the html to be modified
    1587              
    1588             /Description/
    1589              
    1590             /Test/
    1591              
    1592             %insert name of test script here%
    1593              
    1594             =cut
    1595              
    1596             sub html_pad_empty_cells {
    1597 1     1 0 2 my ($self, $html) = @_;
    1598              
    1599 1         3 $$html =~ s/  \.  /    /gm;
    1600              
    1601 1         2 return 0;
    1602             }
    1603              
    1604             =begin wiki
    1605              
    1606             !3 Function html_insert_line_breaks
    1607              
    1608             /Parameters/
    1609              
    1610             * %$self% - reference to our object
    1611             * %$html% - reference to the html to be modified
    1612              
    1613             /Description/
    1614              
    1615             ----
    1616              
    1617             =cut
    1618              
    1619             sub html_insert_line_breaks {
    1620 1     1 0 2 my ($self, $html) = @_;
    1621              
    1622 1         3 $$html =~ s/##BR##/  
      /gm;
    1623              
    1624 1         1 return 0;
    1625             }
    1626              
    1627             =begin wiki
    1628              
    1629             !3 Function html_insert_line_breaks
    1630              
    1631             /Parameters/
    1632              
    1633             * %$self% - reference to our object
    1634             * %$html% - reference to the html to be modified
    1635              
    1636             /Description/
    1637              
    1638             ----
    1639              
    1640             =cut
    1641              
    1642             sub html_insert_checkmarks {
    1643 1     1 0 2 my ($self, $html) = @_;
    1644              
    1645 1 50       5 if ( $self->{_usesvg} eq "yes" ) {
    1646 1 50       6 if ( $$html =~ /##CM##/ ) {
    1647 0         0 $$html =~ s/##CM##//gm;
    1648 0         0 $self->write_checkmark_svg;
    1649             }
    1650             } else {
    1651 0         0 $$html =~ s/##CM##/V<\/em>/gm;
    1652             }
    1653              
    1654 1         2 return 0;
    1655             }
    1656              
    1657             =begin wiki
    1658              
    1659             !3 Function html_set_borders
    1660              
    1661             /Parameters/
    1662              
    1663             * %$self% - reference to our object
    1664             * %$html% - reference to the html to be modified
    1665              
    1666             /Description/
    1667              
    1668             If the borders macro is found in the first cell of a table, replace the table \
    1669             tag with a style callout that will style the table with the appropriately \
    1670             specified border.
    1671              
    1672             If the %##NOBORDERS##% tag is found in the first table cell, replace the \
    1673             tag with .