gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] Re: Tutorial as one big page


From: Zack Brown
Subject: [Gnu-arch-users] Re: Tutorial as one big page
Date: Wed, 10 Sep 2003 09:28:56 -0700
User-agent: Mutt/1.5.4i

On Wed, Sep 10, 2003 at 09:14:58AM -0700, Zack Brown wrote:
> Hi Tom,
> 
> It would be great if the tutorial were available as one big page. Here's
> a really simple script that should work for that. Just invoke it as
> 
> $ onedoc htmltutorial/relative/path
> 
> and it will produce bigpage.html, containing the entire tutorial, with
> all <a name>s and <a href>s adjusted to work as expected.
> 
> I'm sure your existing tools can do a better job creating one big page on
> their own, but I felt like scripting it anyway.
> 
> Be well,
> Zack

update to also include table of contents:

----------------------------------- 'onedoc' ---------------------------
#!/usr/bin/perl -w

use strict;

my $dir = shift || die "specify on the command line the directory containing 
HTML docs";

open(I, "<$dir/arch.html");
my @tocfile = <I>;                           
unshift @tocfile, "<a href=\"arch.html\">";

open(O, ">bigpage.html");

print O  "<html>\n";
print O  "<head>\n";
print O  "<title>The arch Version Control System</title>\n";
print O  "</head>\n";
print O  "<body>\n";

foreach $_ (@tocfile)
{
    next unless /href="(.*?html)/;
    my $basename = $1;
    my $filename = "$dir/$basename";

    open(F, "<$filename");
    while(my $f = <F>)
    {
        next if $f =~ /^<\/?(html|head|title|body)/;

        # this one line is just too long...
        $f =~ s/(cmtrev: tree is not up-to-date \(missing latest revision 
is)/$1\n      /;

        # fix all hrefs and names etc
        $f =~ s/(<a name=")/$1$basename-/;  
        $f =~ s/(<a href=")(.*?)\#/$1\#$2-/;

        print O $f;
    }
}

print O  "</body>\n";
----------------------------------- 'onedoc' ---------------------------

> 
> ----------------------------------- 'onedoc' ---------------------------
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my $dir = shift || die "specify on the command line the directory containing 
> HTML docs";
> 
> open(I, "<$dir/arch.html");
> open(O, ">bigpage.html");
> 
> print O  "<html>\n";
> print O  "<head>\n";
> print O  "<title>The arch Version Control System</title>\n";
> print O  "</head>\n";
> print O  "<body>\n";
> 
> while($_ = <I>)
> {
>     next unless /href="(.*?html)/;
>     my $basename = $1;
>     my $filename = "$dir/$basename";
> 
>     open(F, "<$filename");
>     while(my $f = <F>)
>     {
>         next if $f =~ /^<\/?(html|head|title|body)/;
> 
>         # this one line is just too long...
>         $f =~ s/(cmtrev: tree is not up-to-date \(missing latest revision 
> is)/$1\n      /;
> 
>         # fix all hrefs and names etc
>         $f =~ s/(<a name=")/$1$basename-/;
>         $f =~ s/(<a href=")(.*?)\#/$1\#$2-/;
> 
>         print O $f;
>     }
> }
> 
> print O  "</body>\n";
> ----------------------------------- 'onedoc' ---------------------------
> 
> -- 
> Zack Brown

-- 
Zack Brown




reply via email to

[Prev in Thread] Current Thread [Next in Thread]