#include "tex2rtf.h"
#include "table.h"
+
+extern wxHashTable TexReferences;
+
+
extern void DecToHex(int, char *);
void GenerateHTMLIndexFile(char *fname);
// This is defined in the Tex2Any library.
extern char *BigBuffer;
+// DHS Two-column table dimensions.
+static int TwoColWidthA = -1;
+static int TwoColWidthB = -1;
+
+
class HyperReference: public wxObject
{
public:
CurrentChapterFile = copystring(file);
currentFileName = CurrentChapterFile;
-
+
SetCurrentTopic(s);
}
void SetCurrentSectionName(char *s, char *file)
{
if (*fd)
{
- fprintf(*fd, "\n</BODY></HTML>\n");
+ fprintf(*fd, "\n</FONT></BODY></HTML>\n");
fclose(*fd);
}
fileId ++;
* converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
*
*/
-
+
void ProcessText2HTML(TexChunk *chunk)
{
bool changed = FALSE;
* and before TraverseDocument is called.
*
*/
-
+
void Text2HTML(TexChunk *chunk)
{
Tex2RTFYield();
contentsReference = contentsReferenceBuf;
sprintf(contentsReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">", ConvertCase("contents.gif"));
}
-
+
char *upReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
upReference = UpNameString;
upReference = upReferenceBuf;
sprintf(upReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">", ConvertCase("up.gif"));
}
-
+
char *backReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
backReference = "<<";
backReference = backReferenceBuf;
sprintf(backReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">", ConvertCase("back.gif"));
}
-
+
char *forwardReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
forwardReference = ">>";
forwardReference = forwardReferenceBuf;
sprintf(forwardReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">", ConvertCase("forward.gif"));
}
-
+
TexOutput("<CENTER>");
-
+
char buf[200];
/*
int red = atoi(tok1);
int green = atoi(tok2);
int blue = atoi(tok3);
-
+
strcpy(resStr, "#");
-
+
char buf[3];
DecToHex(red, buf);
strcat(resStr, buf);
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)
{
TexOutput(" BGCOLOR="); TexOutput(s);
}
}
-
+
// Set foreground text colour, if one is specified
if (textColourString)
{
}
}
TexOutput(">\n");
+
+ OutputFont();
}
// Called on start/end of macro examination
sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot));
fprintf(Chapters, "<A NAME=\"%s\"></A>", topicName);
-
+
AddBrowseButtons("", titleBuf, // Up
lastTopic, lastFileName, // Last topic
topicName, ChaptersName); // This topic
if (macroId != ltSECTIONSTAR)
sectionNo ++;
-
+
SetCurrentOutput(NULL);
startedSections = TRUE;
OutputCurrentSection();
TexOutput("</A><BR>");
*/
- if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName);
+ if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName);
SetCurrentOutput(Sections);
}
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)
currentColumn ++;
{
// Convert from points * 20 into pixels.
int points = TableData[currentColumn].width / 20;
-
+
// Say the display is 100 DPI (dots/pixels per inch).
// There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
int pixels = (int)(points * 100.0 / 72.0);
else
sprintf(buf, "\n<TD ALIGN=LEFT>");
TexOutput(buf);
+ OutputFont();
}
else
TexOutput("&");
if (start)
{
currentColumn = 0;
-
+
// Start new row and cell, setting alignment for the first cell.
char buf[100];
if (TableData[currentColumn].justification == 'c')
{
// Convert from points * 20 into pixels.
int points = TableData[currentColumn].width / 20;
-
+
// Say the display is 100 DPI (dots/pixels per inch).
// There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
int pixels = (int)(points * 100.0 / 72.0);
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;
}
{
if ( start )
TexOutput("\n<TABLE>\n");
- else
+ else {
TexOutput("\n</TABLE>\n");
+ // DHS
+ TwoColWidthA = -1;
+ TwoColWidthB = -1;
+ }
break;
}
case ltPAR:
if (htmlFrameContents && FrameContents)
{
SetCurrentOutput(FrameContents);
-
+
// Add a special label for the contents page.
TexOutput("<CENTER>\n");
TexOutput("<H3>\n");
}
TexOutput("\n</CENTER>\n");
TexOutput("<P><HR><P>\n");
-
+
SetCurrentOutput(Titlepage);
}
*/
{
if (!suppressNameDecoration) TexOutput("</B>");
}
-
+
if (start && (arg_no == 3))
TexOutput("(");
if (!start && (arg_no == 3))
if (start)
{
char *sec = NULL;
-
+
char *refName = GetArgData();
if (refName)
{
{
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());
}
}
else TexOutput("??");
alignment = " align=left";
else if (macroId == ltIMAGER)
alignment = " align=right";
-
+
// Try to find an XBM or GIF image first.
char *filename = copystring(GetArgData());
char buf[500];
-
+
strcpy(buf, filename);
StripExtension(buf);
strcat(buf, ".xbm");
// Try to find an XBM or GIF image first.
char *filename = copystring(GetArgData());
char buf[500];
-
+
strcpy(buf, filename);
StripExtension(buf);
strcat(buf, ".xbm");
if (imageFile)
delete[] imageFile;
imageFile = NULL;
- if (f)
+ if (!f.IsEmpty())
{
imageFile = copystring(f);
}
descriptionItemArg = GetArgChunk();
return FALSE;
}
+ return TRUE;
}
case ltTWOCOLITEM:
case ltTWOCOLITEMRULED:
*/
if (arg_no == 1)
{
- if ( start )
- TexOutput("\n<TR><TD VALIGN=TOP>\n");
- else
- TexOutput("\n</TD>\n");
+ if ( start ) {
+ // DHS
+ if (TwoColWidthA > -1) {
+ char buf[100];
+ sprintf(buf,"\n<TR><TD VALIGN=TOP WIDTH=%d>\n",TwoColWidthA);
+ TexOutput(buf);
+ } else
+ TexOutput("\n<TR><TD VALIGN=TOP>\n");
+ OutputFont();
+ } else
+ TexOutput("\n</FONT></TD>\n");
}
if (arg_no == 2)
{
- if ( start )
- TexOutput("\n<TD VALIGN=TOP>\n");
- else
- TexOutput("\n</TD></TR>\n");
+ // DHS
+ if ( start ) {
+ if (TwoColWidthB > -1) {
+ char buf[100];
+ sprintf(buf,"\n<TD VALIGN=TOP WIDTH=%d>\n",TwoColWidthB);
+ TexOutput(buf);
+ } else
+ TexOutput("\n<TD VALIGN=TOP>\n");
+ OutputFont();
+ } else
+ TexOutput("\n</FONT></TD></TR>\n");
}
return TRUE;
break;
TexOutput("<HR><P>\n");
break;
}
+ // DHS
+ case ltTWOCOLWIDTHA:
+ {
+ if (start)
+ {
+ char *val = GetArgData();
+ float points = ParseUnitArgument(val);
+ TwoColWidthA = (int)((points * 100.0) / 72.0);
+ }
+ return FALSE;
+ break;
+ }
+ // DHS
+ case ltTWOCOLWIDTHB:
+ {
+ if (start)
+ {
+ char *val = GetArgData();
+ float points = ParseUnitArgument(val);
+ TwoColWidthB = (int)((points * 100.0) / 72.0);
+ }
+ return FALSE;
+ break;
+ }
/*
* Accents
*
return FALSE;
break;
}
-*/
+*/
case ltTABULAR:
case ltSUPERTABULAR:
{
if (compatibilityMode)
{
TexOutput("<TR>\n<TD>");
+ OutputFont();
/*
for (int i = 0; i < noColumns; i++)
{
if (TitlepageName) delete[] TitlepageName;
TitlepageName = copystring(buf);
Titlepage = fopen(buf, "w");
-
+
if (truncateFilenames)
sprintf(buf, "%s_fc.htm", FileRoot);
else
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;
}
else
fprintf(tmpTitle, "<HEAD><TITLE>%s</TITLE></HEAD>\n\n", FileNameFromPath(FileRoot));
}
-
+
// Output frame information
if (htmlFrameContents)
{
fprintf(tmpTitle, "<FRAME SRC=\"%s\">\n", ConvertCase(FileNameFromPath(contentsFrameName)));
fprintf(tmpTitle, "<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n", ConvertCase(FileNameFromPath(firstFileName)));
fprintf(tmpTitle, "</FRAMESET>\n");
-
+
fprintf(tmpTitle, "<NOFRAMES>\n");
}
// Output <BODY...> to temporary title page
OutputBodyStart();
-
+
// Concat titlepage
FILE *fd = fopen(TitlepageName, "r");
if (fd)
fclose(fd);
}
- fprintf(tmpTitle, "\n</BODY>\n");
+ fprintf(tmpTitle, "\n</FONT></BODY>\n");
if (htmlFrameContents)
{
sprintf(buf, "%s.hhp", fname);
f = fopen(buf, "wt");
- fprintf(f,
+ fprintf(f,
"[OPTIONS]\n"
- "Compatibility=1.1 or later\n"
+ "Compatibility=1.1\n"
+ "Full-text search=Yes\n"
"Contents file=%s.hhc\n"
+ "Compiled file=%s.chm\n"
+ "Default Window=%sHelp\n"
"Default topic=%s\n"
"Index file=%s.hhk\n"
"Title=",
FileNameFromPath(fname),
+ FileNameFromPath(fname),
+ FileNameFromPath(fname),
FileNameFromPath(TitlepageName),
FileNameFromPath(fname)
);
-
+
if (DocumentTitle) {
SetCurrentOutput(f);
TraverseChildrenFromChunk(DocumentTitle);
}
else fprintf(f, "(unknown)");
-
+
+ fprintf(f, "\n\n[WINDOWS]\n"
+ "%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,",
+ FileNameFromPath(fname),
+ FileNameFromPath(fname),
+ FileNameFromPath(fname),
+ FileNameFromPath(TitlepageName));
+
+
fprintf(f, "\n\n[FILES]\n");
fprintf(f, "%s\n", FileNameFromPath(TitlepageName));
- for (int i = 1; i <= fileId; i++) {
+ for (int i = 1; i <= fileId; i++) {
if (truncateFilenames)
sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i);
else
while (node1)
{
char *s = (char *)node1->Data();
- fprintf(f,
+ fprintf(f,
" <LI> <OBJECT type=\"text/sitemap\">\n"
" <param name=\"Local\" value=\"%s#%s\">\n"
" <param name=\"Name\" value=\"%s\">\n"
}
}
}
-
+
fprintf(f, "</UL>\n");
fclose(f);
}
if (level > HTMLWorkshopLastLevel)
for (i = HTMLWorkshopLastLevel; i < level; i++)
- fprintf(HTMLWorkshopContents, "<UL>");
+ fprintf(HTMLWorkshopContents, "<UL>");
if (level < HTMLWorkshopLastLevel)
for (i = level; i < HTMLWorkshopLastLevel; i++)
- fprintf(HTMLWorkshopContents, "</UL>");
-
+ fprintf(HTMLWorkshopContents, "</UL>");
+
SetCurrentOutput(HTMLWorkshopContents);
- fprintf(HTMLWorkshopContents,
+ fprintf(HTMLWorkshopContents,
" <LI> <OBJECT type=\"text/sitemap\">\n"
" <param name=\"Local\" value=\"%s#%s\">\n"
" <param name=\"Name\" value=\"",
file, s);
OutputCurrentSection();
- fprintf(HTMLWorkshopContents,
+ fprintf(HTMLWorkshopContents,
"\">\n"
" </OBJECT>\n");
HTMLWorkshopLastLevel = level;
{
char buf[300];
sprintf(buf, "%s.hhc", FileRoot);
- HTMLWorkshopContents = fopen(buf, "wt");
+ HTMLWorkshopContents = fopen(buf, "wt");
HTMLWorkshopLastLevel = 0;
- fprintf(HTMLWorkshopContents,
+ fprintf(HTMLWorkshopContents,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
"<HTML>\n"
"<HEAD>\n"
"<OBJECT type=\"text/site properties\">\n"
" <param name=\"ImageType\" value=\"Folder\">\n"
"</OBJECT>\n"
- "<UL>\n");
+ "<UL>\n"
+ "<LI> <OBJECT type=\"text/sitemap\">\n"
+ "<param name=\"Local\" value=\"%s\">\n"
+ "<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n",
+ FileNameFromPath(TitlepageName)
+ );
+
}