comp.lang.ada
 help / color / mirror / Atom feed
* Annotated Reference Manual: Text to HTML
@ 1997-11-02  0:00 Marc Wachowitz
  1997-11-03  0:00 ` Stephen Leake
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Wachowitz @ 1997-11-02  0:00 UTC (permalink / raw)



I've written a simple Perl script which transforms the text version of the
Annotated Ada-95 Reference Manual into a set of html documents - though only
links from/to a table of contents and the previous/next section/annex are
created. The result isn't very beautiful, but sufficient for me to save lots
of paper. Feel free to use it as you like (improvements are welcome, though
I'm only interested if it works with lynx, a text-mode browser).

The text version of the AARM is available as
ftp://sw-eng.falls-church.va.us/public/AdaIC/standards/95lrm_rat/v6.0/aarm.txt

-- Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>

#! /usr/local/bin/perl -w
# Expect Annotated Ada-95 Reference Manual on standard input

use strict;
use English;

# file name conventions; prefix/suffix are not applied to $file_toc
# (I prefer to put all files into directory 'AARM' - which must exist)
my $file_toc = 'AARM/index.html';
my $file_prefix = 'AARM/';
my $file_suffix = '.html';

# html name conventions; prefix/suffix are not applied to $html_toc
# (e.g. change '.html' to '.html.gz' and gzip all generated files later)
my $html_toc = 'index.html';
my $html_prefix = '';
my $html_suffix = '.html';

# html document type
my $doc = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';

# Annex titles for generated table of contents
my %annex = ('A' => 'Predefined Language Environment',
	     'B' => 'Interface to Other Languages',
	     'C' => 'Systems Programming',
	     'D' => 'Real-Time Systems',
	     'E' => 'Distributed Systems',
	     'F' => 'Information Systems',
	     'G' => 'Numerics',
	     'H' => 'Safety and Security',
	     'J' => 'Obsolescent Features',
	     'K' => 'Language-Defined Attributes',
	     'L' => 'Language-Defined Pragmas',
	     'M' => 'Implementation-Defined Characteristics',
	     'N' => 'Glossary',
	     'P' => 'Syntax Summary');

my $prev_link;			# undefined or reference to previous document
my $counter = 0;		# used to generate unique names
my $pending_blank = 0;		# are there any pending blank lines?

sub chapter {			# start new chapter, or close the last one
  my $name = shift;		# logical name for this chapter
  my $title = shift;		# title
  my $last = shift;		# close last chapter?
  # mangle logical names (not necessary, but it's nice in the file system):
  $name =~ s/^([0-9])$/0$1/;
  $name =~ s/^([A-Z])$/$1_/;
  $name =~ s/^([0-9])\./0$1\./;
  $name =~ s/^([A-Z])\./$1_\./;
  $name =~ s/\.([0-9])\./\.0$1\./;
  $name =~ s/\.([0-9])$/\.0$1/;
  $name =~ s/^(..)\.(..)$/$1\.$2.00/;
  $name =~ s/^(..)$/$1\.00.00/;
  $counter++;
  $name = "$name._$counter";	# make $name unique, no matter what happened
  my $html_name = "$html_prefix$name$html_suffix";
  if (defined($prev_link)) {		# finish previous document
    if (! $last) {
      print OUT "\n<a href=\"$html_name\">[NEXT]</a>\n";
    }
    print OUT "</pre>\n";
    close(OUT);
  }
  if (! $last) {		# open this new document
    my $file_name = "$file_prefix$name$file_suffix";
    open(OUT, "> $file_name")
      or die "cannot open output to '$file_name':\n$ERRNO\n";
    $title =~ s/^s+//;
    $title =~ s/\s+$//;
    print OUT "$doc\n<title>\n$title\n</title>\n<pre>\n";
    if (defined($prev_link)) {
      print OUT "<a href=\"$prev_link\">[PREV]</a>";
    }
    print OUT "<a href=\"$html_toc#$name\">[TOC]</a>\n\n";
    print TOC "<li><a name=\"$name\" href=\"$html_name\">$title</a>\n";
  }
  $prev_link = $html_name;
  $pending_blank = 0;
}

sub main {
  my $first_index = 1;
  open(TOC, "> $file_toc")
    or die "cannot open output to '$file_toc':\n$ERRNO\n";
  print TOC "$doc\n<title>Annotated Ada-95 Reference Manual</title>\n<ul>\n";
  chapter('0', 'Preface', 0);
  while (defined(my $line = <>)) {
    $line =~ s/\s*$/\n/;
    $line =~ s/&/&amp;/;
    $line =~ s/</&lt;/;
    $line =~ s/>/&gt;/;
    if ($line =~ /^ *Section +([0-9]+)(:.*)$/) {
      print TOC "\n</ul><p><ul>\n";
      chapter($1, "$1$2", 0);
    } elsif ($line =~ /^ *Annex +([A-Z])$/) {
      print TOC "\n</ul><p><ul>\n";
      chapter($1, "$1: $annex{$1}\n", 0);
    } elsif ($line =~ /^Index$/ && $first_index) {
      print TOC "\n</ul><p><ul>\n";
      chapter('XX', $line, 0);
      $first_index = 0;
    } elsif ($line =~ /^Contents$/) {
      print TOC "\n</ul><p><ul>\n";
      chapter('ZZ', $line, 0);
    } elsif ($line =~ /^(([0-9]+|[A-Z])\.[0-9]+(\.[0-9]+)*) +[A-Z]/) {
      chapter($1, $line, 0);
    }
    if ($line =~ /^$/) {	# compress multiple blank lines to just one
      $pending_blank = 1;
    } else {
      if ($pending_blank) {
	$pending_blank = 0;
	print OUT "\n";
      }
      print OUT $line;
    }
  }
  print TOC "</ul>\n";
  close(TOC);
  chapter('ZZ', '...', 1);	# pseudo-chapter, to properly end the last one
}

main()




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Annotated Reference Manual: Text to HTML
@ 1997-11-03  0:00 Marc Wachowitz
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Wachowitz @ 1997-11-03  0:00 UTC (permalink / raw)



Stephen Leake <Stephen.Leake@gsfc.nasa.gov> wrote:
> Hope you didn't spend too much time on this; the html rationale is on
> AdaHome

The Rationale isn't at all the same as the Annotated Reference Manual: The
former is mostly a general outline of improvements since Ada-83, whereas
the latter is the Reference Manual annotated with remarks about subtle
issues of the language specification, i.e. the kind of stuff which compiler
implementors, language lawyers and other people (like me) who're interested
in the "dirty parts" of programming language design like to have. It's a bit
like a contract's fine print with commentaries from those who invented it -
non-lawyers aren't likely to find it very stimulating ;-)

-- Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Annotated Reference Manual: Text to HTML
  1997-11-02  0:00 Marc Wachowitz
@ 1997-11-03  0:00 ` Stephen Leake
  1997-11-03  0:00   ` Jon S Anthony
  1997-11-03  0:00   ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Leake @ 1997-11-03  0:00 UTC (permalink / raw)



Marc Wachowitz wrote:
> 
> I've written a simple Perl script which transforms the text version of the
> Annotated Ada-95 Reference Manual into a set of html documents - though only
> links from/to a table of contents and the previous/next section/annex are
> created. The result isn't very beautiful, but sufficient for me to save lots
> of paper. Feel free to use it as you like (improvements are welcome, though
> I'm only interested if it works with lynx, a text-mode browser).
> 
> The text version of the AARM is available as
> ftp://sw-eng.falls-church.va.us/public/AdaIC/standards/95lrm_rat/v6.0/aarm.txt
> 

Hope you didn't spend too much time on this; the html rationale is on
AdaHome, at:

http://www.adahome.com/Resources/refs/rat95.html

There used to be a way to download the whole thing from AdaHome, but I
don't see it at the moment.

It also comes with ObjectAda from Aonix.

-- 
- Stephe




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Annotated Reference Manual: Text to HTML
  1997-11-03  0:00 ` Stephen Leake
@ 1997-11-03  0:00   ` Jon S Anthony
  1997-11-03  0:00   ` Simon Wright
  1 sibling, 0 replies; 6+ messages in thread
From: Jon S Anthony @ 1997-11-03  0:00 UTC (permalink / raw)



Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:

> Marc Wachowitz wrote:
> > 
> > I've written a simple Perl script which transforms the text version
> > of the Annotated Ada-95 Reference Manual into a set of html
> > documents - though only links from/to a table of contents and the
> > previous/next section/annex are created. The result isn't very
> > beautiful, but sufficient for me to save lots
...

> Hope you didn't spend too much time on this; the html rationale is on
> AdaHome, at:

That's not the AARM.  Having an HTML version of the AARM seems like a
good thing IMO, thanks Marc.

/Jon

-- 
Jon Anthony
Synquiry Technologies, Ltd., Belmont, MA 02178, 617.484.3383
"Nightmares - Ha!  The way my life's been going lately,
 Who'd notice?"  -- Londo Mollari




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Annotated Reference Manual: Text to HTML
  1997-11-03  0:00 ` Stephen Leake
  1997-11-03  0:00   ` Jon S Anthony
@ 1997-11-03  0:00   ` Simon Wright
  1997-11-06  0:00     ` Chris Morgan
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 1997-11-03  0:00 UTC (permalink / raw)



Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:

> Marc Wachowitz wrote:
> > 
> > I've written a simple Perl script which transforms the text version of the
> > Annotated Ada-95 Reference Manual into a set of html documents - though only
> > links from/to a table of contents and the previous/next section/annex are
> > created. The result isn't very beautiful, but sufficient for me to save lots
> > of paper. Feel free to use it as you like (improvements are welcome, though
> > I'm only interested if it works with lynx, a text-mode browser).
> > 
> > The text version of the AARM is available as
> > ftp://sw-eng.falls-church.va.us/public/AdaIC/standards/95lrm_rat/v6.0/aarm.txt
> 
> Hope you didn't spend too much time on this; the html rationale is on
> AdaHome, at:
> 
> http://www.adahome.com/Resources/refs/rat95.html

Actually the AARM and the Rationale are quite different. I find the
AARM useful when trying to puzzle out some obscure point. Also, it
makes a good text-only reference for searching in your favourite text
editor (one that'll take 2.8MB, anyway).

-- 
Simon Wright                        Work Email: simon.j.wright@gecm.com
GEC-Marconi Radar & Defence Systems            Voice: +44(0)1705-701778
Command & Information Systems Division           FAX: +44(0)1705-701800




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Annotated Reference Manual: Text to HTML
  1997-11-03  0:00   ` Simon Wright
@ 1997-11-06  0:00     ` Chris Morgan
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Morgan @ 1997-11-06  0:00 UTC (permalink / raw)



Simon Wright <simon@pogner.demon.co.uk> writes:

> Actually the AARM and the Rationale are quite different. I find the
> AARM useful when trying to puzzle out some obscure point. 

My first introduction to Ada95 (back when I didn't even know it
existed) was borrowing and photocopying a draft AARM from a
colleague. Needless to say I thought the revision was a good bit more
scary than it really is.

Also, it
> makes a good text-only reference for searching in your favourite text
> editor (one that'll take 2.8MB, anyway).

Something that won't edit a file that size shouldn't really be anyones
favourite, but let's let sleeping dogs lie :-)

Chris
-- 
 	"everything remotely enjoyable turns out to be 
 	 powerfully addictive and expensive and bad for you"
						- Lizzy Bryant





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-11-06  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-03  0:00 Annotated Reference Manual: Text to HTML Marc Wachowitz
  -- strict thread matches above, loose matches on Subject: below --
1997-11-02  0:00 Marc Wachowitz
1997-11-03  0:00 ` Stephen Leake
1997-11-03  0:00   ` Jon S Anthony
1997-11-03  0:00   ` Simon Wright
1997-11-06  0:00     ` Chris Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox