]> Shamusworld >> Repos - ardour-manual-diverged/commitdiff
Fix for "munge" to allow content at chapter level.
authorShamus Hammons <jlhamm@acm.org>
Thu, 12 Jan 2017 16:28:35 +0000 (10:28 -0600)
committerShamus Hammons <jlhamm@acm.org>
Thu, 12 Jan 2017 16:28:35 +0000 (10:28 -0600)
master-doc.txt
munge
munge.cpp

index 92f8e48b49b4f151a9bce55cca44a4cbc804181b..b8fa40015a2c35ade584f1caa904262d8474d54c 100644 (file)
@@ -6955,12 +6955,12 @@ part: subchapter
 </ul>
 
 
-
 ---
 title: Ardour's Interface
 part: part
 ---
 
+
 ---
 title: Global view
 part: chapter
@@ -7008,6 +7008,7 @@ part: chapter
 
 <p class="fixme">Add content</p>
 
+
 ---
 title: Status Bar
 part: chapter
@@ -7015,6 +7016,7 @@ part: chapter
 
 <p class="fixme">Add content</p>
 
+
 ---
 title: Transport bar and times
 part: chapter
@@ -7049,14 +7051,11 @@ part: chapter
   <li>the Mode Selector, allowing to switch between Editor and Mixer views, or edit the Preferences.</li>
 </ul>
 
-
-
 ---
 title: The Transport Bar
 part: subchapter
 ---
 
-
 <p>
   The <dfn>Transport Bar</dfn> groups all the actions regarding the control of playback and recording.
 </p>
@@ -7136,7 +7135,6 @@ part: subchapter
   </li>
 </ul>
 
-
 ---
 title: Times
 part: subchapter
diff --git a/munge b/munge
index 3a9d3f504f0c42b9fdb801d392ae4d28d9c49eb6..8b2261d723b4f9fd1e1fb7bcc63f5b74fd4eb5ed 100755 (executable)
Binary files a/munge and b/munge differ
index e8c095d10dbc2dea323101dd4ffccc962d497933..493cdbd7cb8f1cf21ec8b77fc01b4f8309040a06 100644 (file)
--- a/munge.cpp
+++ b/munge.cpp
@@ -60,7 +60,7 @@ int main(int argc, char * argv[])
 
        char buffer[1024000], keyword[1024], token[1024];
        char title[1024], shortTitle[1024], inclFile[1024], style[1024];
-       int level = 0;
+       int level = 0, lastLevel = -1;
        int lineCount = 0, startLine, sectionLineCount;
        int part = 0, chapter = 0, subchapter = 0;
        bool first = true;
@@ -104,6 +104,7 @@ int main(int argc, char * argv[])
                                        }
                                        else if (strcmp(keyword, "part") == 0)
                                        {
+                                               lastLevel = level;
                                                int len = strlen(token);
 
                                                if (len == 4)
@@ -148,6 +149,17 @@ int main(int argc, char * argv[])
 
                                        startLine = lineCount;
 
+                                       // Cleanup our chapter content
+                                       if (lastLevel == 1)
+                                       {
+                                               if (newFile != NULL)
+                                               {
+                                                       fprintf(newFile, "\n{%% children %%}\n\n");
+                                                       fclose(newFile);
+                                                       newFile = NULL;
+                                               }
+                                       }
+
                                        if (level == 0)
                                        {
                                                // Parts & chapters don't have any content...
@@ -186,16 +198,16 @@ int main(int argc, char * argv[])
 
                                                // Make the file expected at this level...
                                                sprintf(temp, "%s.html", level2File);
-                                               FILE * tfp = fopen(temp, "w");
-                                               fprintf(tfp, "---\n");
-                                               fprintf(tfp, "title: %s\n", title);
+                                               newFile = fopen(temp, "w");
+                                               fprintf(newFile, "---\n");
+                                               fprintf(newFile, "title: %s\n", title);
 
                                                if (strlen(shortTitle) > 0)
-                                                       fprintf(tfp, "menu_title: %s\n", shortTitle);
+                                                       fprintf(newFile, "menu_title: %s\n", shortTitle);
 
-                                               fprintf(tfp, "---\n");
-                                               fprintf(tfp, "\n{%% children %%}\n\n");
-                                               fclose(tfp);
+                                               fprintf(newFile, "---\n\n");
+//                                             fprintf(tfp, "\n{%% children %%}\n\n");
+//                                             fclose(tfp);
                                        }
                                        else if (level == 2)
                                        {
@@ -250,7 +262,7 @@ int main(int argc, char * argv[])
                }
                else
                {
-                       if ((level == 2) && (newFile != NULL))
+                       if (((level == 1) || (level == 2)) && (newFile != NULL))
                                fprintf(newFile, "%s\n", buffer);
                }
        }