Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions Common/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ var capableRenderers = 8;
* @public
*/
var capableDerenderers = 13;
/**
* REASON: sciweavers.org retired tex2img.php, the GET image endpoint every Sciweavers
* renderer entry below is built on. Verified 2026-09-18: the site itself is up and its
* editor at /free-online-latex-equation-editor still renders, but tex2img.php returns the
* site's own 404 page for every shape of request - http and https, www and apex, both
* parameter orders, and every user agent tried (curl, Chrome, Googlebot). Even the embed
* URL sciweavers' own editor hands out after a successful render is a tex2img.php link
* that 404s. Its working path is now a POST to /process_form_tex2img that returns a
* one-off /upload/Tex2Img_<id>/render.png; the id changes on every submit and does not
* carry the LaTeX, so it cannot satisfy our contract that an equation's image URL is
* stable and de-renderable back into source.
*
* These families are therefore skipped when RENDERING (see getRendererOrder), which drops
* three guaranteed-failing renderer attempts - two fetches each - from every equation that
* gets past Codecogs and Texrendr. They are deliberately still reachable through
* getRenderer/capableDerenderers so equations rendered before the shutdown keep
* de-rendering. What breaks if this list is emptied: Auto gets slower on every fallback
* and any explicit Sciweavers choice fails 100% of the time.
* @public
*/
var retiredRendererFamilies = ["Sciweavers", "Sciweavers_old"];
/**
* @public
*/
function isRetiredRendererFamily(family) {
return retiredRendererFamilies.indexOf(family) > -1;
}
/**
* Renderer ID constants for retreiving info about specific renderers
* @public
Expand All @@ -49,6 +76,9 @@ var invalidEquationHashTexrendrFirst50 = "GIF89a%uFFFD%008%00%uFFFD%00%00%uFFFD%
var invalidEquationHashTexrendrFirst50_2 = "GIF89a%01%00%01%00%uFFFD%00%00%uFFFD%uFFFD%uFFFD%0";
var invalidEquationHashTexrendrFirst50_3 = "GIF89ai%0A%uFFFD%01%uFFFD%00%00%uFFFD%uFFFD%uFFFD%"; // this is the No Expression Supplied error. Ignored for now.
var invalidEquationHashTexrendrFirst50_4 = "%7FELF%01%01%01%00%00%00%00%00%00%00%00%00%02%00%0";
// NOTE: this prefix is an HTML document where an image was expected. It originally caught
// Sciweavers answering an amsmath equation with its editor page, and it also matches the
// 404 page tex2img.php now serves unconditionally (see retiredRendererFamilies).
var invalidEquationHashSciweaversFirst50 = "%0D%0A%09%3C%21DOCTYPE%20html%20PUBLIC%20%22-//W3C";
var defaultRendererPreference = "auto";
var activeRendererPreference = null;
Expand All @@ -61,7 +91,11 @@ function normalizeRendererPreference(renderer) {
case "texrendr":
return "texrendr";
case "sciweavers":
return "sciweavers";
// REASON: users who picked Sciweavers before it shut down still have it in their saved
// properties, and the option is gone from the sidebars. Migrate the stored value to
// Automatic here so those users render instead of failing on every equation; savePrefs
// writes the normalized value back, so the dead preference does not survive a render.
return defaultRendererPreference;
default:
return defaultRendererPreference;
}
Expand All @@ -72,9 +106,9 @@ function getPreferredRendererFamily(rendererPreference) {
return "Codecogs";
case "texrendr":
return "Texrendr";
case "sciweavers":
return "Sciweavers";
default:
// NOTE: no "sciweavers" case - normalizeRendererPreference maps it to Automatic, so a
// retired family can never become the preferred family that getRendererOrder promotes.
return "";
}
}
Expand Down Expand Up @@ -120,6 +154,10 @@ function getRendererOrder() {
var prioritizedOrder = [];
var fallbackOrder = [];
for (var worked = 1; worked <= capableRenderers; ++worked) {
// REASON: retired services are still listed in getRenderer so old equations de-render,
// but attempting them here only costs two doomed fetches and a sleep per equation.
if (isRetiredRendererFamily(getRenderer(worked)[5]))
continue;
defaultOrder.push(worked);
}
if (!preferredFamily) {
Expand Down
45 changes: 42 additions & 3 deletions Common/Code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,35 @@ const capableRenderers = 8;
*/
const capableDerenderers = 13;

/**
* REASON: sciweavers.org retired tex2img.php, the GET image endpoint every Sciweavers
* renderer entry below is built on. Verified 2026-09-18: the site itself is up and its
* editor at /free-online-latex-equation-editor still renders, but tex2img.php returns the
* site's own 404 page for every shape of request - http and https, www and apex, both
* parameter orders, and every user agent tried (curl, Chrome, Googlebot). Even the embed
* URL sciweavers' own editor hands out after a successful render is a tex2img.php link
* that 404s. Its working path is now a POST to /process_form_tex2img that returns a
* one-off /upload/Tex2Img_<id>/render.png; the id changes on every submit and does not
* carry the LaTeX, so it cannot satisfy our contract that an equation's image URL is
* stable and de-renderable back into source.
*
* These families are therefore skipped when RENDERING (see getRendererOrder), which drops
* three guaranteed-failing renderer attempts - two fetches each - from every equation that
* gets past Codecogs and Texrendr. They are deliberately still reachable through
* getRenderer/capableDerenderers so equations rendered before the shutdown keep
* de-rendering. What breaks if this list is emptied: Auto gets slower on every fallback
* and any explicit Sciweavers choice fails 100% of the time.
* @public
*/
const retiredRendererFamilies = ["Sciweavers", "Sciweavers_old"];

/**
* @public
*/
function isRetiredRendererFamily(family: string) {
return retiredRendererFamilies.indexOf(family) > -1;
}

/**
* Renderer ID constants for retreiving info about specific renderers
* @public
Expand All @@ -160,6 +189,9 @@ const invalidEquationHashTexrendrFirst50 = "GIF89a%uFFFD%008%00%uFFFD%00%00%uFFF
const invalidEquationHashTexrendrFirst50_2 = "GIF89a%01%00%01%00%uFFFD%00%00%uFFFD%uFFFD%uFFFD%0";
const invalidEquationHashTexrendrFirst50_3 = "GIF89ai%0A%uFFFD%01%uFFFD%00%00%uFFFD%uFFFD%uFFFD%"; // this is the No Expression Supplied error. Ignored for now.
const invalidEquationHashTexrendrFirst50_4 = "%7FELF%01%01%01%00%00%00%00%00%00%00%00%00%02%00%0";
// NOTE: this prefix is an HTML document where an image was expected. It originally caught
// Sciweavers answering an amsmath equation with its editor page, and it also matches the
// 404 page tex2img.php now serves unconditionally (see retiredRendererFamilies).
const invalidEquationHashSciweaversFirst50 = "%0D%0A%09%3C%21DOCTYPE%20html%20PUBLIC%20%22-//W3C";
const defaultRendererPreference = "auto";
let activeRendererPreference: string | null = null;
Expand All @@ -173,7 +205,11 @@ function normalizeRendererPreference(renderer: string | null | undefined) {
case "texrendr":
return "texrendr";
case "sciweavers":
return "sciweavers";
// REASON: users who picked Sciweavers before it shut down still have it in their saved
// properties, and the option is gone from the sidebars. Migrate the stored value to
// Automatic here so those users render instead of failing on every equation; savePrefs
// writes the normalized value back, so the dead preference does not survive a render.
return defaultRendererPreference;
default:
return defaultRendererPreference;
}
Expand All @@ -185,9 +221,9 @@ function getPreferredRendererFamily(rendererPreference: string) {
return "Codecogs";
case "texrendr":
return "Texrendr";
case "sciweavers":
return "Sciweavers";
default:
// NOTE: no "sciweavers" case - normalizeRendererPreference maps it to Automatic, so a
// retired family can never become the preferred family that getRendererOrder promotes.
return "";
}
}
Expand Down Expand Up @@ -261,6 +297,9 @@ function getRendererOrder() {
const fallbackOrder: number[] = [];

for (let worked = 1; worked <= capableRenderers; ++worked) {
// REASON: retired services are still listed in getRenderer so old equations de-render,
// but attempting them here only costs two doomed fetches and a sleep per equation.
if (isRetiredRendererFamily(getRenderer(worked)[5])) continue;
defaultOrder.push(worked);
}

Expand Down
12 changes: 8 additions & 4 deletions Docs/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ function replaceEquations(sizeRaw, delimiter, renderer) {
// both because a Codecogs outage can hang UrlFetchApp long enough for
// google.script.run to surface the generic "reload" error, and because it avoids
// sending equation contents to external renderer APIs unless MathJax hard-fails;
// PR #61 wanted no server fallback at all, but keeping Texrendr/Sciweavers as the
// sidebar-invoked fallback preserves rendering when MathJax can't load).
// PR #61 wanted no server fallback at all, but keeping Texrendr as the
// sidebar-invoked fallback preserves rendering when MathJax can't load. Sciweavers used to
// back Texrendr up here; it was dropped when its image endpoint went away).
var autoFallbackToClient = renderer === "auto";
if (clientRender || autoFallbackToClient) {
console.log("MathJax render requested.", JSON.stringify({ sizeRaw: sizeRaw, delimiter: delimiter }));
Expand Down Expand Up @@ -795,7 +796,7 @@ function buildClientRenderResponse(textElement, startElement, equationOriginal,
}
/**
* Called by the client when MathJax rendering fails in auto mode.
* Tries remaining server-side renderers (Texrendr, Sciweavers) for the failed equations.
* Tries remaining server-side renderers (Texrendr) for the failed equations.
* @public
*/
function clientRenderFailed(equations) {
Expand Down Expand Up @@ -830,7 +831,10 @@ function clientRenderFailed(equations) {
r: equation.options.r,
g: equation.options.g,
b: equation.options.b,
allowedServerFamilies: ["Texrendr", "Sciweavers", "Sciweavers_old", "Roger's renderer", "Number empire"]
// NOTE: Sciweavers/Sciweavers_old were dropped from this list when sciweavers.org
// retired its image endpoint (Common.retiredRendererFamilies). getRendererOrder already
// filters them out, so listing them here only suggested a fallback that cannot happen.
allowedServerFamilies: ["Texrendr", "Roger's renderer", "Number empire"]
});
if (fallbackResult.worked > Common.capableRenderers || !fallbackResult.resp || !fallbackResult.renderer) {
if (fallbackResult.authorizationError) {
Expand Down
12 changes: 8 additions & 4 deletions Docs/Code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ function replaceEquations(sizeRaw: string, delimiter: string, renderer: string =
// both because a Codecogs outage can hang UrlFetchApp long enough for
// google.script.run to surface the generic "reload" error, and because it avoids
// sending equation contents to external renderer APIs unless MathJax hard-fails;
// PR #61 wanted no server fallback at all, but keeping Texrendr/Sciweavers as the
// sidebar-invoked fallback preserves rendering when MathJax can't load).
// PR #61 wanted no server fallback at all, but keeping Texrendr as the
// sidebar-invoked fallback preserves rendering when MathJax can't load. Sciweavers used to
// back Texrendr up here; it was dropped when its image endpoint went away).
const autoFallbackToClient = renderer === "auto";
if (clientRender || autoFallbackToClient) {
console.log("MathJax render requested.", JSON.stringify({ sizeRaw, delimiter }));
Expand Down Expand Up @@ -941,7 +942,7 @@ function buildClientRenderResponse(

/**
* Called by the client when MathJax rendering fails in auto mode.
* Tries remaining server-side renderers (Texrendr, Sciweavers) for the failed equations.
* Tries remaining server-side renderers (Texrendr) for the failed equations.
* @public
*/
function clientRenderFailed(equations: { options: AutoLatexCommon.ClientRenderOptions }[]) {
Expand Down Expand Up @@ -980,7 +981,10 @@ function clientRenderFailed(equations: { options: AutoLatexCommon.ClientRenderOp
r: equation.options.r,
g: equation.options.g,
b: equation.options.b,
allowedServerFamilies: ["Texrendr", "Sciweavers", "Sciweavers_old", "Roger's renderer", "Number empire"]
// NOTE: Sciweavers/Sciweavers_old were dropped from this list when sciweavers.org
// retired its image endpoint (Common.retiredRendererFamilies). getRendererOrder already
// filters them out, so listing them here only suggested a fallback that cannot happen.
allowedServerFamilies: ["Texrendr", "Roger's renderer", "Number empire"]
});

if (fallbackResult.worked > Common.capableRenderers || !fallbackResult.resp || !fallbackResult.renderer) {
Expand Down
1 change: 0 additions & 1 deletion Docs/Sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<option value="codecogs">Codecogs</option>
<option value="mathjax">MathJax (best)</option>
<option value="texrendr">Texrendr</option>
<option value="sciweavers">Sciweavers</option>
</select>
</div>

Expand Down
8 changes: 6 additions & 2 deletions Docs/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,12 @@ function loadPreferences(choicePrefs: {size: string, delim: string, renderer: st
$('#delimit').val(choicePrefs.delim);
// REASON: Older users may have Codecogs saved from when it was the practical default.
// Open the sidebar on Automatic so Codecogs outages don't keep affecting them.
const rendererPreference = choicePrefs.renderer === "codecogs" ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr", "sciweavers"].includes(rendererPreference) ? rendererPreference : "auto";
// Sciweavers gets the same treatment for a harder reason: it shut down its image endpoint,
// the option no longer exists in the selector, and leaving the saved value here would show
// an empty renderer box and send a dead choice back to the server.
const retiredOrDeprioritized = ["codecogs", "sciweavers"];
const rendererPreference = retiredOrDeprioritized.includes(choicePrefs.renderer) ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr"].includes(rendererPreference) ? rendererPreference : "auto";
$('#renderer').val(savedRenderer);
enableSidebarButtons();
setRenderButtonState(false);
Expand Down
1 change: 0 additions & 1 deletion Sheets/Sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<option value="mathjax">MathJax (best)</option>
<option value="codecogs">Codecogs</option>
<option value="texrendr">Texrendr</option>
<option value="sciweavers">Sciweavers</option>
</select>
</div>

Expand Down
8 changes: 6 additions & 2 deletions Sheets/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,12 @@ function loadPreferences(choicePrefs: { size: string; delim: string; renderer: s
$('#delimit').val(choicePrefs.delim);
// REASON: Older users may have Codecogs saved from when it was the practical default.
// Open the sidebar on Automatic so Codecogs outages don't keep affecting them.
const rendererPreference = choicePrefs.renderer === "codecogs" ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr", "sciweavers"].includes(rendererPreference) ? rendererPreference : "auto";
// Sciweavers gets the same treatment for a harder reason: it shut down its image endpoint,
// the option no longer exists in the selector, and leaving the saved value here would show
// an empty renderer box and send a dead choice back to the server.
const retiredOrDeprioritized = ["codecogs", "sciweavers"];
const rendererPreference = retiredOrDeprioritized.includes(choicePrefs.renderer) ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr"].includes(rendererPreference) ? rendererPreference : "auto";
$('#renderer').val(savedRenderer);
$('#insert-text').prop("disabled", false);
$('#edit-text').prop("disabled", false);
Expand Down
1 change: 0 additions & 1 deletion Slides/Sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<option value="codecogs">Codecogs</option>
<option value="mathjax">MathJax (best)</option>
<option value="texrendr">Texrendr</option>
<option value="sciweavers">Sciweavers</option>
</select>
</div>

Expand Down
8 changes: 6 additions & 2 deletions Slides/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@ function loadPreferences(choicePrefs: {size: string, delim: string, renderer: st
$('#delimit').val(choicePrefs.delim);
// REASON: Older users may have Codecogs saved from when it was the practical default.
// Open the sidebar on Automatic so Codecogs outages don't keep affecting them.
const rendererPreference = choicePrefs.renderer === "codecogs" ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr", "sciweavers"].includes(rendererPreference) ? rendererPreference : "auto";
// Sciweavers gets the same treatment for a harder reason: it shut down its image endpoint,
// the option no longer exists in the selector, and leaving the saved value here would show
// an empty renderer box and send a dead choice back to the server.
const retiredOrDeprioritized = ["codecogs", "sciweavers"];
const rendererPreference = retiredOrDeprioritized.includes(choicePrefs.renderer) ? "auto" : choicePrefs.renderer;
const savedRenderer = ["auto", "mathjax", "texrendr"].includes(rendererPreference) ? rendererPreference : "auto";
$('#renderer').val(savedRenderer);
$('#insert-text').prop("disabled", false);
$('#edit-text').prop("disabled", false);
Expand Down
14 changes: 11 additions & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ because it returns three SVG fragments instead of one. The fixed source passes.
npm run test:render-services
```

This optional live smoke suite covers the **60 external-renderer combinations**
with the two generic equations. Identical URLs across apps/delimiters reuse the
same response: 12 distinct requests instead of 192 duplicate image requests.
This optional live smoke suite covers **every external-renderer combination the
sidebars still offer** (40 since Sciweavers was retired) with the two generic
equations. Identical URLs across apps/delimiters reuse the same response: 8
distinct requests instead of 160 duplicate image requests.
Requests have deadlines and three workers. It saves returned images, an
Auto/Inline screenshot, and explicit per-combination results under
`test-results/render-services/`. It exits nonzero for unavailable services and
Expand All @@ -107,3 +108,10 @@ On 2026-09-17, Codecogs and Texrendr returned complete sample equations in both
size modes; Sciweavers returned **HTTP 404** for all four distinct sample requests.
This external-service failure is independent of the MathJax Inline fix.
See [review screenshots](evidence/pr71/README.md).

That 404 was not transient. sciweavers.org is still up, but it retired
`tex2img.php` — the GET image endpoint every Sciweavers renderer entry was built
on — so the renderer was removed from the sidebars and from the render order,
while staying available for de-rendering old equations. The probe has run clean
since: on 2026-09-18, 8 distinct requests, 0 unavailable. See
[what was verified](evidence/sciweavers-retired/README.md).
5 changes: 4 additions & 1 deletion tests/browser/server-renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ async function main() {
}));
const gallery = await browser.newPage({ viewport: { width: 1280, height: 900 } });
const escapeHtml = s => s.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
const rows = ['codecogs', 'texrendr', 'sciweavers'].flatMap(renderer => samples.map(sample => {
// Derived from the shipped selector via serverCases, so retiring a renderer removes its row
// instead of leaving a hard-coded name that crashes on a missing result.
const galleryRenderers = [...new Set(serverCases.map(c => c.renderer))];
const rows = galleryRenderers.flatMap(renderer => samples.map(sample => {
const cells = ['smart', 'inline'].map(mode => {
const result = [...results.values()].find(r => r.renderer === renderer && r.mode === mode && r.sample === sample);
if (!result.filename) return `<td class="failed">${escapeHtml(result.error)}</td>`;
Expand Down
Loading
Loading