118 lines
3.3 KiB
Perl
Executable file
118 lines
3.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# cd <g3 clone>/doc; ./mkdoc # --> creates ../html/*.html
|
|
|
|
my $MKD = "./Markdown.pl";
|
|
|
|
use 5.10.0;
|
|
use strict;
|
|
use warnings;
|
|
use lib '../src/lib/Gitolite/Test';
|
|
use Tsh;
|
|
|
|
$ENV{TSH_ERREXIT} = 1;
|
|
|
|
try "
|
|
./fm2mt.pl < g3-master-toc.mm > master-toc.mkd
|
|
|
|
mkdir ../html; ok
|
|
git status -s -uno; !/./
|
|
git log --oneline -1
|
|
" or die 1;
|
|
|
|
my $head = (lines())[0];
|
|
|
|
main();
|
|
|
|
try "
|
|
git checkout gh-pages; ok
|
|
git reset --hard github/gh-pages; ok
|
|
cd ..; ok
|
|
git rm *.html; ok
|
|
mv html/*.html .; ok
|
|
git add *.html; ok
|
|
git commit -m '$head'; ok
|
|
git checkout master; ok
|
|
rmdir html; ok
|
|
" or die 2;
|
|
|
|
sub main {
|
|
chomp(@ARGV = `find . -name "*.mkd" | cut -c3-`) if not @ARGV;
|
|
@ARGV = grep { /./ } @ARGV;
|
|
my @save = @ARGV;
|
|
my $css = join("", <DATA>);
|
|
|
|
my %ct; # chapter tocs
|
|
my $mf = '';
|
|
my $fh;
|
|
|
|
while (<>) {
|
|
$ARGV =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
|
my $b = $1;
|
|
|
|
if (/^(#+) (?:#(\S+) )?(.*)/) {
|
|
if ( length($1) == 1 ) {
|
|
$ct{$b} .= "\n";
|
|
$ct{$b} .= " * [$3][$b]\n";
|
|
$mf .= "[$b]: $b.html\n";
|
|
} else {
|
|
$ct{$b} .= " " x ( 4 * ( length($1) - 1 ) );
|
|
$ct{$b} .= " * ";
|
|
$ct{$b} .= (
|
|
$2
|
|
? "[$3][$2]"
|
|
: "$3"
|
|
);
|
|
$ct{$b} .= "\n";
|
|
$mf .= "[$2]: $b.html" . ($2 ne $b ? "#$2" : "") . "\n" if $2;
|
|
}
|
|
}
|
|
}
|
|
|
|
# open($fh, ">", "master-toc.mk2")
|
|
# and print $fh $mt
|
|
# and close $fh;
|
|
|
|
# after this, do this for every mkd (including the master-toc.mkd)
|
|
|
|
# cat $css_block > $base.html
|
|
# cat $base.mkd $mf | $MKD >> $base.html
|
|
|
|
for my $mkd (@save) {
|
|
$mkd =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
|
my $b = $1;
|
|
|
|
open($fh, ">", "../html/$b.html")
|
|
and print $fh $css
|
|
and close $fh;
|
|
|
|
my $mkt = `cat $mkd`;
|
|
$mkt =~ s/^(#+) #(\S+) /$1 <a name="$2"><\/a> /mg;
|
|
$mkt =~ s/^\[\[TOC\]\]/$ct{$b}/mg;
|
|
open($fh, "|-", "$MKD >> ../html/$b.html")
|
|
and print $fh $mkt, "\n\n", $mf
|
|
and close $fh;
|
|
}
|
|
}
|
|
|
|
__DATA__
|
|
|
|
<head><style>
|
|
body { background: #fff; text-color: #000; margin-left: 40px; font-size: 0.9em; font-family: sans-serif; max-width: 800px; }
|
|
h1 { background: #ffb; text-color: #000; margin-left: -30px; border-top: 5px solid #ccc; }
|
|
h2 { background: #ffb; text-color: #000; margin-left: -20px; border-top: 3px solid #ddd; }
|
|
h3 { background: #ffb; text-color: #000; margin-left: -10px; }
|
|
h4 { background: #ffb; text-color: #000; }
|
|
code { font-size: 1.1em; background: #ddf; text-color: #000; }
|
|
pre { margin-left: 2em; background: #ddf; text-color: #000; }
|
|
pre code { font-size: 1.1em; background: #ddf; text-color: #000; }
|
|
</style></head>
|
|
|
|
<p style="text-align:center">
|
|
<a href="master-toc.html">master TOC</a>
|
|
|
|
|
<a href="index.html">main page</a>
|
|
|
|
|
<a href="index.html#license">license</a>
|
|
</p>
|