diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 0fdb47a14..5f86c88cf 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -1161,7 +1161,7 @@ MathJax.Localization = { if (typeof data[1] === "string") { // [id,string,args] var id = data[0]; if (!(id instanceof Array)) {id = [domain,id]} var phrase = this.lookupPhrase(id,data[1]); - result = result.concat(this.processString(phrase,data.slice(2),domain)); + result = result.concat(this.processMarkdown(phrase,data.slice(2),domain)); } else if (data[1] instanceof Array) { // [domain,snippet] result = result.concat(this.processSnippet.apply(this,data)); } else if (data.length >= 3) { // ["tag",{properties},snippet] @@ -1175,6 +1175,85 @@ MathJax.Localization = { } return result; }, + + markdownPattern: /(%.)|(\*{1,3})((?:%.|.)+?)\2|(`+)((?:%.|.)+?)\4|\[((?:%.|.)+?)\]\(([^\s\)]+)\)/, + // %c or *bold*, **italics**, ***bold-italics***, or `code`, or [link](url) + + processMarkdown: function (phrase,args,domain) { + var result = [], data; + // + // Split the string by the Markdown pattern + // (the text blocks are separated by + // c,stars,star-text,backtics,code-text,link-text,URL). + // Start with teh first text string from the split. + // + var parts = phrase.split(this.markdownPattern); + var string = parts[0]; + // + // Loop through the matches and process them + // + for (var i = 1, m = parts.length; i < m; i += 8) { + if (parts[i+1]) { // stars (for bold/italic) + // + // Select the tag to use by number of stars (three stars requires two tags) + // + data = this.processString(parts[i+2],args,domain); + if (!(data instanceof Array)) {data = [data]} + data = [["b","i","i"][parts[i+1].length-1],{},data]; // number of stars determines type + if (parts[i+1].length === 3) {data = ["b",{},data]} // bold-italic + } else if (parts[i+3]) { // backtics (for code) + // + // Remove one leading or trailing space, and process substitutions + // Make a tag + // + data = this.processString(parts[i+4].replace(/^\s/,"").replace(/\s$/,""),args,domain); + if (!(data instanceof Array)) {data = [data]} + data = ["code",{},data]; + } else if (parts[i+5]) { // hyperlink + // + // Process the link text, and make an tag with the URL + // + data = this.processString(parts[i+5],args,domain); + if (!(data instanceof Array)) {data = [data]} + data = ["a",{href:parts[i+6],target:"_blank"},data]; + } else { + // + // Escaped character (%c) gets added into the string. + // + string += parts[i]; data = null; + } + // + // If there is a tag to insert, + // Add any pending string, then push the tag + // + if (data) { + result = this.concatString(result,string,args,domain); + result.push(data); string = ""; + } + // + // Process the string that follows matches pattern + // + if (parts[i+7] !== "") {string += parts[i+7]} + }; + // + // Add any pending string and return the resulting snippet + // + result = this.concatString(result,string,args,domain); + return result; + }, + concatString: function (result,string,args,domain) { + if (string != "") { + // + // Process the substutions. + // If the result is not a snippet, turn it into one. + // Then concatenate the snippet to the current one + // + string = this.processString(string,args,domain); + if (!(string instanceof Array)) {string = [string]} + result = result.concat(string); + } + return result; + }, lookupPhrase: function (id,phrase,domain) { // diff --git a/unpacked/extensions/FontWarnings.js b/unpacked/extensions/FontWarnings.js index 7b5a7653c..628684193 100644 --- a/unpacked/extensions/FontWarnings.js +++ b/unpacked/extensions/FontWarnings.js @@ -190,35 +190,27 @@ fonts: [ ["p"], ["fonts", - "MathJax can use either the %1 or the %2. " + + "MathJax can use either the [STIX fonts](%1) or the [MathJax TeX fonts](%2). " + "Download and install one of those fonts to improve your MathJax experience.", - [["a",{href:STIXURL,target:"_blank"},[["STIXfonts","STIX fonts"]]]], - [["a",{href:MATHJAXURL,target:"_blank"},[["TeXfonts","MathJax TeX fonts"]]]] + STIXURL,MATHJAXURL ] ], -// fonts: [ -// ["p"], -// ["fonts", -// "MathJax can use either the [STIX fonts](%1) or the [MathJax TeX fonts](%2)", -// "http://www.stixfonts.org/","http://www.mathjax.org/help-v2/fonts/"] -// ], - STIXfonts: [ ["p"], - ["PageDesigned", - "This page is designed to use the %1. " + + ["STIXPage", + "This page is designed to use the [STIX fonts](%1). " + "Download and install those fonts to improve your MathJax experience.", - [["a",{href:STIXURL,target:"_blank"},[["STIXfonts","STIX fonts"]]]] + STIXURL ] ], TeXfonts: [ ["p"], - ["PageDesigned", - "This page is designed to use the %1. " + + ["TeXPage", + "This page is designed to use the [MathJax TeX fonts](%1). " + "Download and install those fonts to improve your MathJax experience.", - [["a",{href:MATHJAXURL,target:"_blank"},[["TeXfonts","MathJax TeX fonts"]]]] + MATHJAXURL ] ] diff --git a/unpacked/extensions/v1.0-warning.js b/unpacked/extensions/v1.0-warning.js index 750c26507..d46839aba 100644 --- a/unpacked/extensions/v1.0-warning.js +++ b/unpacked/extensions/v1.0-warning.js @@ -85,7 +85,7 @@ "you must specify such files explicitly. " + "This page seems to use the older default %1 " + "file, and so needs to be updated. This is explained further at %2", - [["code",{},["config/MathJax.js"]]], + [["code",{},"config/MathJax.js"]], [["p",{style:{"text-align":"center"}},[ ["a", {href:"http://www.mathjax.org/help-v2/configuration"}, diff --git a/unpacked/localization/de/FontWarnings.js b/unpacked/localization/de/FontWarnings.js index 567d91983..9815be7a2 100644 --- a/unpacked/localization/de/FontWarnings.js +++ b/unpacked/localization/de/FontWarnings.js @@ -40,24 +40,22 @@ MathJax.Localization.addTranslation("de","FontWarnings",{ // "browsers) could improve the quality of the mathematics on this page.", fonts: - "MathJax kann %1 oder %2 verwenden. "+ + "MathJax kann [STIX Fonts](%1) oder [MathJax TeX Fonts](%2) verwenden. "+ "Herunterladen und installieren dieser Fonts wird Ihre MathJax-Erfahrung verbessern.", //TODO ???? -// "MathJax can use either the %1 or the %2. " + +// "MathJax can use either the [STIX Fonts](%1) or the [MathJax TeX fonts](%2). " + // "Download and install one of those fonts to improve your MathJax experience.", - PageDesigned: - "Diese Seite ist optimiert fuer %1. " + + STIXPage: + "Diese Seite ist optimiert fuer [STIX Fonts](%1). " + "Herunterladen und installieren dieser Fonts wird Ihre MathJax-Erfahrung verbessern.", //TODO ???? // "This page is designed to use the %1. " + // "Download and install those fonts to improve your MathJax experience.", - STIXfonts: - "STIX Fonts", -// "STIX fonts", - - TeXfonts: - "MathJax TeX Fonts" -// "MathJax TeX fonts" + TeXPage: + "Diese Seite ist optimiert fuer [MathJax TeX Fonts](%1). " + + "Herunterladen und installieren dieser Fonts wird Ihre MathJax-Erfahrung verbessern." //TODO ???? +// "This page is designed to use the %1. " + +// "Download and install those fonts to improve your MathJax experience." } }); diff --git a/unpacked/localization/en/FontWarnings.js b/unpacked/localization/en/FontWarnings.js index 97787deb2..ccf216e20 100644 --- a/unpacked/localization/en/FontWarnings.js +++ b/unpacked/localization/en/FontWarnings.js @@ -26,18 +26,17 @@ MathJax.Localization.addTranslation("en","FontWarnings",{ "browsers) could improve the quality of the mathematics on this page.", fonts: - "MathJax can use either the %1 or the %2. " + + "MathJax can use either the [STIX fonts](%1) or the [MathJax TeX fonts](%2). " + "Download and install one of those fonts to improve your MathJax experience.", - PageDesigned: - "This page is designed to use the %1. " + + STIXPage: + "This page is designed to use the [STIX fonts](%1). " + "Download and install those fonts to improve your MathJax experience.", - STIXfonts: - "STIX fonts", + TeXPage: + "This page is designed to use the [MathJax TeX fonts](%1). " + + "Download and install those fonts to improve your MathJax experience." - TeXfonts: - "MathJax TeX fonts" } }); diff --git a/unpacked/localization/fr/FontWarnings.js b/unpacked/localization/fr/FontWarnings.js index ead16dffa..250826b01 100644 --- a/unpacked/localization/fr/FontWarnings.js +++ b/unpacked/localization/fr/FontWarnings.js @@ -31,20 +31,21 @@ MathJax.Localization.addTranslation("fr","FontWarnings",{ "être améliorée.", fonts: - "MathJax peut utiliser les %1 ou bien les %2. Téléchargez et"+ - "installez l'une de ces familles de polices pour améliorer votre"+ + "MathJax peut utiliser les [Polices STIX](%1) ou bien les " + + "[Polices TeX de MathJax](%2). Téléchargez et installez " + + "l'une de ces familles de polices pour améliorer votre "+ "expérience avec MathJax.", - PageDesigned: - "Cette page est conçue pour utiliser les %1. Téléchargez "+ - " et installez ces polices pour améliorer votre expérience "+ - "avec MathJax", + TeXPage: + "Cette page est conçue pour utiliser les [Polices STIX](%1). " + + "Téléchargez et installez ces polices pour améliorer votre " + + "expérience avec MathJax", - STIXfonts: - "Polices STIX", - - TeXfonts: - "Polices TeX de MathJax" + TeXPage: + "Cette page est conçue pour utiliser les [Polices TeX de MathJax](%1). " + + "Téléchargez et installez ces polices pour améliorer votre " + + "expérience avec MathJax" + } });