Implement the general HTML snippets substitution (e.g do the substitution in attributes too) + some small changes.

This commit is contained in:
Frédéric Wang 2013-02-21 13:12:42 +01:00
parent ca2f87ad7c
commit d71498ee25

View File

@ -2682,7 +2682,7 @@ MathJax.Localization = {
if (key in args) { if (key in args) {
if (appendToResult) { if (appendToResult) {
var e = args[key]; var e = args[key];
if (Array.isArray(e)) { if (e instanceof Array) {
// if that's an array, concatenate it to the result array // if that's an array, concatenate it to the result array
resultArray.push(resultString); resultArray.push(resultString);
resultArray = resultArray.concat(e); resultArray = resultArray.concat(e);
@ -2729,7 +2729,7 @@ MathJax.Localization = {
var choiceIndex = choiceFunction(args[key]), j = 1; var choiceIndex = choiceFunction(args[key]), j = 1;
var isChosenBlock = (j === choiceIndex); var isChosenBlock = (j === choiceIndex);
var blockFound = false; var blockFound = isChosenBlock;
while (i < m) { while (i < m) {
if (s[i] == "|") { if (s[i] == "|") {
@ -2811,15 +2811,22 @@ MathJax.Localization = {
function transformHTMLSnippet(snippet) function transformHTMLSnippet(snippet)
{ {
for (key in snippet) { for (var key in snippet) {
var e = snippet[key]; var e = snippet[key];
if (typeof e === "string") { if (typeof e === "string") {
// transform the string content
snippet[key] = transformString(e); snippet[key] = transformString(e);
continue; continue;
} }
var lastIndex = e.length-1; if (e[1]) {
if (Array.isArray(e[lastIndex])) { // transform attribute values
e[lastIndex] = transformHTMLSnippet(e[lastIndex]); for (var key2 in e[1]) {
snippet[key][1][key2] = transformString(e[1][key2]);
}
}
if (e[2]) {
// transform the HTML content
snippet[key][2] = transformHTMLSnippet(e[2]);
} }
} }
return snippet; return snippet;
@ -2831,7 +2838,7 @@ MathJax.Localization = {
if (translationData) { if (translationData) {
if (translationData.isLoaded) { if (translationData.isLoaded) {
var domain = "_"; var domain = "_";
if (Array.isArray(messageId) && messageId.length == 2) { if (messageId instanceof Array && messageId.length == 2) {
domain = messageId[0]; domain = messageId[0];
messageId = messageId[1]; messageId = messageId[1];
} }