#!/usr/bin/perl # roqdocbuild; # Last updated: 2008-04-17 $version = '3.0'; $copyyear = '2008'; =head1 Roqet Document Builder A perl script to convert a text file that is in - regular ascii, - Roqet Document Format, - POD HTML Format (which was previously converted from POD format) or - a script (Perl, SQL, etc.) ... into a Roqet HTML document. =head2 Roqet Document Format The format of an Roqet Document Format is as follows: - (comment) @ heading (heading) * bullet command = description and [examples] (descriptive line) [code] {{link~~linkname}} {*imagelink*} [[ preformatted block (puts in
tag block) ]] - -->import:filename to import an external file into tag block =head2 The Template File The HTML Template File can contain these tags (*title*) (*title_extra*) (*author*) (*css_background_image*) (*content*) (*body*) (*copyright*) (*draftdate*) =head1 ChangeLog 2004-06-08 :: 1.5 :: fixed = error when inside a codeblock 2004-06-11 :: 1.6 :: added ability to handle preformat tags; [[ and ]] 2004-06-15 :: 1.7 :: modified link method to {{link~~linkname}} 2004-06-30 :: 1.8 :: tabulated command-lists; looks much nicer 2004-09-15 :: 1.9 :: rebranding and pod cleanup 2005-05-26 :: 2.0 :: added -->import:filename command 2005-06-02 :: 2.1 :: modified to truncate preformatted output 2006-08-21 :: 2.2 :: changed output format of "=" areas 2006-08-28 :: 2.3 :: removed use of xml file and added use of params to work in a makefile 2006-09-20 :: 2.5 :: removed named sublink from software page link 2006-11-21 :: 2.6 :: added changelog create subroutine 2006-12-04 :: 2.7 :: modified footer to display original file type 2008-01-24 :: 2.8 :: added image link method: {* *} 2008-04-16 :: 2.9 :: added wiki-format create subroutine (to bulk-create pages for RoqWiki) 2008-04-17 :: 3.0 :: added roqet document format upgrate subroutine to upgrade roqet document formatted files to v2.0 Modified changelog conversion to fit new format too =head1 Author roqet\n");
push (@body, "\n");
foreach $impline (@importfile) {
chomp($impline);
push (@body, $impline . "\n");
}
#push (@body, "\n\n");
push (@body, "\n\n");
undef (@importfile);
}
elsif (substr($line,0,1) eq '-') { next; }
elsif (substr($line,0,2) eq '* ') {
$line =~ s/\* //g;
push (@body, " $line\n");
}
elsif (substr($line,0,1) eq '-') { next; }
elsif (substr($line,0,2) eq '@ ') {
$line =~ s/\@ //g;
push (@body, " \n");
}
elsif ($line =~ /\]\]/){
$pretag = 0;
push (@body, " \n");
}
elsif ( $pretag ){
push (@body, $line . "\n");
}
else {
$line =~ s/\\<\;/g;
$line =~ s/\>/\>\;/g;
$line =~ s/\>/\>\;/g;
$line =~ s/ /\ \;/g;
$line =~ s/\[/\/g;
$line =~ s/\]/\<\/code\>/g;
$line =~ s/\{\{/\/g;
$line =~ s/\}\}/\<\/a\>/g;
$line =~ s/\{\*/\
/g;
if ($line =~ /\= /){
($comm,$desc) = split(/\=/,$line,2);
$comm = '' . $comm . '';
push (@body, " $comm
\n");
push (@body, " $desc
\n
\n");
}
else {
$comm = $line;
$desc = '';
push (@body, " \n " . $comm . $desc . "\n
\n");
}
}
}
}
}
sub buildwiki {
#
# builds html from roqet document format text file
#
$pretag = 0;
foreach $line (@textfile) {
chomp($line);
if (substr($line,0,3) eq '-->') {
($command,$filename) = split(/\:/,$line,2);
print "Importing: $filename... \n";
open IMPORT, $filename or warn "import failure error opening " . $filename . ": $!\n";
@importfile = ;
close IMPORT;
#push (@body, "\n");
push (@body, "\n");
foreach $impline (@importfile) {
chomp($impline);
push (@body, $impline . "\n");
}
#push (@body, "\n\n");
push (@body, "\n\n");
undef (@importfile);
}
elsif (substr($line,0,2) eq '-=') {
$line =~ s/\-\=//g;
$line =~ s/\=\-//g;
$title = $line;
push (@body, " $line
\n");
}
elsif (substr($line,0,1) eq '-') { next; }
elsif (substr($line,0,2) eq '* ') {
$line =~ s/\* //g;
push (@body, " $line\n");
}
elsif (substr($line,0,1) eq '-') { next; }
elsif (substr($line,0,2) eq '@ ') {
$line =~ s/\@ //g;
push (@body, " $line
\n");
}
elsif ($line ne ''){
if ($line =~ /\[\[/){
$pretag = 1;
push (@body, "\n");
}
elsif ($line =~ /\]\]/){
$pretag = 0;
push (@body, " \n");
}
elsif ( $pretag ){
push (@body, $line . "\n");
}
else {
$line =~ s/\\<\;/g;
$line =~ s/\>/\>\;/g;
$line =~ s/\>/\>\;/g;
$line =~ s/ /\ \;/g;
$line =~ s/\[/\/g;
$line =~ s/\]/\<\/code\>/g;
$line =~ s/\{\*/\
/g;
$line =~ s/\{\{/\/g;
$line =~ s/\}\}/\<\/a\>/g;
if ($line =~ /\= /){
($comm,$desc) = split(/\=/,$line,2);
$comm = '' . $comm . '';
push (@body, " $comm
\n");
push (@body, " $desc
\n
\n");
}
else {
$comm = $line;
$desc = '';
push (@body, " \n " . $comm . $desc . "\n
\n");
}
}
}
}
}
sub upgradedoc {
#
# upgrades roqet document format text file
#
local($heading) = @_;
$pretag = 0;
foreach $line (@textfile) {
chomp($line);
if (substr($line,0,2) eq '-=') {
$line =~ s/\-\=//g;
$line =~ s/\=\-//g;
push (@body, '-= ' . $heading . ' =-' . "\n");
}
elsif (substr($line,0,10) eq '- * number') {
push (@body, '- @ heading (heading)' . "\n" . '- * bullet' . "\n");
}
elsif (substr($line,0,8) eq '- Notes:') {
push (@body, "- Roqet Document Format v2.0. Notes:\n");
}
elsif (substr($line,0,1) eq '*') {
($num,$heading) = split(/\./,$line,2);
$num =~ s/\*//g;
$num =~ s/ //g;
push (@body, "@ $heading\n");
}
else {
push (@body, "$line\n");
}
}
}
sub buildpod {
#
# builds doc from roqet pod html file
#
$bodyfound = 0;
foreach $line (@textfile) {
chomp($line);
if (substr($line,0,6) eq '') {
$bodyfound = 1;
}
elsif (substr($line,0,7) eq '') {
$bodyfound = 0;
}
elsif ($bodyfound) {
push (@body, "$line\n");
}
}
}
sub buildscript {
#
# builds doc from roqet script file
#
foreach $line (@textfile) {
chomp($line);
$line =~ s/\</g;
$line =~ s/\>/>/g;
push (@body, "$line\n");
}
}
sub buildlog {
#
# builds changelog from roqet changelog format file
#
$pretag = 0;
push (@body, "\n");
foreach $line (@textfile) {
chomp($line);
if (substr($line,0,1) eq '-') { next; }
elsif (substr($line,0,2) eq '20') {
($num,$heading) = split(/\ /,$line,2);
$num =~ s/\*//g;
$num =~ s/ //g;
push (@body, "
\n$num $heading
\n");
$break = '';
}
elsif ($line =~ /\t\* /){
$line =~ s/\t\* //g;
push (@body, "$break$line\n");
$break = '
';
}
elsif ($line ne ''){
push (@body, "$line\n");
}
}
push (@body, "
\n");
}
sub draftdate {
#
# returns date & time, or year for the current draft
#
local($type) = @_;
($dayofweek, $day, $month, $year, $hour, $minute, $second) = (localtime)[6,3,4,5,2,1,0];
$date = sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day);
$time = sprintf("%02d:%02d:%02d", $hour, $minute, $second );
if ($type eq 'draft') { return("$date $time"); }
else { return($year+1900); }
}
exit;