diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp
index a67bc10be4..654b1d7a14 100644
--- a/utils/tex2rtf/src/htmlutil.cpp
+++ b/utils/tex2rtf/src/htmlutil.cpp
@@ -30,6 +30,12 @@
extern void DecToHex(int, char *);
void GenerateHTMLIndexFile(char *fname);
+
+void GenerateHTMLWorkshopFiles(char *fname);
+void HTMLWorkshopAddToContents(int level, char *s, char *file);
+void HTMLWorkshopStartContents();
+void HTMLWorkshopEndContents();
+
void OutputContentsFrame(void);
#include "readshg.h" // Segmented hypergraphics parsing
@@ -650,6 +656,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
AddTexRef(topicName, ChaptersName, ChapterNameString);
SetCurrentChapterName(topicName, ChaptersName);
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(0, topicName, ChaptersName);
SetCurrentOutput(Chapters);
@@ -719,6 +726,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
AddTexRef(topicName, SectionsName, SectionNameString);
SetCurrentSectionName(topicName, SectionsName);
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(1, topicName, SectionsName);
SetCurrentOutput(Sections);
TexOutput("
");
@@ -811,6 +819,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
ReopenFile(&Subsections, &SubsectionsName);
AddTexRef(topicName, SubsectionsName, SubsectionNameString);
SetCurrentSubsectionName(topicName, SubsectionsName);
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SubsectionsName);
SetCurrentOutput(Subsections);
TexOutput("");
@@ -837,6 +846,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
{
AddTexRef(topicName, SectionsName, SubsectionNameString);
SetCurrentSubsectionName(topicName, SectionsName);
+
// if ( subsectionNo != 0 )
fprintf(Sections, "\n
\n");
@@ -851,6 +861,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
OutputCurrentSection();
TexOutput("
\n");
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName);
SetCurrentOutput(Sections);
}
// Add this section title to the list of keywords
@@ -888,6 +899,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
ReopenFile(&Subsubsections, &SubsubsectionsName);
AddTexRef(topicName, SubsubsectionsName, SubsubsectionNameString);
SetCurrentSubsubsectionName(topicName, SubsubsectionsName);
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(3, topicName, SubsubsectionsName);
SetCurrentOutput(Subsubsections);
TexOutput("");
@@ -926,6 +938,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
OutputCurrentSection();
TexOutput("
");
*/
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName);
SetCurrentOutput(Sections);
}
@@ -1920,6 +1933,23 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
strcat(buf, ".gif");
f = TexPathList.FindValidPath(buf);
}
+
+ if (f == "") // Try for a JPEG instead
+ {
+ strcpy(buf, filename);
+ StripExtension(buf);
+ strcat(buf, ".jpg");
+ f = TexPathList.FindValidPath(buf);
+ }
+
+ if (f == "") // Try for a PNG instead
+ {
+ strcpy(buf, filename);
+ StripExtension(buf);
+ strcat(buf, ".png");
+ f = TexPathList.FindValidPath(buf);
+ }
+
if (f != "")
{
char *inlineFilename = copystring(f);
@@ -2800,6 +2830,7 @@ bool HTMLGo(void)
fprintf(Contents, "\n");
SetCurrentOutput(Titlepage);
+ if (htmlWorkshopFiles) HTMLWorkshopStartContents();
OnInform("Converting...");
TraverseDocument();
@@ -2949,8 +2980,17 @@ bool HTMLGo(void)
GenerateHTMLIndexFile(htmlIndexName);
}
+ // Generate HTML Help Workshop files if requested
+ if (htmlWorkshopFiles)
+ {
+ HTMLWorkshopEndContents();
+ GenerateHTMLWorkshopFiles(FileRoot);
+ }
+
+
return TRUE;
}
+
return FALSE;
}
@@ -2980,3 +3020,152 @@ void GenerateHTMLIndexFile(char *fname)
}
fclose(fd);
}
+
+
+
+
+
+
+
+// output .hpp, .hhc and .hhk files:
+
+
+void GenerateHTMLWorkshopFiles(char *fname)
+{
+ FILE *f;
+ char buf[300];
+
+ /* Generate project file : */
+
+ sprintf(buf, "%s.hhp", fname);
+ f = fopen(buf, "wt");
+ fprintf(f,
+ "[OPTIONS]\n"
+ "Compatibility=1.1 or later\n"
+ "Contents file=%s.hhc\n"
+ "Default topic=%s\n"
+ "Index file=%s.hhk\n"
+ "Title=",
+ FileNameFromPath(fname),
+ FileNameFromPath(TitlepageName),
+ FileNameFromPath(fname)
+ );
+
+ if (DocumentTitle) {
+ SetCurrentOutput(f);
+ TraverseChildrenFromChunk(DocumentTitle);
+ }
+ else fprintf(f, "(unknown)");
+
+ fprintf(f, "\n\n[FILES]\n");
+ fprintf(f, "%s\n", FileNameFromPath(TitlepageName));
+ for (int i = 1; i <= fileId; i++) {
+ if (truncateFilenames)
+ sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i);
+ else
+ sprintf(buf, "%s%d.html", FileNameFromPath(FileRoot), i);
+ fprintf(f, "%s\n", buf);
+ }
+ fclose(f);
+
+ /* Generate index file : */
+
+ sprintf(buf, "%s.hhk", fname);
+ f = fopen(buf, "wt");
+
+ fprintf(f,
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n");
+
+ TopicTable.BeginFind();
+ wxNode *node = NULL;
+ while ((node = TopicTable.Next()))
+ {
+ TexTopic *texTopic = (TexTopic *)node->Data();
+ const char *topicName = node->GetKeyString();
+ if (texTopic->filename && texTopic->keywords)
+ {
+ wxNode *node1 = texTopic->keywords->First();
+ while (node1)
+ {
+ char *s = (char *)node1->Data();
+ fprintf(f,
+ " - \n",
+ texTopic->filename, topicName, s);
+ node1 = node1->Next();
+ }
+ }
+ }
+
+ fprintf(f, "
\n");
+ fclose(f);
+}
+
+
+
+static FILE *HTMLWorkshopContents = NULL;
+static int HTMLWorkshopLastLevel = 0;
+
+void HTMLWorkshopAddToContents(int level, char *s, char *file)
+{
+ int i;
+
+ if (level > HTMLWorkshopLastLevel)
+ for (i = HTMLWorkshopLastLevel; i < level; i++)
+ fprintf(HTMLWorkshopContents, "");
+ if (level < HTMLWorkshopLastLevel)
+ for (i = level; i < HTMLWorkshopLastLevel; i++)
+ fprintf(HTMLWorkshopContents, "
");
+
+ SetCurrentOutput(HTMLWorkshopContents);
+ fprintf(HTMLWorkshopContents,
+ " - \n");
+ HTMLWorkshopLastLevel = level;
+}
+
+
+void HTMLWorkshopStartContents()
+{
+ char buf[300];
+ sprintf(buf, "%s.hhc", FileRoot);
+ HTMLWorkshopContents = fopen(buf, "wt");
+ HTMLWorkshopLastLevel = 0;
+
+ fprintf(HTMLWorkshopContents,
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "
\n");
+}
+
+
+void HTMLWorkshopEndContents()
+{
+ for (int i = HTMLWorkshopLastLevel; i >= 0; i--)
+ fprintf(HTMLWorkshopContents, "
\n");
+ fclose(HTMLWorkshopContents);
+}
diff --git a/utils/tex2rtf/src/tex2any.cpp b/utils/tex2rtf/src/tex2any.cpp
index 6bdc76b38f..cefb10037e 100644
--- a/utils/tex2rtf/src/tex2any.cpp
+++ b/utils/tex2rtf/src/tex2any.cpp
@@ -121,6 +121,7 @@ char *textColourString = NULL;
char *linkColourString = NULL;
char *followedLinkColourString = NULL;
bool combineSubSections = FALSE;
+bool htmlWorkshopFiles = FALSE;
/*
* International support
diff --git a/utils/tex2rtf/src/tex2any.h b/utils/tex2rtf/src/tex2any.h
index db5b1914de..37d25fb7b8 100644
--- a/utils/tex2rtf/src/tex2any.h
+++ b/utils/tex2rtf/src/tex2any.h
@@ -238,6 +238,7 @@ extern char *textColourString; // HTML text colour
extern char *linkColourString; // HTML link colour
extern char *followedLinkColourString; // HTML followed link colour
extern bool combineSubSections; // Stop splitting files below section
+extern bool htmlWorkshopFiles; // generate HTML Help Workshop project files
// Names to help with internationalisation
extern char *ContentsNameString;
diff --git a/utils/tex2rtf/src/texutils.cpp b/utils/tex2rtf/src/texutils.cpp
index 2b61ddfc76..5746339422 100644
--- a/utils/tex2rtf/src/texutils.cpp
+++ b/utils/tex2rtf/src/texutils.cpp
@@ -1166,6 +1166,8 @@ char *RegisterSetting(char *settingName, char *settingValue, bool interactive)
winHelpContents = StringTobool(settingValue);
else if (StringMatch(settingName, "htmlIndex", FALSE, TRUE))
htmlIndex = StringTobool(settingValue);
+ else if (StringMatch(settingName, "htmlWorkshopFiles", FALSE, TRUE))
+ htmlWorkshopFiles = StringTobool(settingValue);
else if (StringMatch(settingName, "htmlFrameContents", FALSE, TRUE))
htmlFrameContents = StringTobool(settingValue);
else if (StringMatch(settingName, "upperCaseNames", FALSE, TRUE))