#!/usr/bin/perl
# Make structure for Qingfu St. 1-X history article (../index.html)
# Copyright       : https://www.fsf.org/copyleft/gpl.html
# Author          : Dan Jacobson -- https://www.jidanni.org/
# Created On      : Thu Jul  8 01:46:37 2021
# Last Modified On: Sat Jul 10 19:20:16 2021
# Update Count    : 62
use strict;
use warnings q(all);
use XML::LibXML;
use utf8;
use open qw/:std :encoding(utf8)/;
my $m    = 1;
my $doc  = XML::LibXML->createDocument;
my $body = $doc->createElement('body');

sub i    #need ASCII still, I think.
{
    my $x = $_[0];
    for ($x) {
        s/之/z/;
        s/號/h/;
        s/\s//g;
        return "b$_";
    }
}

my $u0 = $doc->createElement('ul');
$body->appendChild($u0);
for ( 1 .. 5 ) {
    my $l = $doc->createElement('li');
    $u0->appendChild($l);
    my $h = $doc->createElement('h2');
    $h->setAttribute( 'id', "a$m-$_" );
    $l->appendChild($h);
    $h->appendText("$m-$_");
    next if $_ == 4;
    my $u = $doc->createElement('ul');
    $l->appendChild($u);
    for ( "${m} 之 ${_} 號", "${m} 號之 ${_}" ) {
        my $l = $doc->createElement('li');
        $u->appendChild($l);
        my $h  = $doc->createElement('h3');
        my $id = i($_);
        $h->setAttribute( 'id', $id );
        $l->appendChild($h);
        $h->appendText($_);
        if (/號$/) {
            my $p = $doc->createElement('p');
            $p->setAttribute( 'id', $id . "cb" );
            $p->appendText("初編: …");
            $l->appendChild($p);
        }
        $l->appendTextChild( "p", "…" );
    }
}
$doc->setDocumentElement($body);
print $doc->toString(1);

# I'm too lazy to make a full html header, so:
# Local Variables:
# compile-command: "./p|ascii2uni -a Y # | w3m -dump -T text/html"
# End: