mirror of
https://github.com/GnoConsortium/gno-docs.git
synced 2025-01-16 06:30:03 +00:00
Added FAQ source and generator code.
Other than moving some of the (now) unneeded generator components to a 'historical' subdirectory and adding a GNUmakefile appropriate to the new build, no changes have as yet been made.
This commit is contained in:
parent
d16e7f82a9
commit
2c7a0fbc5e
2549
faq/FAQ.gno.src
Normal file
2549
faq/FAQ.gno.src
Normal file
File diff suppressed because it is too large
Load Diff
24
faq/GNUmakefile
Normal file
24
faq/GNUmakefile
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Frequently Asked Questions
|
||||
#
|
||||
|
||||
SRCROOT = ..
|
||||
WEB_HOME_BASE = faq
|
||||
SUBPROJECTS =
|
||||
|
||||
GEN_TEXT = $(WEB_HOME)/csa2g.FAQ.txt
|
||||
GEN_HTML = $(WEB_HOME)/csa2g.FAQ.html
|
||||
|
||||
TARGETS = $(GEN_TEXT) $(GEN_HTML)
|
||||
|
||||
MKFAQ = ./mkfaq
|
||||
FAQ_SRC = FAQ.gno.src
|
||||
|
||||
include $(SRCROOT)/etc/const-priv.mk
|
||||
include $(SRCROOT)/etc/const.mk
|
||||
-include $(SRCROOT)/etc/const-local.mk
|
||||
|
||||
include $(SRCROOT)/etc/rules.mk
|
||||
|
||||
$(GEN_TEXT) $(GEN_HTML): $(FAQ_SRC) $(MKFAQ)
|
||||
$(MKFAQ)
|
129
faq/historical/Makefile
Normal file
129
faq/historical/Makefile
Normal file
@ -0,0 +1,129 @@
|
||||
# Devin Reade, November 1997
|
||||
#
|
||||
# $Id: Makefile,v 1.4 1998/01/22 14:50:24 gdr Exp $
|
||||
#
|
||||
# Main targets:
|
||||
#
|
||||
# release:
|
||||
# Use this only when the FAQ is ready for news posting, and
|
||||
# after doing a 'cvs commit'.
|
||||
# test: (DEFAULT TARGET)
|
||||
# Use this to generate local copies of the text and html versions
|
||||
# of the FAQ.
|
||||
# test-auto:
|
||||
# This generates a file, "faq.out" that contains what *would* be
|
||||
# posted with the 'post' target, but doesn't actually post anything.
|
||||
# Before this target will build, you must have the file "gnoFAQ.1".
|
||||
# You must manually copy "csa2g.FAQ.txt" to "gnoFAQ.1". This is
|
||||
# so that a draft version of the FAQ is not accidentally posted
|
||||
# by a cron job.
|
||||
#
|
||||
# test-post:
|
||||
# This target will post a version of the FAQ to the configured
|
||||
# test newsgroup. (Currently, ab.test.)
|
||||
# clean:
|
||||
# Deletes all scratch files except the released.* files (from the
|
||||
# previous posting).
|
||||
# clobber:
|
||||
# Deletes *all* scratch files.
|
||||
#
|
||||
|
||||
SRC = FAQ.gno.src
|
||||
CONFIG = faq-config
|
||||
|
||||
AUTOFAQ = ./auto-faq/auto-faq
|
||||
MKFAQ = mkfaq
|
||||
|
||||
GEN_HTML = csa2g.FAQ.html
|
||||
GEN_TEXT = csa2g.FAQ.txt
|
||||
LOG_HTML = csa2g.LOG.html
|
||||
LOG_TEXT = csa2g.LOG.txt
|
||||
LOG_PENDING = unposted.log
|
||||
|
||||
GEN_POST= faq.out
|
||||
|
||||
# if you split the archive, change the 'release' target, below
|
||||
AUTOSRC = gnoFAQ.1
|
||||
|
||||
# This is the name of the file that contains the approval header.
|
||||
APPROVAL = /home/gdr/etc/GNO-FAQ.approval
|
||||
|
||||
# This extracts the date and version from RCS identifiers.
|
||||
GETDATE = /home/gdr/src/gno/doc/refs/getdate
|
||||
|
||||
default: test
|
||||
|
||||
test: $(GEN_TEXT) $(GEN_HTML) log
|
||||
test-auto: $(GEN_POST)
|
||||
log: $(LOG_TEXT) $(LOG_HTML)
|
||||
$(GEN_TEXT) $(GEN_HTML): $(SRC) $(MKFAQ); $(MKFAQ)
|
||||
|
||||
$(LOG_TEXT): $(SRC)
|
||||
@echo "making $@"; \
|
||||
cat log.preamble > $@; \
|
||||
echo " extracting log information"; \
|
||||
cvs log $(SRC) | perl -n \
|
||||
-e '(/------/) && ($$found++);' \
|
||||
-e '($$found == 1) && print;' >> $@; \
|
||||
if [ -f $(LOG_PENDING) ]; then \
|
||||
echo " reusing $(LOG_PENDING)"; \
|
||||
cat $(LOG_PENDING) >> $@; \
|
||||
fi;
|
||||
|
||||
$(LOG_HTML): $(LOG_TEXT)
|
||||
@echo "making $@"; \
|
||||
echo '<html><head><title>GNO FAQ Update Log</title></head>' > $@; \
|
||||
echo '<body bgcolor="#ffffff">' >> $@; \
|
||||
echo '<h1>GNO FAQ Update Log</h1><pre>' >> $@; \
|
||||
perl -p \
|
||||
-e 's/</</g;' -e 's/>/>/g;' -e 's/"/"/g;' \
|
||||
< $< >> $@; \
|
||||
echo '</pre></body></html>' >> $@
|
||||
|
||||
$(GEN_POST): $(AUTOSRC)
|
||||
FAQ_NOSEND=1; export FAQ_NOSEND; \
|
||||
$(AUTOFAQ) GNO-faq
|
||||
|
||||
release: $(GEN_TEXT) $(GEN_HTML) $(LOG_TEXT) $(LOG_HTML)
|
||||
@echo "creating release files"; \
|
||||
v=`$(GETDATE) -version < $(SRC)`; \
|
||||
r=released; \
|
||||
rm -rf $$r; \
|
||||
mkdir $$r; \
|
||||
cp $(GEN_TEXT) $(AUTOSRC); \
|
||||
cp $(GEN_TEXT) $$r/faq.v$$v.txt; \
|
||||
cp $(GEN_HTML) $$r/faq.v$$v.html; \
|
||||
cp $(LOG_TEXT) $$r/log.v$$v.txt; \
|
||||
cp $(LOG_HTML) $$r/log.v$$v.html; \
|
||||
(cd $$r; tar -cf - .) | gzip --best > released.tar.gz
|
||||
|
||||
# tar -cf - released*.txt released*.html| gzip --best > released.tar.gz
|
||||
|
||||
test-post: $(AUTOSRC)
|
||||
@g=`fgrep testgroup faq-config | \
|
||||
sed -e 's/^[^"][^"]*"//;' -e 's/".*//;'`; \
|
||||
echo "posting to test group ($$g)"; \
|
||||
if [ ! -f $(APPROVAL) ]; then \
|
||||
echo "$(APPROVAL) not found."; \
|
||||
echo "======== Are you supposed to be posting this FAQ?"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
FAQ_TEST=1; export FAQ_TEST; \
|
||||
$(AUTOFAQ) GNO-faq
|
||||
|
||||
|
||||
post: $(AUTOSRC)
|
||||
@echo "posting to csa2g"; \
|
||||
if [ ! -f $(APPROVAL) ]; then \
|
||||
echo "$(APPROVAL) not found."; \
|
||||
echo "======== Are you supposed to be posting this FAQ?"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
$(AUTOFAQ) GNO-faq
|
||||
|
||||
clean:
|
||||
rm -f $(GEN_HTML) $(GEN_TEXT) $(GEN_POST) *~ gnoFAQ.? \
|
||||
$(LOG_HTML) $(LOG_TEXT)
|
||||
|
||||
clobber: clean
|
||||
rm -rf released.* released
|
10
faq/historical/README
Normal file
10
faq/historical/README
Normal file
@ -0,0 +1,10 @@
|
||||
The files in this directory were used when the comp.sys.apple2.gno
|
||||
USENET news group was active. That newsgroup has since been retired,
|
||||
so these are no longer necessary.
|
||||
|
||||
In addition to these files, a program called auto-faq was used
|
||||
for automated postings. As of September 2012, auto-faq is available
|
||||
at <http://www.novia.net/~pschleck/auto-faq/>
|
||||
|
||||
Devin Reade
|
||||
07 Sep 2012
|
46
faq/historical/faq-config
Normal file
46
faq/historical/faq-config
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/false
|
||||
#
|
||||
# Configuration for auto-faq
|
||||
#
|
||||
# Current newsgroups covered by this file:
|
||||
# rec.radio.amateur.misc (cross-posted to news.answers)
|
||||
# rec.radio.cb (cross-posted to news.answers)
|
||||
#
|
||||
|
||||
# global parameters
|
||||
articledir="/home/gdr/src/doc/FAQs" # default directory for FAQ
|
||||
chgctrl-type="rcs" # using RCS for revision control
|
||||
newstech="gdr" # technical lead for FAQ postings
|
||||
from="newstech" # From: field default is news-tech user
|
||||
techname="Devin Reade" # full name of technical lead
|
||||
testgroup="edm.test" # newsgroup for tests
|
||||
testdistrib="ab" # distribution for tests
|
||||
organization="Myrias Computer Technologies Corp"
|
||||
localdomain="eddore.myrias.com" # local internet domain name
|
||||
timezone="MST7MDT" # local timezone
|
||||
|
||||
local-func-src="/home/gdr/src/doc/FAQs/faq.funcs" # customization routines
|
||||
|
||||
=== GNO-faq
|
||||
articlebase="gnoFAQ" # basename for FAQ
|
||||
statusbase="gnoFAQ.status" # sequence file for Supersedes: headers
|
||||
owner="gdr@eddore.myrias.com" # owner of FAQ text file
|
||||
ownername="Devin Reade" # full name of owner
|
||||
newsgroup="comp.sys.apple2.gno" # primary newsgroup for FAQ postings
|
||||
extragroups="comp.answers,news.answers"
|
||||
# secondary newsgroup(s) for cross-posting
|
||||
# extragroups may be left empty
|
||||
test-2nd-hdrs="Archive-Name:Revision:Changes:Last-modified:Version:URL"
|
||||
post-2nd-hdrs="Archive-Name:Revision:Changes:Last-modified:Version:URL"
|
||||
faqid="apple2-gno-faq" # identifier for message ID & archive name
|
||||
archive="apple2/GNO-faq" # override archive name
|
||||
distribution="world" # normal FAQ posting distribution
|
||||
approval="@local_approval(A)@" # news.answers approval (optional)
|
||||
interval="35" # how many days before the message expires
|
||||
Keywords: FAQ, GNO, Apple-II, UNIX, ORCA
|
||||
Summary: Contains information on the UNIX-like OS for the Apple IIgs.
|
||||
Posting-Frequency:: monthly
|
||||
X-Content-Currency: This FAQ changes regularly. When a saved or printed copy\
|
||||
is over 6 months old, please obtain a new one. Instructions in the\
|
||||
preamble indicate where to find them via NetNews, FTP, and the WWW.
|
||||
|
60
faq/historical/faq.funcs
Executable file
60
faq/historical/faq.funcs
Executable file
@ -0,0 +1,60 @@
|
||||
push(@local_yearmap, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
|
||||
|
||||
$local_version = '';
|
||||
$local_date = '';
|
||||
$local_http = '';
|
||||
|
||||
$local_approval_header_file = '/home/gdr/etc/GNO-FAQ.approval';
|
||||
|
||||
sub local_approval {
|
||||
open(local_fp, "< $local_approval_header_file") ||
|
||||
die("couldn't open $local_approval_header_file. Are you supposed " .
|
||||
"to be trying to post this FAQ?");
|
||||
$approval_line = <local_fp>;
|
||||
chop($approval_line);
|
||||
close(local_fp);
|
||||
return $approval_line;
|
||||
}
|
||||
|
||||
sub local_hdr_parse_rcs {
|
||||
local($src, $year, $day, $time, $month);
|
||||
|
||||
# $src = "\@articledir\@/FAQ.gno.src";
|
||||
$src = "/home/gdr/src/doc/FAQs/FAQ.gno.src";
|
||||
open (local_fp, "$src") || die("couldn't open $src");
|
||||
while ($_ = <local_fp>) {
|
||||
if (m,\$Id:\s+\S+\s+(\S+)\s+(\d+)/(\d+)/(\d+)\s+(\S+)\s*,) {
|
||||
$local_version = $1;
|
||||
$year = $2;
|
||||
$day = $4;
|
||||
$time = $5;
|
||||
$month = $local_yearmap[int($3)-1];
|
||||
$local_date = "$day $month $year $time";
|
||||
} elsif (/%FAQ-http-addr%([^%]+)%/) {
|
||||
$local_http = $1;
|
||||
}
|
||||
}
|
||||
close(local_fp);
|
||||
}
|
||||
|
||||
sub local_hdr_version {
|
||||
($local_version eq '') && &local_hdr_parse_rcs();
|
||||
&pr_header("Version", "$local_version");
|
||||
}
|
||||
|
||||
sub local_hdr_subject {
|
||||
($local_version eq '') && &local_hdr_parse_rcs();
|
||||
&pr_header("Subject", "comp.sys.apple2.gno FAQ (v$local_version)");
|
||||
}
|
||||
|
||||
sub local_hdr_last_modified {
|
||||
($local_date eq '') && &local_hdr_parse_rcs();
|
||||
&pr_header("Last-modified", "$local_date");
|
||||
}
|
||||
|
||||
sub local_hdr_url {
|
||||
&pr_header("URL", "$local_http");
|
||||
}
|
||||
|
||||
1;
|
7
faq/historical/log.preamble
Normal file
7
faq/historical/log.preamble
Normal file
@ -0,0 +1,7 @@
|
||||
The following are the recent changes to the FAQ. If more than one
|
||||
change set appears, then there have been multiple updates since the
|
||||
last time this FAQ was posted to comp.sys.apple2.gno and *.answers.
|
||||
|
||||
At least one change set will always be shown, even if there have
|
||||
been no changes since the previous posting.
|
||||
|
391
faq/mkfaq
Executable file
391
faq/mkfaq
Executable file
@ -0,0 +1,391 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# This script is used for formatting the GNO FAQ.
|
||||
#
|
||||
# $Id: mkfaq,v 1.10 1998/01/22 14:53:10 gdr Exp $
|
||||
#
|
||||
|
||||
$src = "FAQ.gno.src"; # the name of the FAQ source file
|
||||
$dest = "csa2g.FAQ.txt"; # the name of the text output file
|
||||
$html = "csa2g.FAQ.html"; # the name of the html output file
|
||||
|
||||
$ContactName = "Devin Reade";
|
||||
$ContactEmail = "gdr\@eddore.myrias.com";
|
||||
|
||||
$totalSections = 0; # the number of sections in the FAQ
|
||||
$totalQuestions = 0;
|
||||
$currentQuestion = 0;
|
||||
$tocLines = 0; # number of lines in table of contents
|
||||
$lastmapping = 0; # used in &map()
|
||||
|
||||
$SectionNumber = 0; # number of the current section
|
||||
$MaxSections = 0; # total number of sections
|
||||
|
||||
#
|
||||
# open the output files
|
||||
#
|
||||
open (outfp, "> $dest") || die("couldn't open output file $dest");
|
||||
open (outfp2, "> $html") || die("couldn't open output file $html");
|
||||
|
||||
$faq = "GNO Frequently Asked Questions (FAQ) List";
|
||||
|
||||
printf(outfp2
|
||||
"<html>\n" .
|
||||
"<head>\n" .
|
||||
"<title>" . $faq . "</title>\n" .
|
||||
"</head>\n" .
|
||||
"<body bgcolor=\"#ffffff\">\n" .
|
||||
"<h1>" . $faq . "</h1>\n");
|
||||
#
|
||||
# First pass -- get the table of contents and figure out what the
|
||||
# question number mappings are.
|
||||
#
|
||||
open (fp, $src) || die("couldn't open $src (1)");
|
||||
$_ = <fp>;
|
||||
do {
|
||||
chop;
|
||||
if ( /^%Section%\s*(.+):/ ) {
|
||||
&addSection($1);
|
||||
&addSectionHTML($1);
|
||||
} elsif ( /^Q\#(\d+):\s+(.*)/ ) {
|
||||
$originalLine = int($1);
|
||||
$newLine = &map($originalLine);
|
||||
$question = $2;
|
||||
while (<fp>) {
|
||||
(/^\s*$/) && last;
|
||||
$question .= $_;
|
||||
}
|
||||
if (defined($orgLineList[$originalLine])) {
|
||||
printf(stderr "%s:%d: duplicate question number Q\#%d\n",
|
||||
$src, $. -1, $originalLine);
|
||||
} else {
|
||||
$orgLineList[$originalLine] = 1;
|
||||
}
|
||||
&addTOCEntryHTML ($newLine, $question);
|
||||
$junk = sprintf("Q\#%s", $newLine);
|
||||
if (length($junk) < 7) {
|
||||
$padding = "\t";
|
||||
} else {
|
||||
$padding = " ";
|
||||
}
|
||||
$question = sprintf("\t%s:%s%s\n", $junk, $padding, &fmt(2,$question));
|
||||
&addTOCEntry ($question);
|
||||
} elsif ( /^%RCS-ID%\S+\s+\S+\s+(\S+)\s+(\S+)\s(\S+)/ ) {
|
||||
$version = $1;
|
||||
$date = $2;
|
||||
$time = $3;
|
||||
}
|
||||
} while (<fp>);
|
||||
close(fp);
|
||||
|
||||
#
|
||||
# Second pass -- print out the results, doing mappings as necessary
|
||||
#
|
||||
|
||||
$SectionNumber = 0;
|
||||
open (fp, $src) || die("couldn't open $src (2)");
|
||||
$in_header = 0;
|
||||
$in_body = 0;
|
||||
while(<fp>) {
|
||||
if (/^%Header-start%\s*$/) {
|
||||
$in_header = 1;
|
||||
printf(outfp2
|
||||
"Version: %s<br>\n" .
|
||||
"Last Modified: %s %s<br>\n" .
|
||||
"<hr>\n" .
|
||||
"<h2><A NAME=\"preamble\">Preamble</A></h2>\n" .
|
||||
"<pre>\n", $version, $date, $time);
|
||||
} elsif (/^%Header-end%\s*$/) {
|
||||
$in_header = 0;
|
||||
printf(outfp2 "</pre>\n<hr><hr>\n");
|
||||
} elsif (/^%FAQ-http-addr%(.*)%$/) {
|
||||
$faq_http = $1;
|
||||
} elsif (/^%FAQ-ftp-addr%(.*)%$/) {
|
||||
$faq_ftp = $1;
|
||||
} elsif (/^%FAQ-log-http-addr%(.*)%$/) {
|
||||
$faqlog_http = $1;
|
||||
} elsif (/^%FAQ-log-ftp-addr%(.*)%$/) {
|
||||
$faqlog_ftp = $1;
|
||||
# } elsif (/%Version%\s*$/) {
|
||||
# printf(outfp "Version:\t%s\n", $version);
|
||||
# } elsif (/%Last-Modified%\s*$/) {
|
||||
# printf(outfp "Modified:\t%s %s\n\n", $date, $time);
|
||||
} elsif (/^%TOC%\s*$/) {
|
||||
&printTOC();
|
||||
} elsif (/^%Section%\s*(.+):\s*$/) {
|
||||
# found a section header
|
||||
$SectionNumber++;
|
||||
&PrintSection($1);
|
||||
$_ = <fp>; # ditch the old underlining
|
||||
$in_body = 1;
|
||||
} elsif ($in_header || $in_body) {
|
||||
s,\%Version\%,$version,;
|
||||
s,\%Last\-Modified\%,$date $time,;
|
||||
s,\%FAQ-FTP\%,$faq_ftp,;
|
||||
s,\%FAQ-HTTP\%,$faq_http,;
|
||||
s,\%LOG-FTP\%,$faqlog_ftp,;
|
||||
s,\%LOG-HTTP\%,$faqlog_http,;
|
||||
&PrintLine($_);
|
||||
}
|
||||
}
|
||||
|
||||
# print trailing info
|
||||
printf(outfp2
|
||||
"</pre><hr>\n" .
|
||||
"%s\n" .
|
||||
"<A HREF=\"mailto:%s\"><%s></A>\n" .
|
||||
"</body>\n" .
|
||||
"</html>\n", $ContactName, $ContactEmail, $ContactEmail);
|
||||
|
||||
# clean up
|
||||
close(fp);
|
||||
close(outfp);
|
||||
close(outfp2);
|
||||
|
||||
#
|
||||
# Subroutines
|
||||
#
|
||||
|
||||
sub map {
|
||||
local ($old);
|
||||
$old = @_[0];
|
||||
|
||||
if ($mappings[$old] == 0) {
|
||||
$lastmapping++;
|
||||
$mappings[$old] = sprintf("%d.%d", $SectionNumber, $lastmapping);
|
||||
}
|
||||
return $mappings[$old];
|
||||
}
|
||||
|
||||
sub addTOCEntry {
|
||||
local($line, $first, $num, $num2, $last);
|
||||
|
||||
$line = $_[0];
|
||||
$toc[$tocLines++] = $line;
|
||||
$tocLines++;
|
||||
}
|
||||
|
||||
sub addTOCEntryHTML {
|
||||
local($line, $num, $entry);
|
||||
local($first, $num2, $last);
|
||||
|
||||
$num = $_[0];
|
||||
$line = $_[1];
|
||||
$line = &text2html($line);
|
||||
$line =~ s/[\s\n]+/ /g;
|
||||
$tag = $num;
|
||||
$tag =~ s/\./_/g;
|
||||
$entry = sprintf("<li><A HREF=\"\#q%s\">Q%s</A>: %s\n", $tag, $num, $line);
|
||||
$htmlQuestion{$num} = "$line";
|
||||
push(@htmlTOC, "$entry");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub addSection {
|
||||
local ($underline, $len, $i);
|
||||
|
||||
&addTOCEntry ("\n\t" . @_[0] . "\n");
|
||||
$underline = "\t";
|
||||
$len = length(@_[0]);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$underline .= '^';
|
||||
}
|
||||
$underline .= "\n";
|
||||
$lastmapping = 0; # reset the question numbers for new section
|
||||
&addTOCEntry ($underline);
|
||||
}
|
||||
|
||||
sub addSectionHTML {
|
||||
local ($entry, $arg, $tail);
|
||||
|
||||
$arg = $_[0];
|
||||
$arg = &text2html($arg);
|
||||
$MaxSections++;
|
||||
$SectionNumber++;
|
||||
$SectionNames[$SectionNumber] = $arg;
|
||||
|
||||
$tail = '';
|
||||
($SectionNumber > 1) && ($tail = "</ul>");
|
||||
$entry = sprintf("%s\n" .
|
||||
"<h3><A HREF=\"\#s%d\">Section %d</A>: %s</h3>\n" .
|
||||
"<ul>\n", $tail, $SectionNumber, $SectionNumber, $arg);
|
||||
push(@htmlTOC, "$entry");
|
||||
}
|
||||
|
||||
|
||||
sub printTOC {
|
||||
local ($i, $l);
|
||||
|
||||
# print out the text TOC
|
||||
printf (outfp
|
||||
"Table of Contents\n" .
|
||||
"=================\n");
|
||||
for ($i=0; $i < $tocLines; $i++) {
|
||||
printf (outfp "%s", $toc[$i]);
|
||||
}
|
||||
printf(outfp "\n");
|
||||
|
||||
# print the html TOC
|
||||
printf (outfp2 "<h2>Table of Contents</h2>\n");
|
||||
print outfp2 @htmlTOC;
|
||||
printf (outfp2 "</ul><br><hr>\n\n"); # finish off the last list
|
||||
}
|
||||
|
||||
#
|
||||
# Print the section name. For the text version, underline the name.
|
||||
# Takes one argument, the section name.
|
||||
#
|
||||
sub PrintSection {
|
||||
local($sname, $len, $i);
|
||||
|
||||
$sname = @_[0];
|
||||
|
||||
# Do the text version
|
||||
printf(outfp "%s\n", $sname);
|
||||
$len = length($sname);
|
||||
for ($i=0; $i<$len; $i++) {
|
||||
printf (outfp "-");
|
||||
}
|
||||
printf(outfp "\n");
|
||||
|
||||
# Do the html version
|
||||
$sname = &text2html($sname);
|
||||
($SectionNumber > 1) && printf(outfp2 "</pre>\n");
|
||||
printf(outfp2
|
||||
"\n<hr>\n\n" .
|
||||
"<h2><A NAME=\"s%d\">Section %d: %s</A></h2>\n\n",
|
||||
$SectionNumber, $SectionNumber, $sname);
|
||||
}
|
||||
|
||||
#
|
||||
# Print a line that's in the header or body. Takes one argument, the
|
||||
# raw line.
|
||||
#
|
||||
sub PrintLine {
|
||||
local($line, $rest);
|
||||
|
||||
$line = @_[0];
|
||||
|
||||
# do a concheck and print out the text version
|
||||
$qora = '';
|
||||
if ($line =~ /^([QA])\#\d+:(.*)/) {
|
||||
$qora = $1;
|
||||
$rest = $2;
|
||||
($rest =~ /^\t/) ||
|
||||
printf(stderr "%s:%d: missing leading tab\n", $src, $. -1);
|
||||
}
|
||||
$line =~ s/([QA])\#(\d+)/"$1#".&map($2)/ge;
|
||||
printf (outfp "%s", $line);
|
||||
if ($qora eq 'Q') {
|
||||
do {
|
||||
$line = <fp>;
|
||||
$line =~ s/([QA])\#(\d+)/"$1#".&map($2)/ge;
|
||||
printf (outfp "%s", $line);
|
||||
} until ($line =~ /^\s*$/);
|
||||
}
|
||||
|
||||
# do the html version
|
||||
$line = &text2html(@_[0]);
|
||||
if ($line =~ /^([QA])\#(\d+):(.*)/) {
|
||||
# start of a question or answer
|
||||
$qora = $1;
|
||||
$num = $2;
|
||||
$rest = $3;
|
||||
if ($qora eq 'Q') {
|
||||
printf(outfp2
|
||||
"</pre><h3><A NAME=\"q%s\">Q\#%s</A>: %s</h3>\n<pre>\n",
|
||||
&mapnum(&map($num)), &map($num), $htmlQuestion{&map($num)})
|
||||
} else {
|
||||
$rest =~ s,Q\#(\d+),
|
||||
'<A HREF="#q'.&mapnum(&map($1)).'">Q#'.&map($1).'</A>',ge;
|
||||
$rest =~ s/^\t//;
|
||||
printf(outfp2 "%s\n", $rest);
|
||||
}
|
||||
} else {
|
||||
$line =~ s,Q\#(\d+),'<A HREF="#q'.&mapnum(&map($1)).'">Q#'.&map($1).
|
||||
'</A>',ge;
|
||||
$line =~ s/^\t//;
|
||||
|
||||
# replace http:// and ftp:// with the link equivalents
|
||||
$line =~ s,(http|ftp)://(\S+),'<A HREF="'.$1.'://'.$2.'">'.$1.'://'.$2.'</A>',ge;
|
||||
|
||||
# $line =~ s,ftp://(\S+),'<A HREF="ftp://'.$1.'">http://'.$1.'</A>',ge;
|
||||
printf (outfp2 "%s", $line);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub mapnum {
|
||||
local($num);
|
||||
|
||||
$num = @_[0];
|
||||
$num =~ s/\./_/g;
|
||||
return $num
|
||||
}
|
||||
|
||||
#
|
||||
# &fmt (tabs, text)
|
||||
#
|
||||
# This routine formats the specified text to fall within 76 columns,
|
||||
# and indents the text with the specified number of tabs (considered
|
||||
# to be 8 characters wide).
|
||||
#
|
||||
# The first line will _not_ be preceeded by any tabs, even though
|
||||
# the length will be calculated as if it is.
|
||||
#
|
||||
sub fmt {
|
||||
local (@array, $tabs, $line, $columns, $result, $tablen, $linelen);
|
||||
local ($word, $len, $i);
|
||||
$tabs = int(@_[0]);
|
||||
$line = @_[1];
|
||||
$columns = 76; # maximum column number to print
|
||||
$tablen = 8; # spaces per tab
|
||||
|
||||
$line =~ s/\s+/ /g;
|
||||
|
||||
@array = split ("[ \t]+", $line);
|
||||
$result = '';
|
||||
$linelen = 0;
|
||||
for ($i = 0; $i < $tabs; $i++) {
|
||||
$linelen += $tablen;
|
||||
}
|
||||
foreach $word (@array) {
|
||||
$len = length($word);
|
||||
if ($columns - $linelen > $len) {
|
||||
# add it into the current line
|
||||
if ($linelen == $tablen * $tabs) {
|
||||
$result .= $word;
|
||||
$linelen += $len;
|
||||
} else {
|
||||
$result .= ' ' . $word;
|
||||
$linelen += $len + 1;
|
||||
}
|
||||
} else {
|
||||
# start a new line
|
||||
$result .= "\n";
|
||||
$linelen = 0;
|
||||
for ($i = 0; $i < $tabs; $i++) {
|
||||
$result .= "\t";
|
||||
$linelen += $tablen;
|
||||
}
|
||||
$result .= $word;
|
||||
$linelen += $len;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
#
|
||||
# Translates HTML special character sequences into their "escaped" formats
|
||||
#
|
||||
sub text2html {
|
||||
local($line);
|
||||
|
||||
$line = @_[0];
|
||||
|
||||
$line =~ s/</</g;
|
||||
$line =~ s/>/>/g;
|
||||
$line =~ s/"/"/g;
|
||||
return $line;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user