From: Shamus Hammons Date: Sat, 14 Jan 2017 19:31:52 +0000 (-0600) Subject: Added explode/implode convenience commands. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=ardour-manual-diverged;a=commitdiff_plain;h=868cf77b9cf3134a70f90802440ec713b3703e1c Added explode/implode convenience commands. Explode will take all the non-included content from the master document and split them into separate files in include/. Implode undoes this heinous action. ;-) --- diff --git a/explode b/explode new file mode 100755 index 0000000..ff2bd23 Binary files /dev/null and b/explode differ diff --git a/explode.cpp b/explode.cpp new file mode 100644 index 0000000..7d5cc32 --- /dev/null +++ b/explode.cpp @@ -0,0 +1,305 @@ +// +// Small program to 'explode' the master document automagically into separate +// files in the include/ directory. +// +// by James Hammons +// (C) 2017 Underground Software +// + +#include +#include +#include +#include // For mkdir() +#include + + +// Global variable (OMG YOU EVIL BASTARD!!) +char buffer[1024000], keyword[1024], token[1024]; +char title[1024], shortTitle[1024], inclFile[1024], style[1024]; +int level = 0, lastLevel = -1; +int lineCount = 0, startLine, sectionLineCount, fileCount = 0; +int part = 0, chapter = 0, subchapter = 0; +bool first = true; +bool nomove = false; +FILE * newFile = NULL; +char level1File[1024], level2File[1024], level3File[1024], temp[1024]; +char partFN[1024], chapterFN[1024], scLink[4096]; + + +void MakeFilename(char * fn) +{ + int l = strlen(fn); + + for(int i=0; i= 'A' && fn[i] <= 'Z') + fn[i] |= 0x20; + else if (fn[i] >= 'a' && fn[i] <= 'z') + ; + else if (fn[i] >= '0' && fn[i] <= '9') + ; + else + fn[i] = '_'; + } +} + + +bool ParseHeader(FILE * file) +{ + while (true) + { + // If we hit the EOF before finishing, something went horribly wrong + if (feof(file)) + break; + + fgets(buffer, 1023999, file); + lineCount++; + + // If we're seeing the end of header sentinel, return; we're done. + if (strncmp(buffer, "---", 3) == 0) + return true; + + sscanf(buffer, "%[^:]: %[^\n]", keyword, token); + + if (strcmp(keyword, "title") == 0) + { + strcpy(title, token); + } + else if (strcmp(keyword, "part") == 0) + { + lastLevel = level; + int len = strlen(token); + + if (len == 4) + level = 0, part++; + else if (len == 7) + level = 1, chapter++, subchapter = 0; + else if (len == 10) + level = 2, subchapter++; + else + level = -1; // Something went wrong + } + else if (strcmp(keyword, "include") == 0) + { + strcpy(inclFile, token); + } + else if (strcmp(keyword, "menu_title") == 0) + { + strcpy(shortTitle, token); + } + else if (strcmp(keyword, "style") == 0) + { + strcpy(style, token); + } + else if (strcmp(keyword, "exclude") == 0) + { + // Don't care about the token, just the keyword + nomove = true; + } + else + printf("Unknown keyword '%s' (token: %s)\n", keyword, token); + } + + // If we end up here, something went horribly wrong... + return false; +} + + +int main(int argc, char * argv[]) +{ + // First, check to see if this has been run here already. + FILE * fp = fopen("master-doc.txt", "r"); + fgets(buffer, 1023999, fp); + fclose(fp); + + if (strncmp(buffer, "", 17) == 0) + { + printf("Master file has already been exploded.\n"); + return 0; + } + + // First, rename the master document + rename("master-doc.txt", "master-doc.bak"); + + // Then open the .bak file + FILE * master = fopen("master-doc.bak", "r"); + + if (master == NULL) + { + printf("Could not open master doc (master-doc.txt) file!\n"); + return -1; + } + + // Create new master document + FILE * exp = fopen("master-doc.txt", "w"); + + if (exp == NULL) + { + printf("Could not open 'master-doc.txt' file!\n"); + fclose(master); + return -1; + } + + fprintf(exp, "\n"); + + while (!feof(master)) + { + fgets(buffer, 1023999, master); + lineCount++; + + // Look for start of file marker + if (strncmp(buffer, "---", 3) == 0) + { + // Reset the "short" title, include file & sytle + shortTitle[0] = 0; + inclFile[0] = 0; + style[0] = 0; + nomove = false; + + if (!ParseHeader(master)) + { + printf("Something went horribly wrong with the header parsing! Aborting!\n"); + break; + } + + // Close any previously opened files... + if (newFile != NULL) + { + fclose(newFile); + newFile = NULL; + } + + // We finished parsing our keyword block, now do something about + // it... :-P + + // temp, for explode only: + if (strlen(inclFile) > 0) + nomove = true; + + if (level == 0) + { + // Parts don't have any content... + + // Set up the "part" level of TOC link + sprintf(partFN, "%s", temp); + + // Set up content for the exploded part level + fprintf(exp, "\n---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + fprintf(exp, "part: part\n"); + fprintf(exp, "---\n\n\n"); + } + else if (level == 1) + { + // Make a filename from the title (not short title!) + strcpy(chapterFN, title); + MakeFilename(chapterFN); + + // Set up content for the exploded chapter level + fprintf(exp, "---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + if (strlen(inclFile) > 0) + fprintf(exp, "include: %s\n", inclFile); + else + fprintf(exp, "include: %s.html\n", chapterFN); + + // If it was already an include file, mark it to stay in include/ + if (nomove) + fprintf(exp, "exclude: yes\n"); + + fprintf(exp, "part: chapter\n"); + fprintf(exp, "---\n\n"); + + // Make the file expected at this level (but only if not + // included)... + if (nomove == false) + { + fileCount++; + sprintf(temp, "include/%s.html", chapterFN); + newFile = fopen(temp, "w"); + fprintf(newFile, "---\n"); + fprintf(newFile, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(newFile, "menu_title: %s\n", shortTitle); + + fprintf(newFile, "---\n"); + } + } + else if (level == 2) + { + strcpy(scLink, title); + MakeFilename(scLink); + + // Set up content for the exploded subchapter level + fprintf(exp, "---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + if (strlen(inclFile) > 0) + fprintf(exp, "include: %s\n", inclFile); + else + fprintf(exp, "include: %s.html\n", scLink); + + // If it was already an include file, mark it to stay in include/ + if (nomove) + fprintf(exp, "exclude: yes\n"); + + fprintf(exp, "part: subchapter\n"); + fprintf(exp, "---\n\n"); + + if (nomove == false) + { + fileCount++; + sprintf(temp, "include/%s.html", scLink); + newFile = fopen(temp, "w"); + fprintf(newFile, "---\n"); + fprintf(newFile, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(newFile, "menu_title: %s\n", shortTitle); + + if (strlen(style) > 0) + fprintf(newFile, "style: %s\n", style); + + fprintf(newFile, "---\n"); + } + } + } + else + { + if (((level == 1) || (level == 2)) && (newFile != NULL)) + fprintf(newFile, "%s", buffer); + } + + // Kill the buffer to prevent false positives... + buffer[0] = 0; + } + + printf("\nProcessed %i lines.\n", lineCount); + printf("Exploded master document into %i files.\n", fileCount); + + fclose(master); + fclose(exp); + + if (newFile) + fclose(newFile); + + // Finally, remove the .bak file: + remove("master-doc.bak"); + + return 0; +} + diff --git a/implode b/implode new file mode 100755 index 0000000..c9b8795 Binary files /dev/null and b/implode differ diff --git a/implode.cpp b/implode.cpp new file mode 100644 index 0000000..f845c1e --- /dev/null +++ b/implode.cpp @@ -0,0 +1,339 @@ +// +// Small program to 'implode' the master document automagically from separate +// files in the include/ directory. +// +// by James Hammons +// (C) 2017 Underground Software +// + +#include +#include +#include +#include // For mkdir() +#include + + +// Global variable (OMG YOU EVIL BASTARD!!) +char buffer[1024000], keyword[1024], token[1024]; +char title[1024], shortTitle[1024], inclFile[1024], style[1024]; +int level = 0, lastLevel = -1; +int lineCount = 0, startLine, sectionLineCount, fileCount = 0; +int part = 0, chapter = 0, subchapter = 0; +bool first = true; +bool nomove = false; +FILE * newFile = NULL; +char level1File[1024], level2File[1024], level3File[1024], temp[1024]; +char partFN[1024], chapterFN[1024], scLink[4096]; + + +void MakeFilename(char * fn) +{ + int l = strlen(fn); + + for(int i=0; i= 'A' && fn[i] <= 'Z') + fn[i] |= 0x20; + else if (fn[i] >= 'a' && fn[i] <= 'z') + ; + else if (fn[i] >= '0' && fn[i] <= '9') + ; + else + fn[i] = '_'; + } +} + + +long SkipHeader(FILE * file) +{ + long length = 0; + + while (true) + { + // If we hit the EOF before finishing, something went horribly wrong + if (feof(file)) + break; + + fgets(buffer, 1023999, file); + length += strlen(buffer) + 1; + + // If we're seeing the end of header sentinel, return; we're done. + if (strncmp(buffer, "---", 3) == 0) + break; + } + + while (true) + { + // If we hit the EOF before finishing, something went horribly wrong + if (feof(file)) + break; + + fgets(buffer, 1023999, file); + length += strlen(buffer) + 1; + + // If we're seeing the end of header sentinel, return; we're done. + if (strncmp(buffer, "---", 3) == 0) + break; + } + + return length; +} + + +void CopyFileToStream(char * from, FILE * toFile) +{ + FILE * fromFile = fopen(from, "r"); + + if (fromFile == NULL) + { + printf("\n\nCould not open file '%s' for reading! Aborting!!\n", from); + exit(1); + } + + fseek(fromFile, 0, SEEK_END); + long length = ftell(fromFile); + rewind(fromFile); + long skipped = SkipHeader(fromFile); + skipped = ftell(fromFile); + + for(long i=skipped; i", 17) == 0) + { + printf("Master file has already been imploded.\n"); + return 0; + } + + // First, rename the master document + rename("master-doc.txt", "master-doc.bak"); + + // Then open the .bak file + FILE * master = fopen("master-doc.bak", "r"); + + if (master == NULL) + { + printf("Could not open master doc (master-doc.txt) file!\n"); + return -1; + } + + // Create new master document + FILE * exp = fopen("master-doc.txt", "w"); + + if (exp == NULL) + { + printf("Could not open 'master-doc.txt' file!\n"); + fclose(master); + return -1; + } + + fprintf(exp, "\n"); + + while (!feof(master)) + { + fgets(buffer, 1023999, master); + lineCount++; + + // Look for start of file marker + if (strncmp(buffer, "---", 3) == 0) + { + // Reset the "short" title, include file & style + shortTitle[0] = 0; + inclFile[0] = 0; + style[0] = 0; + nomove = false; + + if (!ParseHeader(master)) + { + printf("Something went horribly wrong with the header parsing! Aborting!\n"); + break; + } + + // Close any previously opened files... + if (newFile != NULL) + { + fclose(newFile); + newFile = NULL; + } + + // We finished parsing our keyword block, now do something about + // it... :-P + if (level == 0) + { + // Parts don't have any content... + + // Set up the "part" level of TOC link + sprintf(partFN, "%s", temp); + + // Set up content for the imploded part level + fprintf(exp, "\n---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + fprintf(exp, "part: part\n"); + fprintf(exp, "---\n\n\n"); + } + else if (level == 1) + { + // Make a filename from the title (not short title!) + strcpy(chapterFN, title); + MakeFilename(chapterFN); + + // Set up content for the imploded chapter level + fprintf(exp, "---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + // If it was already an include file, mark it to stay in include/ + if (nomove) + { + fprintf(exp, "include: %s\n", inclFile); + fprintf(exp, "exclude: yes\n"); + } + + fprintf(exp, "part: chapter\n"); + fprintf(exp, "---\n"); + + // Make the file expected at this level (but only if not + // included)... + if (nomove == false) + { + fileCount++; + sprintf(temp, "include/%s.html", chapterFN); + CopyFileToStream(temp, exp); + remove(temp); + } + else + fprintf(exp, "\n"); + } + else if (level == 2) + { + strcpy(scLink, title); + MakeFilename(scLink); + + // Set up content for the exploded subchapter level + fprintf(exp, "---\n"); + fprintf(exp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(exp, "menu_title: %s\n", shortTitle); + + // If it was already an include file, mark it to stay in include/ + if (nomove) + { + fprintf(exp, "include: %s\n", inclFile); + fprintf(exp, "exclude: yes\n"); + } + + fprintf(exp, "part: subchapter\n"); + fprintf(exp, "---\n"); + + if (nomove == false) + { + fileCount++; + sprintf(temp, "include/%s.html", scLink); + CopyFileToStream(temp, exp); + remove(temp); + } + else + fprintf(exp, "\n"); + } + } + + // Kill the buffer to prevent false positives... + buffer[0] = 0; + } + + printf("\nProcessed %i lines.\n", lineCount); + printf("Imploded master document from %i files.\n", fileCount); + + fclose(master); + fclose(exp); + + if (newFile) + fclose(newFile); + + // Finally, remove the .bak file: + remove("master-doc.bak"); + + return 0; +} + diff --git a/master-doc.txt b/master-doc.txt index 2b0f672..b55c71d 100644 --- a/master-doc.txt +++ b/master-doc.txt @@ -1,3 +1,5 @@ + + --- title: Introduction to Ardour part: part @@ -1833,6 +1835,8 @@ part: subchapter + + --- title: System Configuration part: part @@ -2416,7 +2420,7 @@ part: subchapter dialog"/> --- -title: Misc Tab +title: Global Misc Tab menu_title: Misc Tab part: subchapter --- @@ -3960,7 +3964,7 @@ part: subchapter image of meterbidge with all options on --- -title: Misc Tab +title: Session Misc Tab menu_title: Misc Tab part: subchapter --- @@ -4018,14 +4022,16 @@ part: chapter --- title: Controlling Ardour with OSC -part: subchapter include: controlling-ardour-with-osc.html +exclude: yes +part: subchapter --- --- title: Controlling Ardour with OSC (Ardour 4.7 and Prior) -part: subchapter include: controlling-ardour-with-osc-4.7-and-prior.html +exclude: yes +part: subchapter --- --- @@ -6950,6 +6956,8 @@ part: subchapter + + --- title: Ardour's Interface part: part @@ -8100,6 +8108,8 @@ part: subchapter + + --- title: Sessions & Tracks part: part @@ -9805,6 +9815,8 @@ part: chapter --- + + --- title: Playback & Recording part: part @@ -10416,6 +10428,8 @@ part: subchapter

Broken links + + --- title: Editing part: part @@ -11125,7 +11139,7 @@ part: subchapter --- -title: Editing Clips and Selections +title: Editing Regions and Selections part: chapter --- @@ -11684,6 +11698,8 @@ part: chapter --- + + --- title: MIDI part: part @@ -12460,6 +12476,8 @@ part: chapter --- + + --- title: Arranging part: part @@ -12681,6 +12699,8 @@ part: chapter --- + + --- title: Mixing part: part @@ -14840,6 +14860,8 @@ part: subchapter

+ + --- title: Surround part: part @@ -14968,6 +14990,8 @@ panner in 4 in, 5 out mode"/>

+ + --- title: Sync & Video part: part @@ -16097,6 +16121,8 @@ part: subchapter

+ + --- title: Scripting part: part @@ -16576,8 +16602,9 @@ close_session() --- -style: luadoc title: Class Reference -part: subchapter include: class_reference.html +exclude: yes +part: subchapter --- + diff --git a/munge b/munge index 8176b44..216c93d 100755 Binary files a/munge and b/munge differ diff --git a/munge.cpp b/munge.cpp index 61e1a6b..7cca133 100644 --- a/munge.cpp +++ b/munge.cpp @@ -13,6 +13,18 @@ #include +// Global variables (ZOMG YOU HIDEOUS BASTARD!!) +char buffer[1024000], keyword[1024], token[1024]; +char title[1024], shortTitle[1024], inclFile[1024], style[1024]; +int level = 0, lastLevel = -1; +int lineCount = 0, startLine, sectionLineCount; +int part = 0, chapter = 0, subchapter = 0; +bool first = true, nomove = false; +FILE * newFile = NULL; +char level1File[1024], level2File[1024], level3File[1024], temp[1024], temp2[1024]; +char partFN[1024], chapterFN[1024], scLink[4096]; + + void MakeFilename(char * fn) { int l = strlen(fn); @@ -33,6 +45,101 @@ void MakeFilename(char * fn) } +// +// There's probably posix function to do this, if you find it, feel free to +// nuke this crap +// +void CopyFile(char * from, char * to) +{ + FILE * fromFile = fopen(from, "r"); + + if (fromFile == NULL) + { + printf("\n\nCould not open file '%s' for reading! Aborting!!\n", from); + exit(1); + } + + FILE * toFile = fopen(to, "w"); + + if (toFile == NULL) + { + printf("\n\nCould not open file '%s' for writing! Aborting!!\n", to); + exit(1); + } + + fseek(fromFile, 0, SEEK_END); + long length = ftell(fromFile); + rewind(fromFile); + + for(long i=0; i 0) + printf(" [%s]", inclFile); + + startLine = lineCount; + + // Add appropriate suffix chapter content if needed + if ((lastLevel == 1) && (level == 2)) + { + if (newFile != NULL) + { + fprintf(newFile, "\n{%% children %%}\n\n"); + } + else + { + // If it didn't stream, it was a included file, so append to + // it directly... + sprintf(temp2, "%s.html", level2File); + FILE * tfp = fopen(temp2, "a"); + fprintf(tfp, "\n{%% children %%}\n\n"); + fclose(tfp); + } + } + + // Close any previously opened files... + if (newFile != NULL) + { + fclose(newFile); + newFile = NULL; + } - while (true) + if (level == 0) + { + // Parts don't have any content... + strcpy(temp, title); + MakeFilename(temp); + sprintf(level1File, "_manual/%02d_%s", part, temp); + mkdir(level1File, 0777); + + // Set up the "part" level of TOC link + sprintf(partFN, "%s", temp); + fprintf(toc, "

Part %s: %s

\n", roman[part], title); + + // Make the file expected at this level... + sprintf(temp, "%s.html", level1File); + FILE * tfp = fopen(temp, "w"); + fprintf(tfp, "---\n"); + fprintf(tfp, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(tfp, "menu_title: %s\n", shortTitle); + + fprintf(tfp, "---\n"); + fprintf(tfp, "\n{%% children %%}\n\n"); + fclose(tfp); + } + else if (level == 1) { - fgets(buffer, 1023999, master); - lineCount++; - - if (strncmp(buffer, "---", 3) != 0) + strcpy(temp, title); + MakeFilename(temp); + sprintf(level2File, "%s/%02d_%s", level1File, chapter, temp); + mkdir(level2File, 0777); + + // Set up the "chapter" part of the TOC link + sprintf(chapterFN, "%s", temp); + fprintf(toc, "

Ch. %d:  %s

\n", chapter, partFN, chapterFN, title); + + // If there's an include file, copy it... + if (strlen(inclFile) > 0) { - sscanf(buffer, "%[^:]: %[^\n]", keyword, token); - - if (strcmp(keyword, "title") == 0) - { - strcpy(title, token); - } - else if (strcmp(keyword, "part") == 0) - { - lastLevel = level; - int len = strlen(token); - - if (len == 4) - level = 0, part++; - else if (len == 7) - level = 1, chapter++, subchapter = 0; - else if (len == 10) - level = 2, subchapter++; - else - level = -1; // Something went wrong - } - else if (strcmp(keyword, "include") == 0) - { - strcpy(inclFile, token); - } - else if (strcmp(keyword, "menu_title") == 0) - { - strcpy(shortTitle, token); - } - else if (strcmp(keyword, "style") == 0) - { - strcpy(style, token); - } - else - printf("Unknown keyword '%s' (token: %s)\n", keyword, token); + sprintf(temp, "include/%s", inclFile); + sprintf(temp2, "%s.html", level2File); + CopyFile(temp, temp2); } else { - // We hit the end of our keyword block, now do something - // about it... :-P - if (level == 0) - printf("\nPart %s: ", roman[part]); - else if (level == 1) - printf("\n\tCh. %d: ", chapter); - else if (level == 2) - printf("\t\t"); - - printf("%s", title); - - if (strlen(inclFile) > 0) - printf(" [%s]", inclFile); - - startLine = lineCount; - - // Cleanup our chapter content - if (lastLevel == 1) - { - if (newFile != NULL) - { - if (level == 2) - fprintf(newFile, "\n{%% children %%}\n\n"); - - fclose(newFile); - newFile = NULL; - } - } - - if (level == 0) - { - // Parts & chapters don't have any content... - strcpy(temp, title); - MakeFilename(temp); - sprintf(level1File, "_manual/%02d_%s", part, temp); - mkdir(level1File, 0777); - - // Set up the "part" level of TOC link - sprintf(partFN, "%s", temp); - fprintf(toc, "

Part %s: %s

\n", roman[part], title); - - // Make the file expected at this level... - sprintf(temp, "%s.html", level1File); - FILE * tfp = fopen(temp, "w"); - fprintf(tfp, "---\n"); - fprintf(tfp, "title: %s\n", title); - - if (strlen(shortTitle) > 0) - fprintf(tfp, "menu_title: %s\n", shortTitle); - - fprintf(tfp, "---\n"); - fprintf(tfp, "\n{%% children %%}\n\n"); - fclose(tfp); - } - else if (level == 1) - { - strcpy(temp, title); - MakeFilename(temp); - sprintf(level2File, "%s/%02d_%s", level1File, chapter, temp); - mkdir(level2File, 0777); - - // Set up the "chapter" part of the TOC link - sprintf(chapterFN, "%s", temp); - fprintf(toc, "

Ch. %d:  %s

\n", chapter, partFN, chapterFN, title); - - // Make the file expected at this level... - sprintf(temp, "%s.html", level2File); - newFile = fopen(temp, "w"); - fprintf(newFile, "---\n"); - fprintf(newFile, "title: %s\n", title); - - if (strlen(shortTitle) > 0) - fprintf(newFile, "menu_title: %s\n", shortTitle); - - fprintf(newFile, "---\n\n"); -// fprintf(tfp, "\n{%% children %%}\n\n"); -// fclose(tfp); - } - else if (level == 2) - { - strcpy(temp, title); - MakeFilename(temp); - sprintf(level3File, "%s/%02d_%s.html", level2File, subchapter, temp); - - // Make the file expected at this level... - if (newFile != NULL) - fclose(newFile); - - // Make the link - sprintf(scLink, "/%s/%s/%s/", partFN, chapterFN, temp); - fprintf(toc, " %s
\n", scLink, title); - - if (strlen(inclFile) > 0) - { - // Copy the include file to the appropriate spot... - sprintf(temp, "include/%s", inclFile); - FILE * fileToCopy = fopen(temp, "r"); - newFile = fopen(level3File, "w"); - fseek(fileToCopy, 0, SEEK_END); - long length = ftell(fileToCopy); - rewind(fileToCopy); - - for(long i=0; i 0) - fprintf(newFile, "menu_title: %s\n", shortTitle); - - if (strlen(style) > 0) - fprintf(newFile, "style: %s\n", style); - - fprintf(newFile, "---\n\n"); - } - } - - break; + // Make the file expected at this level... + sprintf(temp, "%s.html", level2File); + newFile = fopen(temp, "w"); + fprintf(newFile, "---\n"); + fprintf(newFile, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(newFile, "menu_title: %s\n", shortTitle); + + fprintf(newFile, "---\n\n"); + } + } + else if (level == 2) + { + strcpy(temp, title); + MakeFilename(temp); + sprintf(level3File, "%s/%02d_%s.html", level2File, subchapter, temp); + + // Make the file expected at this level... + + // Make the link + sprintf(scLink, "/%s/%s/%s/", partFN, chapterFN, temp); + fprintf(toc, " %s
\n", scLink, title); + + // If there's an include file, copy it... + if (strlen(inclFile) > 0) + { + sprintf(temp, "include/%s", inclFile); + CopyFile(temp, level3File); + } + else + { + // Otherwise, stream it out of the master document + newFile = fopen(level3File, "w"); + fprintf(newFile, "---\n"); + fprintf(newFile, "title: %s\n", title); + + if (strlen(shortTitle) > 0) + fprintf(newFile, "menu_title: %s\n", shortTitle); + + if (strlen(style) > 0) + fprintf(newFile, "style: %s\n", style); + + fprintf(newFile, "---\n\n"); } } } else { if (((level == 1) || (level == 2)) && (newFile != NULL)) - fprintf(newFile, "%s\n", buffer); + fprintf(newFile, "%s", buffer); } + + // Make sure no spurious garbage signals a false positive + buffer[0] = 0; } printf("\n\nProcessed %i lines.\n", lineCount);