Skip to content

Commit

Permalink
use codecogs for LaTeX rendering by default
Browse files Browse the repository at this point in the history
Note that the changes in the translation files is mostly just churn. The non-English locales' JSON files weren't properly getting English fallbacks added to them; I did that and sorted the keys on output, to prevent future churn. But the difference in order and whitespace bloated the diff. In the future this shouldn't happen.
  • Loading branch information
adam-p committed Nov 9, 2024
1 parent a513139 commit 9628a6d
Show file tree
Hide file tree
Showing 34 changed files with 3,328 additions and 3,104 deletions.
520 changes: 267 additions & 253 deletions src/_locales/de/messages.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@
"message": "<strong>Privacy Issues:</strong>",
"description": "heading for warnings about TeX math privacy concerns"
},
"options_page__tex_math_privacy_issue_1": {
"message": "To generate the image for the formula, a request is sent to Google. That effectively means that you are sharing your formula with Google. It also means that recipients of your message will be making a request to Google to have the image rendered.",
"options_page__tex_math_codecogs_privacy_issue_1": {
"message": "To generate the image for the formula, a request is sent to CodeCogs. That effectively means that you are sharing your formula with CodeCogs. It also means that recipients of your message will be making a request to CodeCogs to have the image rendered.",
"description": "one of the TeX math privacy concerns"
},
"options_page__tex_math_privacy_issue_2": {
Expand All @@ -220,11 +220,11 @@
"message": "If this feature is enabled, text between dollar signs — <code>$$</code> — will be interpreted as mathematical formulae. For example, <code>$$\\Delta$$</code> would be rendered as a delta symbol.",
"description": "Note: Double dollar signs ($$) are necessary to get a single dollar sign."
},
"options_page__tex_math_customization_2": {
"message": "For render customization options, see the <a href=\"https://developers.google.com/chart/infographics/docs/formulas\" target=\"_blank\">Google Charts documentation</a> for this service."
"options_page__tex_math_codecogs_customization_2": {
"message": "For render customization options, see the <a href=\"https://editor.codecogs.com/docs/4-LaTeX_rendering.php\" target=\"_blank\">CodeCogs documentation</a> for this service."
},
"options_page__tex_math_customization_3": {
"message": "A good resource for creating TeX formulae is the <a href=\"https://www.codecogs.com/latex/about.php\" target=\"_blank\">CodeCogs Equation Editor</a>."
"message": "A good resource for creating TeX formulae is the <a href=\"https://editor.codecogs.com/\" target=\"_blank\">CodeCogs Equation Editor</a>."
},
"options_page__tex_math_customization_4": {
"message": "Formulae are rendered to images, so email recipients will have to enable images to be shown to see the rendering."
Expand Down
519 changes: 266 additions & 253 deletions src/_locales/es/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/fr/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/it/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/ja/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/ko/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/pl/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/pt_BR/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/ru/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/tr/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/zh_CN/messages.json

Large diffs are not rendered by default.

519 changes: 266 additions & 253 deletions src/_locales/zh_TW/messages.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/common/options-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (typeof(Utils) === 'undefined' && typeof(Components) !== 'undefined') {
// Common defaults
var DEFAULTS = {
'math-enabled': true,
'math-value': '<img src="https://chart.googleapis.com/chart?cht=tx&chl={urlmathcode}" alt="{mathcode}">',
'math-value': '<img src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;{urlmathcode}" alt="{mathcode}">',
'hotkey': { shiftKey: false, ctrlKey: true, altKey: true, key: 'M' },
'forgot-to-render-check-enabled': false,
'header-anchors-enabled': false,
Expand Down Expand Up @@ -50,6 +50,7 @@ var DEFAULTS = {

var ChromeOptionsStore = {


// The options object will be passed to `callback`
get: function(callback) {
var that = this;
Expand Down Expand Up @@ -500,6 +501,14 @@ if (!this.OptionsStore) {
this.OptionsStore._fillDefaults = function(prefsObj, callback) {
var that = this;

// Upgrade the object, if necessary.
// Motivation: Our default for the LaTeX renderer used to be Google Charts API. Google
// discontinued the service and we switched the default to CodeCogs, but because it was
// the default, it will be set in many users' OptionsStore. We need to forcibly replace it.
if (typeof prefsObj['math-value'] === 'string' && prefsObj['math-value'].indexOf('chart.googleapis.com') >= 0) {
prefsObj['math-value'] = that.defaults['math-value'];
}

var key, allKeys = [];
for (key in that.defaults) {
if (that.defaults.hasOwnProperty(key)) {
Expand Down
10 changes: 5 additions & 5 deletions src/common/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ <h1>
<p>
<span data-i18n="tex_math_privacy_heading"><strong>Privacy Issues:</strong></span>
<ul>
<li data-i18n="tex_math_privacy_issue_1">
To generate the image for the formula, a request is sent to Google. That effectively means that you are sharing your formula with Google. It also means that recipients of your message will be making a request to Google to have the image rendered.
<li data-i18n="tex_math_codecogs_privacy_issue_1">
To generate the image for the formula, a request is sent to CodeCogs. That effectively means that you are sharing your formula with CodeCogs. It also means that recipients of your message will be making a request to CodeCogs to have the image rendered.
</li>
<li data-i18n="tex_math_privacy_issue_2">
If you customize the formula rendering tag, you should use a secure (https://) path. Not all rendering services provide a secure option.
Expand All @@ -520,11 +520,11 @@ <h1>
<li data-i18n="tex_math_customization_1">
If this feature is enabled, text between dollar signs — <code>$</code> — will be interpreted as mathematical formulae. For example, <code>$\Delta$</code> would be rendered as a delta symbol.
</li>
<li data-i18n="tex_math_customization_2">
For render customization options, see the <a href="https://developers.google.com/chart/infographics/docs/formulas" target="_blank">Google Charts documentation</a> for this service.
<li data-i18n="tex_math_codecogs_customization_2">
For render customization options, see the <a href="https://editor.codecogs.com/docs/4-LaTeX_rendering.php" target="_blank">CodeCogs documentation</a> for this service.
</li>
<li data-i18n="tex_math_customization_3">
A good resource for creating TeX formulae is the <a href="https://www.codecogs.com/latex/about.php" target="_blank">CodeCogs Equation Editor</a>.
A good resource for creating TeX formulae is the <a href="https://editor.codecogs.com/" target="_blank">CodeCogs Equation Editor</a>.
</li>
<li data-i18n="tex_math_customization_4">
Formulae are rendered to images, so email recipients will have to enable images to be shown to see the rendering.
Expand Down
12 changes: 6 additions & 6 deletions src/common/test/markdown-render-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ describe('Markdown-Render', function() {
// https://github.com/adam-p/markdown-here/issues/84
it('should render single-character math formulae', function() {
userprefs = {
'math-value': '<img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl={urlmathcode}" alt="{mathcode}">',
'math-value': '<img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;{urlmathcode}" alt="{mathcode}">',
'math-enabled': true
};

var md = '$x$';
var target = '<p><img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl=x" alt="x"></p>\n';
var target = '<p><img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;x" alt="x"></p>\n';
expect(MarkdownRender.markdownRender(md, userprefs, marked, hljs)).to.equal(target);

// Make sure we haven't broken multi-character forumlae
md = '$xx$';
target = '<p><img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl=xx" alt="xx"></p>\n';
target = '<p><img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;xx" alt="xx"></p>\n';
expect(MarkdownRender.markdownRender(md, userprefs, marked, hljs)).to.equal(target);
});

Expand Down Expand Up @@ -320,17 +320,17 @@ describe('Markdown-Render', function() {
// https://github.com/adam-p/markdown-here/issues/84
it('should render single-character math formulae', function() {
userprefs = {
'math-value': '<img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl={urlmathcode}" alt="{mathcode}">',
'math-value': '<img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;{urlmathcode}" alt="{mathcode}">',
'math-enabled': true
};

var md = '$x$';
var target = '<p><img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl=x" alt="x"></p>\n';
var target = '<p><img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;x" alt="x"></p>\n';
expect(fullRender(md)).to.equal(target);

// Make sure we haven't broken multi-character forumlae
md = '$xx$';
target = '<p><img class="mdh-math" src="https://chart.googleapis.com/chart?cht=tx&chl=xx" alt="xx"></p>\n';
target = '<p><img class="mdh-math" src="https://latex.codecogs.com/png.image?\\dpi{120}\\inline&space;xx" alt="xx"></p>\n';
expect(fullRender(md)).to.equal(target);
});

Expand Down
2 changes: 1 addition & 1 deletion src/common/test/mdh-html-to-text-test.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/common/test/options-store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ describe('OptionsStore', function() {
});
});

it('should upgrade defunct values to new default', function(done) {
// Set our old math-value default, which we're replacing
let obj = {'math-value': '<img src="https://chart.googleapis.com/chart?cht=tx&chl={urlmathcode}" alt="{mathcode}">'};
OptionsStore.set(obj, function() {
// Make sure we get the new default value instead of the defunct old one
OptionsStore.get(function(options) {
expect(options).to.have.property('math-value');
expect(options['math-value']).to.contain('codecogs');
done();
});
});
});

});

});
23 changes: 23 additions & 0 deletions src/common/test/utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,29 @@ describe('Utils', function() {
});
});

describe('semverGreaterThan', function() {
it('should correctly order version strings', function() {
// Since the exact string retuned depends on the current browser locale,
// we'll just check that some string is returned.
expect(Utils.semverGreaterThan('1.11.1', '1.2.2')).to.be.true;
expect(Utils.semverGreaterThan('11.1.1', '2.2.2')).to.be.true;
expect(Utils.semverGreaterThan('11.1.1', '11.1.0')).to.be.true;
expect(Utils.semverGreaterThan('9.0.0', '10.0.0')).to.be.false;
expect(Utils.semverGreaterThan('9.0.2', '9.0.100')).to.be.false;
expect(Utils.semverGreaterThan('0.99', '1.0')).to.be.false;
});

it('should cope with non-semver input', function() {
expect(Utils.semverGreaterThan('nope', '1.0')).to.be.true.and.to.not.throw;
expect(Utils.semverGreaterThan('1.0', 'nope')).to.be.false.and.to.not.throw;
});

it('should return false on falsy input', function() {
expect(Utils.semverGreaterThan(null, '1.0')).to.be.false;
expect(Utils.semverGreaterThan('1.0', null)).to.be.false;
});
});

describe('registerStringBundleLoadListener', function() {
it('should get called eventually', function(done) {
Utils.registerStringBundleLoadListener(done);
Expand Down
12 changes: 12 additions & 0 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,17 @@ function getMessage(messageID) {
return message;
}

// Returns true if the semver version string in a is greater than the one in b.
// If a or b isn't a version string, a simple string comparison is returned.
// If a or b is falsy, false is returned.
// From https://stackoverflow.com/a/55466325
function semverGreaterThan(a, b) {
if (!a || !b) {
return false;
}
return a.localeCompare(b, undefined, { numeric: true }) === 1;
}


/*****************************************************************************/
/*\
Expand Down Expand Up @@ -1209,6 +1220,7 @@ Utils.getSafariStringBundle = getSafariStringBundle;
/*? } */
Utils.registerStringBundleLoadListener = registerStringBundleLoadListener;
Utils.getMessage = getMessage;
Utils.semverGreaterThan = semverGreaterThan;
Utils.utf8StringToBase64 = utf8StringToBase64;
Utils.base64ToUTF8String = base64ToUTF8String;

Expand Down
6 changes: 3 additions & 3 deletions src/firefox/chrome/locale/de/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ options_page__donate_plea_2=<strong>Markdown Here verbessern!</strong>
options_page__donate_plea_3=<strong>Bei der Entwicklung von Markdown Here helfen!</strong>
options_page__donate_plea_4=Schon gewusst was es einfacher macht Markdown Here mit diversen Tools (Chrome, Firefox, Thunderbird, Postbox, Safari, Opera, Gmail, Yahoo, Hotmail, Blogger, Evernote, uvm.) kompatibel zu halten? <strong>Kaffee!</strong>
options_page__footer_1=<em>Markdown Here</em> ist Open Source. Um Fragen zu stellen, Bug-Reports zu machen, Features zu erfragen, oder selbst beizutragen, siehe die <a target=\"_blank\" href=\"https://github.com/adam-p/markdown-here\">Github-Projektseite</a> oder die <a target=\"_blank\" href=\"https://groups.google.com/forum/?fromgroups=#!forum/markdown-here\">\"markdown-here\" Google-Gruppe</a>.
options_page__footer_2=Geschrieben von <a target=\"_blank\" href=\"https://adam-p.github.io/\">Adam Pritchard</a>.
options_page__footer_2=Geschrieben von <a target=\"_blank\" href=\"http://adam-p.github.com/\">Adam Pritchard</a>.
options_page__forgot_to_render_1=Z.Zt. nur unterstützt im Gmail-Webinterface und für Thunderbird (sowie Postbox und Icedove).
options_page__forgot_to_render_2=Bei Versendung einer E-Mail überprüft dies den Inhalt um festzustellen ob sie in Markdown geschrieben, aber noch nicht gerendert wurde (durch Klick auf \"Markdown An/Aus\"). Möglicherweise muss dies deaktiviert werden wenn es das Versenden von E-Mails verhindert.
options_page__forgot_to_render_3=Wenn es deaktiviert werden muss, <em>bitte</em> mich benachrichtigen so dass es verbessert werden kann. Erstellen <a href=\"https://groups.google.com/forum/#!forum/markdown-here\" target=\"_blank\">einen Post in der \"Markdown-Here\" Google-Gruppe</a> oder <a href=\"https://github.com/adam-p/markdown-here/issues\" target=\"_blank\">eine Anfrage im Github-Project</a>. Danke.
Expand Down Expand Up @@ -69,8 +69,9 @@ options_page__resources_title=Ressourcen und Links
options_page__start_new_message=Eine neue E-Mail beginnen.
options_page__syntax_highlighting_css_title=CSS für Syntax-Highlighting
options_page__syntax_highlighting_theme_label=Schema:
options_page__tex_math_codecogs_customization_2=For render customization options, see the <a href=\"https://editor.codecogs.com/docs/4-LaTeX_rendering.php\" target=\"_blank\">CodeCogs documentation</a> for this service.
options_page__tex_math_codecogs_privacy_issue_1=To generate the image for the formula, a request is sent to CodeCogs. That effectively means that you are sharing your formula with CodeCogs. It also means that recipients of your message will be making a request to CodeCogs to have the image rendered.
options_page__tex_math_customization_1=Wenn dies aktiviert ist, wird Text zwischen Dollarzeichen — <code>$</code> — als mathematische Formel interpretiert. Zum Beispiel wird <code>$\\Delta$</code> als Deltasymbol &Delta; gerendert.
options_page__tex_math_customization_2=Siehe die <a href=\"https://developers.google.com/chart/infographics/docs/formulas\" target=\"_blank\">Google Charts Dokumentation</a> für Optionen zur Anpassung des Renderings.
options_page__tex_math_customization_3=Der <a href=\"https://www.codecogs.com/latex/about.php\" target=\"_blank\">CodeCogs Gleichungseditor</a> ist eine gute Quelle für TeX-Tipps.
options_page__tex_math_customization_4=Formeln werden als Bilddateien gerendert, Empfänger müssen also Bilder zulassen um sie zu sehen.
options_page__tex_math_customization_5=Bei Anpassung des Rendering-Tags können (und sollten) <code>{mathcode}</code> und/oder <code>{urlmathcode}</code> als Platzhalter verwendet werden.
Expand All @@ -79,7 +80,6 @@ options_page__tex_math_customization_5_2=<code>{urlmathcode}</code>: Die URL-kod
options_page__tex_math_customization_6=Bei Anpassung des <code>&lt;img&gt;</code>-Tags sollte ein <code>alt</code>-Attribut eingschlossen werden mit möglichst leserlichem Wert, etwa <code>{mathcode}</code>. Der Wert dieses Attributs wird für die Plaintext-Version der E-Mail benutzt (wenn via Gmail oder Thunderbird versandt), sowie von Bildschirm-Leser für Seh-behinderte Empfänger.
options_page__tex_math_customization_heading=<strong>Anpassung und Verwendung:</strong>
options_page__tex_math_privacy_heading=<strong>Datenschutz:</strong>
options_page__tex_math_privacy_issue_1=Um eine Formel als Bilddatei zu rendern, wird eine Anfrage an Google gesendet. Damit wird die Formel für Google freigegeben. Das bedeutet auch dass die Empfänger der Nachricht Anfragen an Google schicken müssen um das gerenderte Ergebnis zu sehen.
options_page__tex_math_privacy_issue_2=Bei Anpassung des Formel-Rendering-Tags sollte ein sicherer (https://) Pfad benutzt werden. Nicht alle Rendering-Services haben diese Option.
options_page__tex_math_reset_button=Auf Standard zurücksetzen
options_page__tex_math_title=TeX für mathematische Formeln
Expand Down
6 changes: 3 additions & 3 deletions src/firefox/chrome/locale/en/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ options_page__resources_title=Resources and Links
options_page__start_new_message=Start a new email message.
options_page__syntax_highlighting_css_title=Syntax Highlighting CSS
options_page__syntax_highlighting_theme_label=Theme:
options_page__tex_math_codecogs_customization_2=For render customization options, see the <a href=\"https://editor.codecogs.com/docs/4-LaTeX_rendering.php\" target=\"_blank\">CodeCogs documentation</a> for this service.
options_page__tex_math_codecogs_privacy_issue_1=To generate the image for the formula, a request is sent to CodeCogs. That effectively means that you are sharing your formula with CodeCogs. It also means that recipients of your message will be making a request to CodeCogs to have the image rendered.
options_page__tex_math_customization_1=If this feature is enabled, text between dollar signs — <code>$</code> — will be interpreted as mathematical formulae. For example, <code>$\\Delta$</code> would be rendered as a delta symbol.
options_page__tex_math_customization_2=For render customization options, see the <a href=\"https://developers.google.com/chart/infographics/docs/formulas\" target=\"_blank\">Google Charts documentation</a> for this service.
options_page__tex_math_customization_3=A good resource for creating TeX formulae is the <a href=\"https://www.codecogs.com/latex/about.php\" target=\"_blank\">CodeCogs Equation Editor</a>.
options_page__tex_math_customization_3=A good resource for creating TeX formulae is the <a href=\"https://editor.codecogs.com/\" target=\"_blank\">CodeCogs Equation Editor</a>.
options_page__tex_math_customization_4=Formulae are rendered to images, so email recipients will have to enable images to be shown to see the rendering.
options_page__tex_math_customization_5=If you customize the rendering tag, you can (and should) use either or both of <code>{mathcode}</code> and <code>{urlmathcode}</code> as placeholders.
options_page__tex_math_customization_5_1=<code>{mathcode}</code>: The text between the <code>$</code> symbols — i.e., the raw TeX formula; like <code>\\Delta</code>.
options_page__tex_math_customization_5_2=<code>{urlmathcode}</code>: The URL-encoded form of the TeX formula; like <code>%5CDelta</code>.
options_page__tex_math_customization_6=If you customize the <code>&lt;img&gt;</code> tag, you should include an <code>alt</code> attribute that has as human-readable a value as possible, like <code>{mathcode}</code>. This value of this attribute will be used for the plaintext version of the email (when sent from Gmail and Thunderbird), and used by screen readers for sight-impaired recipients.
options_page__tex_math_customization_heading=<strong>Customization and Use:</strong>
options_page__tex_math_privacy_heading=<strong>Privacy Issues:</strong>
options_page__tex_math_privacy_issue_1=To generate the image for the formula, a request is sent to Google. That effectively means that you are sharing your formula with Google. It also means that recipients of your message will be making a request to Google to have the image rendered.
options_page__tex_math_privacy_issue_2=If you customize the formula rendering tag, you should use a secure (https://) path. Not all rendering services provide a secure option.
options_page__tex_math_reset_button=Reset to Default
options_page__tex_math_title=TeX Mathematical Formulae Support
Expand Down
Loading

0 comments on commit 9628a6d

Please sign in to comment.