# to handle.
#
# by James Hammons
+# (C) 2017 Underground Software
#
import os
# Make a filename from the title...
levelNames[level] = MakeFilename(header['title'])
-
path = ''
for i in range(level):
path = path + str(levelNums[level]).zfill(2) + '_' + levelNames[level]
- # Append the appropriate footer, if the current file is one level
- # down from the previous...
+ # Append the appropriate footer to the last file, if the current file
+ # is one level down from the previous...
if ((level > 0) and (level > lastLevel)):
nfile = open(buildDir + lastFile + '.html', 'a')
nfile.write('\n{% children %}\n\n')
nfile.close()
- # Parts DO NOT have any content, they are ONLY an organizing construct!
- if (level == 0):
+ # Handle TOC scriblings...
+ if level == 0:
toc.write('<h2>Part ' + roman[levelNums[level]] + ': ' + header['title'] + '</h2>\n');
+ elif level == 1:
+ toc.write(' <p id=chapter>Ch. ' + str(levelNums[level]) + ': <a href="/' + levelNames[0] + '/' + levelNames[1] + '/">' + header['title'] + '</a></p>\n')
+ elif level == 2:
+ toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/">' + header['title'] + '</a><br>\n')
+ elif level == 3:
+ toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/">' + header['title'] + '</a><br>\n')
+ elif level == 4:
+ toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/' + levelNames[4] + '/">' + header['title'] + '</a><br>\n')
+ # Parts DO NOT have any content, they are ONLY an organizing construct!
+ if (level == 0):
os.mkdir(buildDir + path, 0o774)
nfile = open(buildDir + path + '.html', 'w')
nfile.write('---\n' + 'title: ' + header['title'] + '\n')
# Chapters, subchapters, sections & subsections all can have content.
# But the basic fundamental organizing unit WRT content is still the
# chapter.
- elif (level == 1):
- toc.write(' <p id=chapter>Ch. ' + str(levelNums[level]) + ': <a href="/' + levelNames[0] + '/' + levelNames[1] + '/">' + header['title'] + '</a></p>\n')
-
- os.mkdir(buildDir + path, 0o774)
-
- if ('include' in header):
- shutil.copy('include/' + header['include'], buildDir + path + '.html')
- else:
- htmlFile = open(buildDir + path + '.html', 'w')
- writingToFile = True
- htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
- if ('menu_title' in header):
- htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
- if ('style' in header):
- htmlFile.write('style: ' + header['style'] + '\n')
-
- htmlFile.write('---\n\n')
-
- elif (level == 2):
- toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/">' + header['title'] + '</a><br>\n')
-
- os.mkdir(buildDir + path, 0o774)
-
- if ('include' in header):
- shutil.copy('include/' + header['include'], buildDir + path + '.html')
- else:
- htmlFile = open(buildDir + path + '.html', 'w')
- writingToFile = True
- htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
- if ('menu_title' in header):
- htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
- if ('style' in header):
- htmlFile.write('style: ' + header['style'] + '\n')
-
- htmlFile.write('---\n\n')
-
- elif (level == 3):
- toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/">' + header['title'] + '</a><br>\n')
-
- os.mkdir(buildDir + path, 0o774)
-
- if ('include' in header):
- shutil.copy('include/' + header['include'], buildDir + path + '.html')
- else:
- htmlFile = open(buildDir + path + '.html', 'w')
- writingToFile = True
- htmlFile.write('---\n' + 'title: ' + header['title'] + '\n')
-
- if ('menu_title' in header):
- htmlFile.write('menu_title: ' + header['menu_title'] + '\n')
-
- if ('style' in header):
- htmlFile.write('style: ' + header['style'] + '\n')
-
- htmlFile.write('---\n\n')
-
- elif (level == 4):
- toc.write(' <a id=subchapter href="/' + levelNames[0] + '/' + levelNames[1] + '/' + levelNames[2] + '/' + levelNames[3] + '/' + levelNames[4] + '/">' + header['title'] + '</a><br>\n')
-
+ else:
os.mkdir(buildDir + path, 0o774)
if ('include' in header):