\n";
push @sections_content,$section_content;
my $htmlbutt = "\n";
if ($opts{p}) {
for my $i (0..$#sections_content) {
$_ = $sections_content[$i];
open(FH,">root-$i.html");
print FH $htmlhead;
if ($opts{c}) {
print FH "\n";
} else {
print FH "\n";
}
print FH $_;
print FH $toc_string;
print FH $htmlbutt;
close(FH);
}
} else {
print $htmlhead;
print $toc_string;
print foreach(@sections_content);
print $htmlbutt;
}
# Other subroutines
sub gencontent {
my $content = shift;
$content =~ s/\[image:\s*(.+)\s*\]//ig;
$content =~ s{\[link:\s*(.+)\s*[,\.]\s*((http|ftp)://.+)\s*\]}
{\1}ig;
$content =~ s{\[((http|ftp)://.+)\|(.+)\]} # Wiki style
{\2}ig;
$content =~ s{([^\s]+?)\s*\(((http|ftp)://.+)\)\s*}
{\1}ig;
my @paragraphs = split(/\n\n/,$content);
# enum, list
,
foreach (@paragraphs) {
s/^\n+//s; s/\s+\n//s;
my @lines = split(/\n/);
my $prefixed;
foreach(@lines) {
$prefixed++ if(/^\s*[\-\.ox\*#@\+=]\s*/);
}
if($prefixed-1 == $#lines) {
my $new_p;
foreach (@lines) {
s{^\s*[\-\.ox\*#@\+=]+(.+)$}{
\1
};
$new_p .= "$_\n";
}
$_ = "
\n${new_p}
\n";
}
}
$content = '';
$content .= "\n
\n$_\n
\n" foreach (@paragraphs);
return $content;
}
__END__
=head1 NAME
outline2html.pl - Convert Emacs outline-mode text into html pages.
=head1 SYNOPSIS
outline2html.pl S<[ B<-l> [I] ]> foo.txt > foo.html
outline2html.pl S<[-p]> S<[B<-l> [I] ]> foo.txt
=head1 OPTIONS
-c Collapse indexes. Expend it only when necessary.
-p Multi-page mode.
-l Levels to expand in Table of content. Default to 2
=head1 DESCRIPTION
This script is quite convienent for a Emacs outline-mode user who
wants to make html pages quickly. It generates html pages in two
styles: all nodes in a single page or a page for each root nodes.
HTML pages are generate in a structured fashion with default CSS
stylesheet named B. It is also possible to embed links and
images , using the following format in your outline-mode text file:
[image: picure.jpg]
[link: link_title , http://url.of.some/where/]
[http://url.of.some/where/|link_title]
... link_title (http://url.of.some/where/) ...
The first one makes a tag, where both of the
second and the third make a
link_title tag.
Paragraphs are seperated by a blank line in outline text file, and
will be convert to a
...
in html file. Enumerations could be
done by this simple way:
- the item 1
- the item 2
- the item 3 , this should be enough for an example
A paragraph contain only lines like this will be convert to a
.
(Un-numbered list). List prefix uses this regexp: [\-\.ox\*#@\+=]
Each section-i.html has accesskey i. You can press Alt-0 for quick
access to section-0.html
So far the generated html are not validated under any DTD but it's
tended to be so.
=head1 Copyright
Copyright 2003 by Kang-min Liu .
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See
=end