From f98303632bc9dac488096dea603fedb7f49f13c8 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 12 Aug 2012 15:36:01 -0400 Subject: Now remove the old notes and demo script. --- (limited to 'notes') diff --git a/notes/number-sections.pl b/notes/number-sections.pl deleted file mode 100755 index 3cef327..0000000 --- a/notes/number-sections.pl +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -use HTML::TreeBuilder; - -sub find_elements_by_tag_names($@) -{ - my ($elem, @tagnames) = @_; - if (ref($elem) ne 'HTML::TreeBuilder' && ref($elem) ne 'HTML::Element') { - die('Invalid argument to find_elements_by_tag_names'); - } - - my @list = $elem->content_list(); - my $tag; - my @retlist = (); - - foreach (@list) { - if (ref($_) ne 'HTML::Element') { - next; - } - $tag = $_->tag(); - if (grep($_ eq $tag, @tagnames)) { - push(@retlist, $_); - } - } - - return @retlist; -} - -sub number_sections($) -{ - my ($doc) = @_; -# my $doc = shift; - if (ref($doc) ne 'HTML::TreeBuilder') { - die('Invalid argument to number_sections'); - } - - my @body = find_elements_by_tag_names($doc, ('body')); - my @headers = find_elements_by_tag_names($body[0], - ('h1', 'h2', 'h3', 'h4', 'h5', 'h6')); - my @secnums = (0, 0, 0, 0, 0, 0); - my $curlev = -1; - my $newlev; - my $secstr; - - foreach (@headers) { - $newlev = $_->tag(); - $newlev =~ s/^h(\d)$/$1/; - if ($newlev != $curlev) { - foreach (@secnums[$newlev .. $#secnums]) { - $_ = 0; - } - } - ++$secnums[$newlev - 1]; - $secstr = join('.', @secnums); - $secstr =~ s/(\.0)*$//; - print($secstr, ":\t\"", $_->content_list(), "\"\n"); - $curlev = $newlev; - } -} - -sub main() -{ - my $doc = HTML::TreeBuilder->new(); - while (<>) { - $doc->parse($_); - } - number_sections($doc); -} - -main(); diff --git a/notes/processing-scripts.txt b/notes/processing-scripts.txt deleted file mode 100644 index 35e8edb..0000000 --- a/notes/processing-scripts.txt +++ /dev/null @@ -1,129 +0,0 @@ -MD -> TXT: - scripts/preprocmdheaders.pl -n $docdir -MD -> HTML: - scripts/preprocmdheaders.pl -nl $docdir - scripts/linkpages.pl $docdir - markdown $docdir/index.txt > $docdir/index.html - while read file; do \ - markdown $docdir/$file.txt > $docdir/$file.html - done < $docdir/series - scripts/postprochtmlheaders.pl -anL $docdir - - -scripts/preprocmdheaders.pl [-ntl] docdir - options - -n prepend section numbers to headers - -l handle hyperlinks to sections in text and table of contents - pseudocode - chapter = 0 - for each file in $docdir/series: - ++chapter - ... - for each header: - if opt n: - ... - ... -scripts/linkpages.pl docdir -scripts/postprochtmlheaders.pl [-anL] docdir - options - -a add "id" attributes to headers - -n remove section numbers from "id" attributes (use with -a) - -scripts/preproc.pl - options - -f format - "txt" or "html" - pseudopseudocode - scan each source file for sections - build a ToC - print(' ' x $seclev, "* [$secnum $sectitle][$secid]\n"); - if txt - add section numbers to headers - add $title . "\n" . '*' x strlen($title) - if html - add link defs "[$secid]: $chapter.html#$section_id" -scripts/postproc.pl - options - -f format - "txt" or "html" - pseudopseudocode - if txt - blame the schools and bail out - add section numbers and "id" attributes to headers - - -$docdir/ - +- appendices - | A list of appendix documents in the book. - +- chapters - | A list of chapter documents in the book. - +- first-chapter.md - | The source file for a chapter. - +- first-chapter.html - | The rendered HTML file for a chapter. - +- first-chapter.txt - | The rendered text file for a chapter. - +- reference-stuff.md - | The source file for an appendix. - +- second-chapter.md - | The source file for a chapter. - \- title.md - The source file for the title page. - - -ToC substitution: -$[toc] - -section link substitution: -$[sectlink][foo] -[ยง 1.10.11][foo] - -# create book and documents - DONE -# book->parse() - DONE -# foreach document: - DONE -# doc->parse() - DONE -# foreach heading: - DONE -# section = new Section - DONE -# push(self->sections, section) - DONE -# book->add_section() - DONE -# prefix section title with num - DONE -# book->output() - DONE -# book->subst_macros - DONE -# build ToC string - DONE -# foreach document: - DONE -# doc(Txt)->output() - DONE -# book->subst_macros() - DONE -# write title - DONE -# dump Markdown text - DONE -# doc(HTML)->output() - DONE -# book->subst_macros() - DONE -# append link defs string - DONE -# generate HTML (markdown) - DONE -# parse HTML - DONE -# foreach heading: - DONE -# set id attribute - DONE -# write templated documents - DONE -# -# Book -# new -# add_section -# indexes section by id -# appends to link defs string -# parse -# output -# add_section -# add_macro -# subst_macros -# _do_subst_macro -# Document -# new -# parse -# Document::Txt -# output -# Document::HTML -# output -# Section -# new -# number -# id -# title -- cgit v0.9.1