📄 htmlutil.cpp
字号:
}
return false;
}
break;
}
case ltURLREF:
{
if (IsArgOptional())
return false;
else if ((GetNoArgs() - arg_no) == 1)
{
if (start)
helpRefText = GetArgChunk();
return false;
}
else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional
{
if (start)
{
TexChunk *ref = GetArgChunk();
TexOutput(_T("<A HREF=\""));
inVerbatim = true;
TraverseChildrenFromChunk(ref);
inVerbatim = false;
TexOutput(_T("\">"));
if (helpRefText)
TraverseChildrenFromChunk(helpRefText);
TexOutput(_T("</A>"));
}
return false;
}
break;
}
case ltHELPREF:
case ltHELPREFN:
case ltPOPREF:
{
if (IsArgOptional())
{
if (start)
helpRefFilename = GetArgChunk();
return false;
}
if ((GetNoArgs() - arg_no) == 1)
{
if (start)
helpRefText = GetArgChunk();
return false;
}
else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional
{
if (start)
{
wxChar *refName = GetArgData();
wxChar *refFilename = NULL;
if (refName)
{
TexRef *texRef = FindReference(refName);
if (texRef)
{
if (texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0)
refFilename = texRef->refFile;
TexOutput(_T("<A HREF=\""));
// If a filename is supplied, use it, otherwise try to
// use the filename associated with the reference (from this document).
if (helpRefFilename)
{
TraverseChildrenFromChunk(helpRefFilename);
TexOutput(_T("#"));
TexOutput(refName);
}
else if (refFilename)
{
TexOutput(ConvertCase(refFilename));
if(!PrimaryAnchorOfTheFile(texRef->refFile, refName))
{
TexOutput(_T("#"));
TexOutput(refName);
}
}
TexOutput(_T("\">"));
if (helpRefText)
TraverseChildrenFromChunk(helpRefText);
TexOutput(_T("</A>"));
}
else
{
if (helpRefText)
TraverseChildrenFromChunk(helpRefText);
if (!ignoreBadRefs)
TexOutput(_T(" (REF NOT FOUND)"));
// for launching twice do not warn in preparation pass
if ((passNumber == 1 && !runTwice) ||
(passNumber == 2 && runTwice))
{
wxString errBuf;
errBuf.Printf(_T("Warning: unresolved reference '%s'"), refName);
OnInform((wxChar *)errBuf.c_str());
}
}
}
else TexOutput(_T("??"));
}
return false;
}
break;
}
case ltIMAGE:
case ltIMAGEL:
case ltIMAGER:
case ltPSBOXTO:
{
if (arg_no == 2)
{
if (start)
{
wxChar *alignment = _T("");
if (macroId == ltIMAGEL)
alignment = _T(" align=left");
else if (macroId == ltIMAGER)
alignment = _T(" align=right");
// Try to find an XBM or GIF image first.
wxChar *filename = copystring(GetArgData());
wxChar buf[500];
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".xbm"));
wxString f = TexPathList.FindValidPath(buf);
if (f == _T("")) // Try for a GIF instead
{
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".gif"));
f = TexPathList.FindValidPath(buf);
}
if (f == _T("")) // Try for a JPEG instead
{
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".jpg"));
f = TexPathList.FindValidPath(buf);
}
if (f == _T("")) // Try for a PNG instead
{
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".png"));
f = TexPathList.FindValidPath(buf);
}
if (f != _T(""))
{
wxChar *inlineFilename = copystring(f);
#if 0
wxChar *originalFilename = TexPathList.FindValidPath(filename);
// If we have found the existing filename, make the inline
// image point to the original file (could be PS, for example)
if (originalFilename && (wxStrcmp(inlineFilename, originalFilename) != 0))
{
TexOutput(_T("<A HREF=\""));
TexOutput(ConvertCase(originalFilename));
TexOutput(_T("\">"));
TexOutput(_T("<img src=\""));
TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename)));
TexOutput(_T("\""));
TexOutput(alignment);
TexOutput(_T("></A>"));
}
else
#endif
{
TexOutput(_T("<img src=\""));
TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename)));
TexOutput(_T("\""));
TexOutput(alignment);
TexOutput(_T(">"));
delete[] inlineFilename;
}
}
else
{
// Last resort - a link to a PS file.
TexOutput(_T("<A HREF=\""));
TexOutput(ConvertCase(wxFileNameFromPath(filename)));
TexOutput(_T("\">Picture</A>\n"));
wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename);
OnInform(buf);
}
}
}
return false;
}
// First arg is PSBOX spec (ignored), second is image file, third is map name.
case ltIMAGEMAP:
{
static wxChar *imageFile = NULL;
if (start && (arg_no == 2))
{
// Try to find an XBM or GIF image first.
wxChar *filename = copystring(GetArgData());
wxChar buf[500];
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".xbm"));
wxString f = TexPathList.FindValidPath(buf);
if (f == _T("")) // Try for a GIF instead
{
wxStrcpy(buf, filename);
StripExtension(buf);
wxStrcat(buf, _T(".gif"));
f = TexPathList.FindValidPath(buf);
}
if (f == _T(""))
{
wxChar buf[300];
wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename);
OnInform(buf);
}
delete[] filename;
if (imageFile)
delete[] imageFile;
imageFile = NULL;
if (!f.empty())
{
imageFile = copystring(f);
}
}
else if (start && (arg_no == 3))
{
if (imageFile)
{
// First, try to find a .shg (segmented hypergraphics file)
// that we can convert to a map file
wxChar buf[256];
wxStrcpy(buf, imageFile);
StripExtension(buf);
wxStrcat(buf, _T(".shg"));
wxString f = TexPathList.FindValidPath(buf);
if (f != _T(""))
{
// The default HTML file to go to is THIS file (so a no-op)
SHGToMap((wxChar *)f.c_str(), currentFileName);
}
wxChar *mapName = GetArgData();
TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
if (mapName)
TexOutput(mapName);
else
TexOutput(_T("unknown"));
TexOutput(_T("\">"));
TexOutput(_T("<img src=\""));
TexOutput(ConvertCase(wxFileNameFromPath(imageFile)));
TexOutput(_T("\" ISMAP></A><P>"));
delete[] imageFile;
imageFile = NULL;
}
}
return false;
}
case ltINDENTED :
{
if ( arg_no == 1 )
return false;
else
{
return true;
}
}
case ltITEM:
{
if (start)
{
descriptionItemArg = GetArgChunk();
return false;
}
return true;
}
case ltTWOCOLITEM:
case ltTWOCOLITEMRULED:
{
/*
if (start && (arg_no == 1))
TexOutput(_T("\n<DT> "));
if (start && (arg_no == 2))
TexOutput(_T("<DD> "));
*/
if (arg_no == 1)
{
if ( start ) {
// DHS
if (TwoColWidthA > -1)
{
wxChar buf[100];
wxSnprintf(buf, sizeof(buf), _T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA);
TexOutput(buf);
}
else
{
TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
}
OutputFont();
} else
TexOutput(_T("\n</FONT></TD>\n"));
}
if (arg_no == 2)
{
// DHS
if ( start )
{
if (TwoColWidthB > -1)
{
wxChar buf[100];
wxSnprintf(buf, sizeof(buf), _T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB);
TexOutput(buf);
}
else
{
TexOutput(_T("\n<TD VALIGN=TOP>\n"));
}
OutputFont();
} else
TexOutput(_T("\n</FONT></TD></TR>\n"));
}
return true;
}
case ltNUMBEREDBIBITEM:
{
if (arg_no == 1 && start)
{
TexOutput(_T("\n<DT> "));
}
if (arg_no == 2 && !start)
TexOutput(_T("<P>\n"));
break;
}
case ltBIBITEM:
{
wxChar buf[100];
if (arg_no == 1 && start)
{
wxChar *citeKey = GetArgData();
TexRef *ref = (TexRef *)TexReferences.Get(citeKey);
if (ref)
{
if (ref->sectionNumber) delete[] ref->sectionNumber;
wxSnprintf(buf, sizeof(buf), _T("[%d]"), citeCount);
ref->sectionNumber = copystring(buf);
}
wxSnprintf(buf, sizeof(buf), _T("\n<DT> [%d] "), citeCount);
TexOutput(buf);
citeCount ++;
return false;
}
if (arg_no == 2 && !start)
TexOutput(_T("<P>\n"));
return true;
}
case ltMARGINPAR:
case ltMARGINPARODD:
case ltMARGINPAREVEN:
case ltNORMALBOX:
case ltNORMALBOXD:
{
if (start)
{
TexOutput(_T("<HR>\n"));
return true;
}
else
TexOutput(_T("<HR><P>\n"));
break;
}
// DHS
case ltTWOCOLWIDTHA:
{
if (start)
{
wxChar *val = GetArgData();
float points = ParseUnitArgument(val);
TwoColWidthA = (int)((points * 100.0) / 72.0);
}
return false;
}
// DHS
case ltTWOCOLWIDTHB:
{
if (start)
{
wxChar *val = GetArgData();
float points = ParseUnitArgument(val);
TwoColWidthB = (int)((points * 100.0) / 72.0);
}
return false;
}
/*
* Accents
*
*/
case ltACCENT_GRAVE:
{
if (start)
{
wxChar *val = GetArgData();
if (val)
{
switch (val[0])
{
case 'a':
TexOutput(_T("à"));
break;
case 'e':
TexOutput(_T("è"));
break;
case 'i':
TexOutput(_T("ì"));
break;
case 'o':
TexOutput(_T("ò"));
break;
case 'u':
TexOutput(_T("ù"));
break;
case 'A':
TexOutput(_T("À"));
break;
case 'E':
TexOutput(_T("È"));
break;
case 'I':
TexOutput(_T("Ì"));
break;
case 'O':
TexOutput(_T("Ò"));
break;
case 'U':
TexOutput(_T("Ì"));
break;
default:
break;
}
}
}
return false;
}
case ltACCENT_ACUTE:
{
if (start)
{
wxChar *val = GetArgData();
if (val)
{
switch (val[0])
{
case 'a':
TexOutput(_T("á"));
break;
case 'e':
TexOutput(_T("é"));
break;
case 'i':
TexOutput(_T("í"));
break;
case 'o':
TexOutput(_T("ó"));
break;
case 'u':
TexOutput(_T("ú"));
break;
case 'y':
TexOutput(_T("ý"));
break;
case 'A':
TexOutput(_T("Á"));
break;
case 'E':
TexOutput(_T("É"));
break;
case 'I':
TexOutput(_T("Í"));
break;
case 'O':
TexOutput(_T("Ó"));
break;
case 'U':
TexOutput(_T("&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -