; ; From a requirements directory containing a map file and all of the referenced ; .html files, generate the following: ; * index.html, with a heading and full table of contents ; * index{1-6}.html, with tables of contents for section levels 1 through 6, ; as these levels exist ; * lof.html, containing a cumulatively numbered list of figures ; * modified *_.html files, with inserted title commands at the top, ; navigation links at the bottom, and generated section numbers in the ; body; these files are referenced in the toc and nav links ; ; Formating requirements for a map file are the following: ; ... see the example in work/calendar/requirements for now ... ; ; Formating requirements for html files are as follows: ; * , , and <body> commands are replaced if present; the first ; <hn> command is used to generate the title and heading ; * <h1> through <h6> indicate section depth ; * <img ... caption=> is counted as a figure; the non-standard caption ; argument is replaced by an anchored caption text immediately below the ; image; spacing, centering, and horizontal rules are added; the caption ; text appears in the lof ; * the non-standard html command <ref>unique section title prefix</ref> is ; replaced with the section number; if the section title prefix is non- ; unique, a warning is issued and the the earliest number is used; if the ; section title prefix is not found, then it is left unchanged but linked ; to a _sectinon-not-found.html file; otherwise identical section titles ; can be disambiguated with   or other invisible characters ; * the non-standard html command <fig>unique caption prefix</fig> is ; replaced with the figure number; error handling is the same as for <ref> ; ; ; Alternatives to building separate *_.html files: ; * <head>, <title>, and <body> commands are processed the same, i.e., by ; replacement. ; * Any leading dewey decimal number is replaced when processing <h*> ; commands. ; * The caption= argument is left as is within the <img ...> command. ; Immediately following the <img> tag begin/end pair of caption tags ; is inserted with the following syntax: ; <caption>Figure n: caption text.</caption> ; If caption tag pair is present, its guts are replaced. ; * The caption= arg can also appear in <table> commands. If present, it ; signals that the table should appear in the lot. Processing is as for ; the caption= arg in <img>s. ; * Change <ref> and <fig> commands as follows: Make the command syntax ; <ref [section="...",figure="...",table="..."]> ; When the processing, the generated number (section, fig, or table) is ; added after the <ref ...> command and ended with </ref>. If a number ; and </ref> are already present, they are replaced. ; ; ; First pass: ; foreach line in map file ; save file-level as prev-file-level ; set file-level to number of leading tabs + 1 ; do parent/child processing ; nuke any extant <head>, <title>, <body> and replace with new stuff ; search consecutively for each type of arg we care about ; switch on arg ; case <h>: add or replace number; store number in symtab ; case <img> | <table>: if captioned, add or replace caption; ; store number in symtab ; create nav links based on file-level, etc. ; ; Second pass: ; process all <ref> commands ; ; Section number components (defvar l1 0) (defvar l2 0) (defvar l3 0) (defvar l4 0) (defvar l5 0) (defvar l6 0) ; Figure number (defvar fig 0) ; Table number (defvar tab 0) ; File level, as spefied by indentation in map. It's init'd to -1 so as to ; catch any leading tabs on the first line of the <sections> part of the map. (defvar file-level -1) ; List that defines the hierachy of sections based on numbering. The list is ; used to generate the navigation links. (defvar map nil) ; Open the map file and leave in a buffer for access as necessary. Complain ; and exit if no map file present. (defun open-map () ) ; Create the index.html file, inserting title and heading text. Any old index ; is moved to index.html.bak. (defun create-index () ; Open up. (find-file "index.html") ; Copy to .bak if necessary. (if (> (buffer-size) 0) (shell-command "cp -p index.html index.html.bak &") ) ; Insert title info from map file. ) ; Scan all sections files, doing the following for each ; * prepend l1. ... .ln in front of the text for each <hn> section ; * create a toc entry for each section ; * create a lof entry for each figure ; (defun process-file-body () (while (search-forward-regexp (concat "\\(<[Hh][1-9]>\\)\\|" "\\(<img\\)\\|" "\\(<table\\)") nil t) (cond ( (match-string 1) ; Header (insert-section-number) ) ( (match-string 2) ; Image (insert-figure-number) ) ( (match-string 3) ; Table (insert-table-number) ) ) ) ) ; Insert or replace a section number. At entry, we're at the first char ; followint the closing '>' of the heading command. (defun insert-section-number () ; Move over whitespace and check ) ; Insert or replace a figure number of there's a caption arg before the next ; ">". (defun insert-section-number () ) ; Insert or replace a table number of there's a caption arg before the next ; ">". (defun insert-section-number () ) ; Insert generated section numbers in heading commands. (defun insert-section-numbers () ) ; Scan all sections files, creating toc entries and lof entries ; Pre: level >= 1 and level <= 6 (defun start-new-section (level) ; Enforce precond brutally (if (< level 1) (setq level 1)) (if (> level 6) (setq level 6)) ; Increment l<i> by 1 (setq l1 (1+ l1)) ; Reset l<i>, i < level, to 1 (let ((i (1+ level))) (while () ) ) ; ) ; Do indentation validity checking. If cur-lev > prev-lev + 1, issue warning ; that extra indentation is ignored, giving map file line number. Set cur-lev ; = to prev-lev + 1. (defun process-indentation (line) ) ; Do previous processing. If prev-lev is same as cur-lev, make prev link the ; preceding file. If prev-lev > cur-lev, make prev link nil. ; Do parent processing. If cur-lev is equal to prev-lev, leave parent ; unchanged; if cur-lev < prev-lev, pop (prev-lev - cur-lev) items off parent ; stack and set parent = to new top of stack; if cur-lev = prev-lev + 1, push ; current parent and set parent = prev-file. (defun compute-parent () ) ; Example format of nav-link list: (setq nav-list '( (intro.html nil functional.html index.html index.html) (functional.html intro.html non-functional.html index.html index.html) (ui-overview.html nil appt-scheduling.html functional.html index.html) (appt-scheduling.html ui-overview.html viewing.html functional.html index.html) (viewing.html appt-scheduling.html more-scheduling.html functional.html index.html) structural-viewing.html specific-date-viewing.html list-viewing.html filtered-viewing.html viewing-other-users.html window-viewing.html more-scheduling.html meeting-scheduling.html task-scheduling.html event-scheduling.html finer-points.html item-level-viewing.html changing-and-deleting.html recurring-details.html receiving-reminders.html category-editing.html dynamic-view-updating.html admin.html options.html file.html edit.html help.html data-entry-details.html error-conditions.html gui-details.html multi-user-envir.html installation.html future-enhancements.html work-in-progress.html non-functional.html developer-overview.html spec.html schedule.rsl.html caldb.rsl.html view.rsl.html admin.rsl.html options.rsl.html file.rsl.html edit.rsl.html rationale.html <appendices> users-man.html command-lang.html help-content.html feature-comparison.html ) )