[pm-h] write to empty files

rlharris at oplink.net rlharris at oplink.net
Sun Jun 17 00:27:15 PDT 2018


On Sun, June 10, 2018 4:06 pm, Chris Blanc wrote:
> Sounds like a fun project. If I recall correctly, you had mentioned
> also wanting a custom header in each output file; what would that be? Also,
> how do you want to delimit A, B, and C in the output?



Here is the task as I see it now.  In general, all that is required is:

    (a) traversal of a directory, operating on each file in the directory,

    (b) use of the filename as the key to obtain one or more values from a
look-up table, and

    (c) writing to the file the value or values obtained from the look-up
table.

----------------------------------------------------------------------

This one-time task produces approximately twelve hundred sets of document
templates -- one set for each chapter of the English Bible.  Each set
consists of four LaTeX files, one of which is the master which has include
statements which specify the other three files.  When complete, each
document is the analysis of a single chapter, and may be revised and
published independently of the other documents.

----------------------------------------------------------------------

(Step 1) Populate four directories ("greek", "english", "exposition",
"publication") with files which initially are empty except for an
identifying header:

    % filename
    % timestamp
    % projectname
    % bookname-common
    % chapternumber

where:

    "filename" is of the form:

        greek-xx-yyy.tex (The Greek text.)

        english-xx-yyy.tex (The English translation.)

        exposition-xx-yyy.tex (The part which I write.)

        publication-xx-yyy.tex (The LaTeX document, which (via
        "\include" statements) incorporates the text of the
        corresponding "greek", "english", and "exposition" files.)

        xx, the "booknumber", ranges from 01 to 66.

        yyy, the "chapternumber", ranges from 001 to 150; three digits are
used, because the book of Psalms has 150 chapters.

	".tex" indicates that the file contains LaTeX markup.

    "timestamp" is taken from the clock of the computer, with format
"2018.06.15 1400gmt".

    "projectname" is the string "survey".

    "bookname-common" is the common form of the book name, obtained from a
look-up table.

    "chapternumber" yyy is obtained from the filename.

Accordingly:

    greek-01-001.tex appertains to Genesis chapter 1
    english-19-127.tex appertains to Psalm 127
    exposition-28-004.tex appertains to Hosea chapter 4
    publication-47-012.tex appertains to II Corinthians chapter 12

A 66-line look-up table provides the following values for each of the 66
books of the English Bible:

    bookname-common
    bookname-formal
    chaptercount

"bookname-common" is used in the identification header files of all four
categories ("greek", "english", "exposition", and "publication").

"bookname-formal" is used only in the LaTeX header of "publication" files.

"chaptercount" is included in the look-up table, so that file creation can
be automated.

----------------------------------------------------------------------

(Step 2) Copy to each "publication" file a LaTeX preamble.

The same preamble is used for each publication file, but within the
preamble are several labeled fields into which a number or a string needs
to be written; for example:

    bookname
    chapter
    revisiondate

"bookname" is the formal bookname, obtained from the look-up table.

"chapter" is the "chapternumber", obtained from the filename, but stripped
of leading zeroes.

"revisiondate" is a fixed string ("date monthname year") which indicates
the official revision date.

----------------------------------------------------------------------

(Step 3) Write to each "publication" file three LaTeX include statements
which specify the filenames for the corresponding "greek", "english", and
"exposition" files:

    \include greek-xx-yyy
    \include english-xx-yyy
    \include exposition-xx-yyy

No ".tex" suffix appears, because the include statement assumes a ".tex"
file.

----------------------------------------------------------------------

(Step 4) One or more additional Perl scripts are needed to process source
files from which the "english" and "greek" files are created.  The source
files are:

    (1) English translation of the Bible (either the King James Version or
else Young's Literal Translation).

    (2) Greek text of the Bible (either in native Greek or else in English
transliteration.)

The processing:

    (1) Removes or replaces artifacts, including non-LaTeX markup.

    (2) Adds required LaTeX markup.

    (3) Parses the source file (if it is monolithic) into chapter files.

----------------------------------------------------------------------


More information about the Houston mailing list