X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31ad62bc096aaa3de3e0702c92d75b2e43c32605..90aaa86507f004720d761a737478a99c19689078:/utils/tex2rtf/src/htmlutil.cpp diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp index c91ca52c9f..1029c30603 100644 --- a/utils/tex2rtf/src/htmlutil.cpp +++ b/utils/tex2rtf/src/htmlutil.cpp @@ -181,7 +181,7 @@ void ReopenFile(FILE **fd, char **fileName) { if (*fd) { - fprintf(*fd, "\n\n"); + fprintf(*fd, "\n\n"); fclose(*fd); } fileId ++; @@ -191,7 +191,7 @@ void ReopenFile(FILE **fd, char **fileName) else sprintf(buf, "%s%d.html", FileRoot, fileId); if (*fileName) delete[] *fileName; - *fileName = copystring(FileNameFromPath(buf)); + *fileName = copystring(wxFileNameFromPath(buf)); *fd = fopen(buf, "w"); fprintf(*fd, "\n"); } @@ -426,13 +426,13 @@ void AddBrowseButtons(char *upLabel, char *upFilename, if (truncateFilenames) { char buf1[80]; - strcpy(buf1, ConvertCase(FileNameFromPath(FileRoot))); + strcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); sprintf(buf, "\n%s ", buf1, ConvertCase("htm"), contentsReference); } else { char buf1[80]; - strcpy(buf1, ConvertCase(FileNameFromPath(FileRoot))); + strcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); sprintf(buf, "\n%s ", buf1, ConvertCase("_contents.html"), contentsReference); } // TexOutput(""); @@ -583,6 +583,20 @@ char *ParseColourString(char *bkStr, bool *isPicture) else return NULL; } +void OutputFont(void) +{ + // Only output <font face> if explicitly requested by htmlFaceName= directive in + // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's + // default font: + if (htmlFaceName) + { + // Output <FONT FACE=...> + TexOutput("<FONT FACE=\""); + TexOutput(htmlFaceName); + TexOutput("\">\n"); + } +} + // Output start of <BODY> block void OutputBodyStart(void) { @@ -637,6 +651,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,16 +703,17 @@ 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(); char titleBuf[200]; if (truncateFilenames) - sprintf(titleBuf, "%s.htm", FileNameFromPath(FileRoot)); + sprintf(titleBuf, "%s.htm", wxFileNameFromPath(FileRoot)); else - sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot)); + sprintf(titleBuf, "%s_contents.html", wxFileNameFromPath(FileRoot)); fprintf(Chapters, "<A NAME=\"%s\"></A>", topicName); @@ -707,8 +742,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 +773,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 +805,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 +867,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 +913,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 +948,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 +992,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 +1065,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 +1090,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 +1139,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; } @@ -1906,7 +1947,8 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { if (helpRefText) TraverseChildrenFromChunk(helpRefText); - TexOutput(" (REF NOT FOUND)"); + if (!ignoreBadRefs) + TexOutput(" (REF NOT FOUND)"); wxString errBuf; errBuf.Printf("Warning: unresolved reference '%s'", refName); OnInform((char *)errBuf.c_str()); @@ -1987,7 +2029,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; } } @@ -2093,6 +2135,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) descriptionItemArg = GetArgChunk(); return FALSE; } + return TRUE; } case ltTWOCOLITEM: case ltTWOCOLITEMRULED: @@ -2113,8 +2156,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) { @@ -2126,8 +2170,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; @@ -2629,6 +2674,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (compatibilityMode) { TexOutput("<TR>\n<TD>"); + OutputFont(); /* for (int i = 0; i < noColumns; i++) { @@ -2665,11 +2711,12 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) char titleBuf[150]; if (truncateFilenames) - sprintf(titleBuf, "%s.htm", FileNameFromPath(FileRoot)); + sprintf(titleBuf, "%s.htm", wxFileNameFromPath(FileRoot)); else - sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot)); + sprintf(titleBuf, "%s_contents.html", wxFileNameFromPath(FileRoot)); - TexOutput("<head><title>"); + HTMLHead(); + TexOutput("<title>"); TexOutput(ReferencesNameString); TexOutput("</title></head>\n"); OutputBodyStart(); @@ -2875,7 +2922,7 @@ bool HTMLGo(void) OnError("Cannot open output file!"); return FALSE; } - AddTexRef("contents", FileNameFromPath(TitlepageName), ContentsNameString); + AddTexRef("contents", wxFileNameFromPath(TitlepageName), ContentsNameString); fprintf(Contents, "<P><P><H2>%s</H2><P><P>\n", ContentsNameString); @@ -2908,25 +2955,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; } @@ -2947,17 +2994,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", wxFileNameFromPath(FileRoot)); } // Output frame information @@ -2971,8 +3020,8 @@ bool HTMLGo(void) fprintf(tmpTitle, "<FRAMESET COLS=\"30%%,70%%\">\n"); - fprintf(tmpTitle, "<FRAME SRC=\"%s\">\n", ConvertCase(FileNameFromPath(contentsFrameName))); - fprintf(tmpTitle, "<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n", ConvertCase(FileNameFromPath(firstFileName))); + fprintf(tmpTitle, "<FRAME SRC=\"%s\">\n", ConvertCase(wxFileNameFromPath(contentsFrameName))); + fprintf(tmpTitle, "<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n", ConvertCase(wxFileNameFromPath(firstFileName))); fprintf(tmpTitle, "</FRAMESET>\n"); fprintf(tmpTitle, "<NOFRAMES>\n"); @@ -2994,7 +3043,7 @@ bool HTMLGo(void) fclose(fd); } - fprintf(tmpTitle, "\n</BODY>\n"); + fprintf(tmpTitle, "\n</FONT></BODY>\n"); if (htmlFrameContents) { @@ -3003,7 +3052,7 @@ bool HTMLGo(void) fprintf(tmpTitle, "\n</HTML>\n"); fclose(tmpTitle); - if (FileExists(TitlepageName)) wxRemoveFile(TitlepageName); + if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName); if (!wxRenameFile("title.tmp", TitlepageName)) { wxCopyFile("title.tmp", TitlepageName); @@ -3016,7 +3065,7 @@ bool HTMLGo(void) if (lastTopic) delete[] lastTopic; lastTopic = NULL; - if (FileExists(ContentsName)) wxRemoveFile(ContentsName); + if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName); if (!wxRenameFile(TmpContentsName, ContentsName)) { @@ -3101,11 +3150,11 @@ void GenerateHTMLWorkshopFiles(char *fname) "Default topic=%s\n" "Index file=%s.hhk\n" "Title=", - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(TitlepageName), - FileNameFromPath(fname) + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(TitlepageName), + wxFileNameFromPath(fname) ); if (DocumentTitle) { @@ -3116,19 +3165,19 @@ void GenerateHTMLWorkshopFiles(char *fname) fprintf(f, "\n\n[WINDOWS]\n" "%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,", - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(fname), - FileNameFromPath(TitlepageName)); + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(fname), + wxFileNameFromPath(TitlepageName)); fprintf(f, "\n\n[FILES]\n"); - fprintf(f, "%s\n", FileNameFromPath(TitlepageName)); + fprintf(f, "%s\n", wxFileNameFromPath(TitlepageName)); for (int i = 1; i <= fileId; i++) { if (truncateFilenames) - sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i); + sprintf(buf, "%s%d.htm", wxFileNameFromPath(FileRoot), i); else - sprintf(buf, "%s%d.html", FileNameFromPath(FileRoot), i); + sprintf(buf, "%s%d.html", wxFileNameFromPath(FileRoot), i); fprintf(f, "%s\n", buf); } fclose(f); @@ -3140,8 +3189,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" @@ -3216,8 +3267,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" @@ -3228,7 +3281,7 @@ void HTMLWorkshopStartContents() "<LI> <OBJECT type=\"text/sitemap\">\n" "<param name=\"Local\" value=\"%s\">\n" "<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n", - FileNameFromPath(TitlepageName) + wxFileNameFromPath(TitlepageName) ); }