// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace)
{
TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace)
{
- // First, try to find begin{thing}
- if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0)
- {
- i += 6;
-
- int j = i;
- while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))
+ // First, try to find begin{thing}
+ if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0)
- if (def)
- {
- *pos = j + 1; // BUGBUG Should this be + 1???
- *env = def->name;
- ForbidWarning(def);
- return def;
+ int j = i;
+ while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))
+ {
+ macroBuf[j-i] = buffer[j];
+ j ++;
+ }
+ macroBuf[j-i] = 0;
+ def = (TexMacroDef *)MacroDefs.Get(macroBuf);
+
+ if (def)
+ {
+ *pos = j + 1; // BUGBUG Should this be + 1???
+ *env = def->name;
+ ForbidWarning(def);
+ return def;
+ }
+ else
+ {
+ return NULL;
+ }
- // First try getting a one-character macro, but ONLY
- // if these TWO characters are not both alphabetical (could
- // be a longer macro)
- if (!(isalpha(buffer[i]) && isalpha(buffer[i+1])))
- {
- macroBuf[0] = buffer[i];
- macroBuf[1] = 0;
+ // First try getting a one-character macro, but ONLY
+ // if these TWO characters are not both alphabetical (could
+ // be a longer macro)
+ if (!(isalpha(buffer[i]) && isalpha(buffer[i+1])))
+ {
+ macroBuf[0] = buffer[i];
+ macroBuf[1] = 0;
- if (def)
- {
- i = j;
-
- // We want to check whether this is a space-consuming macro
- // (e.g. {\bf word})
- // No brace, e.g. \input thing.tex instead of \input{thing};
- // or a numeric argument, such as \parindent0pt
- if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i]))))
+ // We want to check whether this is a space-consuming macro
+ // (e.g. {\bf word})
+ // No brace, e.g. \input thing.tex instead of \input{thing};
+ // or a numeric argument, such as \parindent0pt
+ if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i]))))
+ {
+ if ((buffer[i] == 32) || (buffer[i] == '='))
+ i ++;
+
+ *parseToBrace = false;
+ }
+ *pos = i;
+ ForbidWarning(def);
+ return def;
{
wxChar buf2[400];
wxSnprintf(buf2, sizeof(buf2), _T("%s.tex"), fileNameStr.c_str());
{
wxChar buf2[400];
wxSnprintf(buf2, sizeof(buf2), _T("%s.tex"), fileNameStr.c_str());
- pos = ParseMacroBody(def->name, chunk, chunk->no_args,
- buffer, pos, env, tmpParseToBrace, customMacroArgs);
+ pos = ParseMacroBody(def->name,
+ chunk, chunk->no_args,
+ buffer,
+ pos,
+ env,
+ tmpParseToBrace,
+ customMacroArgs);
- static wxChar *line_buffer;
- stopRunning = false;
- wxStrcpy(TexFileRoot, filename);
- StripExtension(TexFileRoot);
- wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
- wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
+ static wxChar *line_buffer;
+ stopRunning = false;
+ wxStrcpy(TexFileRoot, filename);
+ StripExtension(TexFileRoot);
+ wxSnprintf(TexBibName, 300, _T("%s.bb"), TexFileRoot);
+ wxSnprintf(TexTmpBibName, 300, _T("%s.bb1"), TexFileRoot);
- Inputs[0] = wxFopen(filename, _T("r"));
- LineNumbers[0] = 1;
- FileNames[0] = copystring(filename);
- if (Inputs[0])
- {
- read_a_line(line_buffer);
- ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
- if (Inputs[0]) fclose(Inputs[0]);
- return true;
- }
+ Inputs[0] = wxFopen(filename, _T("r"));
+ LineNumbers[0] = 1;
+ FileNames[0] = copystring(filename);
+ if (Inputs[0])
+ {
+ read_a_line(line_buffer);
+ ParseMacroBody(_T("toplevel"), TopLevel, 1, line_buffer, 0, NULL, true);
+ if (Inputs[0]) fclose(Inputs[0]);
+ return true;
+ }
}
TexMacroDef::TexMacroDef(int the_id, const wxChar *the_name, int n, bool ig, bool forbidLevel)
}
TexMacroDef::TexMacroDef(int the_id, const wxChar *the_name, int n, bool ig, bool forbidLevel)
- TexOutput(_T("<<"), true);
+ {
+ if (convertMode == TEX_HTML)
+ TexOutput(_T("<<"));
+ else
+ TexOutput(_T("<<"), true);
+ }
- TexOutput(_T(">>"), true);
+ {
+ if (convertMode == TEX_HTML)
+ TexOutput(_T(">>"));
+ else
+ TexOutput(_T(">>"), true);
+ }
wxChar fileBuf[300];
wxStrcpy(fileBuf, bibFile);
wxString actualFile = TexPathList.FindValidPath(fileBuf);
wxChar fileBuf[300];
wxStrcpy(fileBuf, bibFile);
wxString actualFile = TexPathList.FindValidPath(fileBuf);
{
wxStrcat(fileBuf, _T(".bib"));
actualFile = TexPathList.FindValidPath(fileBuf);
}
{
wxStrcat(fileBuf, _T(".bib"));
actualFile = TexPathList.FindValidPath(fileBuf);
}