]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/tex2rtf/src/htmlutil.cpp
Added files to Tex2RTF file list
[wxWidgets.git] / utils / tex2rtf / src / htmlutil.cpp
index b85e33f4a4f6f9155b65bd15e73c8982741caa82..ea8b6efc2e6ce9bfe7f914870cf798c59d6f4e8b 100644 (file)
@@ -181,7 +181,7 @@ void ReopenFile(FILE **fd, char **fileName)
 {
   if (*fd)
   {
-    fprintf(*fd, "\n</BODY></HTML>\n");
+    fprintf(*fd, "\n</FONT></BODY></HTML>\n");
     fclose(*fd);
   }
   fileId ++;
@@ -583,6 +583,17 @@ char *ParseColourString(char *bkStr, bool *isPicture)
   else return NULL;
 }
 
+void OutputFont(void)
+{
+  // Output <FONT FACE=...>
+  TexOutput("<FONT FACE=\"");
+  if (htmlFaceName)
+       TexOutput(htmlFaceName);
+  else
+       TexOutput("Times New Roman");
+  TexOutput("\">\n");
+}
+
 // Output start of <BODY> block
 void OutputBodyStart(void)
 {
@@ -637,6 +648,26 @@ void OutputBodyStart(void)
     }
   }
   TexOutput(">\n");
+
+  OutputFont();
+}
+
+void HTMLHead()
+{
+  TexOutput("<head>");
+  if (htmlStylesheet) {
+    TexOutput("<link rel=stylesheet type=\"text/css\" href=\"");
+    TexOutput(htmlStylesheet);
+    TexOutput("\">");
+  }
+};
+
+void HTMLHeadTo(FILE* f)
+{
+  if (htmlStylesheet)
+    fprintf(f,"<head><link rel=stylesheet type=\"text/css\" href=\"%s\">",htmlStylesheet);
+  else
+    fprintf(f,"<head>");
 }
 
 // Called on start/end of macro examination
@@ -669,7 +700,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
 
       SetCurrentOutput(Chapters);
 
-      TexOutput("<head><title>");
+      HTMLHead();
+      TexOutput("<title>");
       OutputCurrentSection(); // Repeat section header
       TexOutput("</title></head>\n");
       OutputBodyStart();
@@ -707,8 +739,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
       // Add this section title to the list of keywords
       if (htmlIndex)
       {
-        OutputCurrentSectionToString(wxBuffer);
-        AddKeyWordForTopic(topicName, wxBuffer, ConvertCase(currentFileName));
+        OutputCurrentSectionToString(wxTex2RTFBuffer);
+        AddKeyWordForTopic(topicName, wxTex2RTFBuffer, ConvertCase(currentFileName));
       }
     }
     break;
@@ -738,7 +770,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
       if (htmlWorkshopFiles) HTMLWorkshopAddToContents(1, topicName, SectionsName);
 
       SetCurrentOutput(Sections);
-      TexOutput("<head><title>");
+      HTMLHead();
+      TexOutput("<title>");
       OutputCurrentSection();
       TexOutput("</title></head>\n");
       OutputBodyStart();
@@ -769,8 +802,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
       // Add this section title to the list of keywords
       if (htmlIndex)
       {
-        OutputCurrentSectionToString(wxBuffer);
-        AddKeyWordForTopic(topicName, wxBuffer, currentFileName);
+        OutputCurrentSectionToString(wxTex2RTFBuffer);
+        AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName);
       }
     }
     break;
@@ -831,7 +864,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
             if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SubsectionsName);
             SetCurrentOutput(Subsections);
 
-            TexOutput("<head><title>");
+           HTMLHead();
+            TexOutput("<title>");
             OutputCurrentSection();
             TexOutput("</title></head>\n");
             OutputBodyStart();
@@ -876,8 +910,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
           // Add this section title to the list of keywords
           if (htmlIndex)
           {
-            OutputCurrentSectionToString(wxBuffer);
-            AddKeyWordForTopic(topicName, wxBuffer, currentFileName);
+            OutputCurrentSectionToString(wxTex2RTFBuffer);
+            AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName);
           }
 
       }
@@ -911,7 +945,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
             if (htmlWorkshopFiles) HTMLWorkshopAddToContents(3, topicName, SubsubsectionsName);
 
             SetCurrentOutput(Subsubsections);
-            TexOutput("<head><title>");
+           HTMLHead();
+            TexOutput("<title>");
             OutputCurrentSection();
             TexOutput("</title></head>\n");
             OutputBodyStart();
@@ -954,8 +989,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
         // Add this section title to the list of keywords
         if (htmlIndex)
         {
-          OutputCurrentSectionToString(wxBuffer);
-          AddKeyWordForTopic(topicName, wxBuffer, currentFileName);
+          OutputCurrentSectionToString(wxTex2RTFBuffer);
+          AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName);
         }
       }
     }
@@ -1027,7 +1062,8 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
       if (inTabular)
       {
         // End cell, start cell
-        TexOutput("</TD>");
+
+        TexOutput("</FONT></TD>");
 
         // Start new row and cell, setting alignment for the first cell.
         if (currentColumn < noColumns)
@@ -1051,6 +1087,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
         else
           sprintf(buf, "\n<TD ALIGN=LEFT>");
         TexOutput(buf);
+               OutputFont();
       }
       else
         TexOutput("&amp;");
@@ -1099,12 +1136,13 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
       else
         sprintf(buf, "<TR>\n<TD ALIGN=LEFT>");
       TexOutput(buf);
+         OutputFont();
     }
     else
     {
       // End cell and row
       // Start new row and cell
-      TexOutput("</TD>\n</TR>\n");
+      TexOutput("</FONT></TD>\n</TR>\n");
     }
     break;
   }
@@ -1988,7 +2026,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
          {
             TexOutput("<img src=\"");
             TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename)));
-            TexOutput("\""); TexOutput(alignment); TexOutput("></A>");
+            TexOutput("\""); TexOutput(alignment); TexOutput(">");
             delete[] inlineFilename;
          }
         }
@@ -2094,6 +2132,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
       descriptionItemArg = GetArgChunk();
       return FALSE;
     }
+    return TRUE;
   }
   case ltTWOCOLITEM:
   case ltTWOCOLITEMRULED:
@@ -2114,8 +2153,9 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
           TexOutput(buf);
         } else
           TexOutput("\n<TR><TD VALIGN=TOP>\n");
+               OutputFont();
       }  else
-            TexOutput("\n</TD>\n");
+            TexOutput("\n</FONT></TD>\n");
     }
     if (arg_no == 2)
     {
@@ -2127,8 +2167,9 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
           TexOutput(buf);
         } else 
            TexOutput("\n<TD VALIGN=TOP>\n");
+               OutputFont();
       }  else
-           TexOutput("\n</TD></TR>\n");
+           TexOutput("\n</FONT></TD></TR>\n");
     }
     return TRUE;
     break;
@@ -2630,6 +2671,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
         if (compatibilityMode)
         {
           TexOutput("<TR>\n<TD>");
+                 OutputFont();
 /*
           for (int i = 0; i < noColumns; i++)
           {
@@ -2670,7 +2712,8 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
       else
         sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot));
 
-      TexOutput("<head><title>");
+      HTMLHead();
+      TexOutput("<title>");
       TexOutput(ReferencesNameString);
       TexOutput("</title></head>\n");
       OutputBodyStart();
@@ -2909,25 +2952,25 @@ bool HTMLGo(void)
 
     if (Chapters)
     {
-      fprintf(Chapters, "\n</BODY></HTML>\n");
+      fprintf(Chapters, "\n</FONT></BODY></HTML>\n");
       fclose(Chapters);
       Chapters = NULL;
     }
     if (Sections)
     {
-      fprintf(Sections, "\n</BODY></HTML>\n");
+      fprintf(Sections, "\n</FONT></BODY></HTML>\n");
       fclose(Sections);
       Sections = NULL;
     }
     if (Subsections && !combineSubSections)
     {
-      fprintf(Subsections, "\n</BODY></HTML>\n");
+      fprintf(Subsections, "\n</FONT></BODY></HTML>\n");
       fclose(Subsections);
       Subsections = NULL;
     }
     if (Subsubsections && !combineSubSections)
     {
-      fprintf(Subsubsections, "\n</BODY></HTML>\n");
+      fprintf(Subsubsections, "\n</FONT></BODY></HTML>\n");
       fclose(Subsubsections);
       Subsubsections = NULL;
     }
@@ -2948,17 +2991,19 @@ bool HTMLGo(void)
       if (DocumentTitle)
       {
         SetCurrentOutput(tmpTitle);
-        TexOutput("\n<HTML>\n<HEAD><TITLE>");
+       HTMLHead();
+        TexOutput("\n<HEAD><TITLE>");
         TraverseChildrenFromChunk(DocumentTitle);
         TexOutput("</TITLE></HEAD>\n");
       }
       else
       {
         SetCurrentOutput(tmpTitle);
+       HTMLHeadTo(tmpTitle);
         if (contentsString)
-          fprintf(tmpTitle, "<HEAD><TITLE>%s</TITLE></HEAD>\n\n", contentsString);
+          fprintf(tmpTitle, "<TITLE>%s</TITLE></HEAD>\n\n", contentsString);
         else
-          fprintf(tmpTitle, "<HEAD><TITLE>%s</TITLE></HEAD>\n\n", FileNameFromPath(FileRoot));
+          fprintf(tmpTitle, "<TITLE>%s</TITLE></HEAD>\n\n", FileNameFromPath(FileRoot));
       }
 
       // Output frame information
@@ -2995,7 +3040,7 @@ bool HTMLGo(void)
         fclose(fd);
       }
 
-      fprintf(tmpTitle, "\n</BODY>\n");
+      fprintf(tmpTitle, "\n</FONT></BODY>\n");
 
       if (htmlFrameContents)
       {
@@ -3141,8 +3186,10 @@ void GenerateHTMLWorkshopFiles(char *fname)
 
   fprintf(f,
       "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
-      "<HTML>\n"
-      "<HEAD>\n"
+      "<HTML>\n");
+  HTMLHeadTo(f);
+  fprintf(f,
+      "\n"
       "<meta name=\"GENERATOR\" content=\"tex2rtf\">\n"
       "<!-- Sitemap 1.0 -->\n"
       "</HEAD><BODY>\n"
@@ -3217,8 +3264,10 @@ void HTMLWorkshopStartContents()
 
   fprintf(HTMLWorkshopContents,
       "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
-      "<HTML>\n"
-      "<HEAD>\n"
+      "<HTML>\n");
+  HTMLHeadTo(HTMLWorkshopContents);
+  fprintf(HTMLWorkshopContents,
+      "\n"
       "<meta name=\"GENERATOR\" content=\"tex2rtf\">\n"
       "<!-- Sitemap 1.0 -->\n"
       "</HEAD><BODY>\n"