├── .gitignore ├── MSI ├── License.rtf ├── MathML-fonts.msi ├── MathML-fonts.wxs └── README.md ├── README.md ├── bug-648548 ├── README.md └── bootstrap.js ├── image-to-mathml ├── README.md ├── data │ ├── LaTeX_Delimiters.js │ ├── LaTeX_NoDelimiters.js │ ├── addRulePanel.html │ ├── addRulePanel.js │ ├── convert.js │ ├── icon16.png │ ├── icon32.png │ └── icon64.png ├── icon.png ├── icon64.png ├── lib │ ├── LaTeXML.js │ ├── Mathematica.js │ ├── main.js │ ├── predefinedRules.js │ └── sanitizer.js ├── locale │ ├── en-US.properties │ ├── fr-FR.properties │ └── pt-BR.properties └── package.json ├── mathml-copy ├── README.md ├── data │ ├── get-annotations.js │ └── get-mathml-source.js ├── lib │ ├── copy-mathml.js │ └── main.js ├── locale │ ├── ar.properties │ ├── de-DE.properties │ ├── en-US.properties │ ├── es-ES.properties │ ├── fr-FR.properties │ ├── hi-IN.properties │ ├── hu-HU.properties │ ├── mr-IN.properties │ ├── pt-BR.properties │ ├── pt-PT.properties │ └── zh-CN.properties └── package.json ├── mathml-ctop ├── .gitignore ├── Makefile ├── README.md ├── config └── src │ ├── bootstrap.js │ ├── chrome.manifest │ └── install.rdf ├── mathml-fonts ├── .gitignore ├── Makefile.in ├── MathML-fonts │ ├── bootstrap.js │ ├── install.rdf │ └── resource │ │ └── mathml.css ├── README.md ├── configure └── configure.ac ├── mathml-fontsettings ├── README.md ├── data │ └── set-style.js ├── lib │ └── main.js ├── locale │ ├── en-US.properties │ ├── fr-FR.properties │ └── pt-BR.properties └── package.json ├── mathml-viewsource ├── README.md ├── data │ ├── get-mathml-source.js │ ├── prism.css │ ├── prism.js │ ├── view-mathml-source.html │ └── view-mathml-source.js ├── index.js ├── locale │ ├── ar.properties │ ├── ast.properties │ ├── cs.properties │ ├── de.properties │ ├── en-GB.properties │ ├── en-US.properties │ ├── eo.properties │ ├── es-AR.properties │ ├── es-CL.properties │ ├── es-ES.properties │ ├── es-MX.properties │ ├── fa.properties │ ├── fr.properties │ ├── fy-NL.properties │ ├── gl.properties │ ├── he.properties │ ├── hu.properties │ ├── id.properties │ ├── it.properties │ ├── ja-JP-mac.properties │ ├── ja.properties │ ├── kk.properties │ ├── ko.properties │ ├── lt.properties │ ├── lv.properties │ ├── nb-NO.properties │ ├── nl.properties │ ├── nn-NO.properties │ ├── pl.properties │ ├── pt-BR.properties │ ├── pt-PT.properties │ ├── ru.properties │ ├── sk.properties │ ├── sl.properties │ ├── sv-SE.properties │ ├── th.properties │ ├── tr.properties │ ├── uk.properties │ ├── vi.properties │ ├── zh-CN.properties │ └── zh-TW.properties └── package.json ├── mathml-zoom ├── README.md ├── data │ ├── zoom.css │ └── zoom.js ├── icon64.png ├── lib │ └── main.js └── package.json ├── mathparser ├── README.md ├── mathparser-base.diff ├── mathparser-dictionary.diff ├── mathparser-itex.diff ├── mathparser-simple.diff ├── mathparser-tests.diff ├── mathparser-utils.diff └── mathzilla-parser.xhtml ├── mathzilla.svg ├── mathzilla ├── README.md ├── data │ ├── ctop.xsl │ └── mathzilla-parser.xhtml ├── lib │ ├── content-to-presentation.js │ ├── copy-mathml.js │ ├── image-to-mathml.js │ └── main.js └── package.json ├── native-mathml ├── README.md ├── data │ ├── bug-fixes.js │ ├── katex.css │ ├── mediawiki.css │ └── menu-cookie.js ├── icon.png ├── icon64.png ├── lib │ └── main.js ├── locale │ ├── ar.properties │ ├── en-US.properties │ ├── fr-FR.properties │ └── pt-BR.properties └── package.json ├── texzilla ├── README.md ├── data │ ├── TeXZilla.js │ ├── index.html │ ├── logo.png │ └── logo.svg ├── lib │ ├── TeXZilla.js │ └── main.js ├── package.json └── test │ └── test-TeXZilla.js └── xpi ├── mathparser-0.1.xpi └── mathzilla-0.1.xpi /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | mathml-fonts/MSI/*.msi 3 | -------------------------------------------------------------------------------- /MSI/MathML-fonts.msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/MSI/MathML-fonts.msi -------------------------------------------------------------------------------- /MSI/README.md: -------------------------------------------------------------------------------- 1 | # MSI 2 | 3 | **This package is no longer maintained. Cambria Math is installed by default on 4 | Windows 7 and higher and is usable with Firefox 31 or higher, so this installer 5 | is becoming obsolete.** 6 | 7 | This directory contains the source of the MathML fonts Windows installer. 8 | Instructions on how to build it are given in `MathML-fonts.wxs`. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mathzilla 2 | 3 | The goal of the Mathzilla Project is to provide add-ons to extend Mozilla 4 | products with new MathML-related features. See the [Mathzilla collection on AMO](https://addons.mozilla.org/collections/fred_wang/mathzilla/). 5 | 6 | **Warning: This directory contains some obsolete or experimental content and is 7 | only kept for historical purpose.** 8 | 9 | The following extensions have been converted to the 10 | [WebExtension](https://developer.mozilla.org/en-US/Add-ons/WebExtensions) format 11 | and are tracked in separate repositories: 12 | 13 | - [Image To MathML](https://github.com/fred-wang/webextension-image-to-mathml) 14 | - [MathML Copy](https://github.com/fred-wang/webextension-mathml-copy) 15 | - [MathML Fonts](https://github.com/fred-wang/MathFonts/tree/master/webextension) 16 | - [MathML Font Settings](https://github.com/fred-wang/webextension-mathml-font-settings) 17 | - [MathML View Source](https://github.com/fred-wang/webextension-mathml-view-source/) 18 | - [MathML Zoom](https://github.com/fred-wang/webextension-mathml-zoom) 19 | - [Native MathML](https://github.com/fred-wang/webextension-native-mathml) 20 | - [Content MathML Polyfill](https://github.com/fred-wang/webextension-content-mathml-polyfill) 21 | - [Presentation MathML Polyfill](https://github.com/fred-wang/webextension-presentation-mathml-polyfill) 22 | - [TeXZilla](https://github.com/fred-wang/TeXZilla/tree/master/webextension) 23 | -------------------------------------------------------------------------------- /bug-648548/README.md: -------------------------------------------------------------------------------- 1 | This was an experimental code to use Windows' API to register fonts. 2 | See also [bug 648548](https://bugzilla.mozilla.org/show_bug.cgi?id=648548) 3 | and the 4 | [MissingFontsNotifier](https://github.com/fred-wang/MissingFontsNotifier). 5 | -------------------------------------------------------------------------------- /bug-648548/bootstrap.js: -------------------------------------------------------------------------------- 1 | const { classes: Cc, interfaces: Ci, utils: Cu } = Components; 2 | 3 | Cu.import("resource://gre/modules/Services.jsm"); 4 | Cu.import("resource://gre/modules/devtools/Console.jsm"); 5 | Cu.import("resource://gre/modules/ctypes.jsm"); 6 | 7 | const kAddonID = "bug-648548@mozilla.org"; 8 | const kFontList = [/* ... */]; 9 | const kRuntime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime); 10 | 11 | function windowsBroadCastFontChange() 12 | { 13 | // These are taken from MinGW-w64 14 | const HWND_BROADCAST = ctypes.voidptr_t(0xFFFF); 15 | const WM_FONTCHANGE = 0x001D; 16 | let libUser32 = ctypes.open("User32.dll"); 17 | let SendMessage = 18 | libUser32.declare("SendMessageA", 19 | ctypes.winapi_abi, 20 | ctypes.long, // LRESULT 21 | ctypes.voidptr_t, // HWND 22 | ctypes.unsigned_int, // UINT 23 | ctypes.int, // WPARAM 24 | ctypes.long // LPARAM 25 | ); 26 | SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); 27 | libUser32.close(); 28 | } 29 | 30 | function windowsRegisterFont(aFontPath) 31 | { 32 | // Add the font resource and broadcast the change. 33 | let libGdi32 = ctypes.open("Gdi32.dll"); 34 | let AddFontResource = 35 | libGdi32.declare("AddFontResourceA", 36 | ctypes.winapi_abi, 37 | ctypes.int, // int 38 | ctypes.char.ptr // LPCTSTR lpszFilename 39 | ); 40 | if (AddFontResource(aFontPath) == 0) { 41 | console.error("Failed to add font resource " + aFontPath); 42 | } 43 | libGdi32.close(); 44 | } 45 | 46 | function windowsUnregisterFont(aFontPath) 47 | { 48 | let libGdi32 = ctypes.open("Gdi32.dll"); 49 | let RemoveFontResource = 50 | libGdi32.declare("RemoveFontResourceA", 51 | ctypes.winapi_abi, 52 | ctypes.int, // BOOL 53 | ctypes.char.ptr // LPCTSTR lpFileName 54 | ); 55 | if (RemoveFontResource(aFontPath) == 0) { 56 | console.error("Failed to remove font resource " + aFontPath); 57 | } 58 | libGdi32.close(); 59 | } 60 | 61 | function getFontsDir() 62 | { 63 | // Ensure there is a fonts/ directory in the profile directory. 64 | let fontsDir = Cc["@mozilla.org/toolkit/profile-service;1"]. 65 | createInstance(Ci.nsIToolkitProfileService). 66 | selectedProfile.localDir.clone(); 67 | fontsDir.appendRelativePath("fonts"); 68 | if (!fontsDir.exists()) { 69 | fontsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0x1ff); 70 | } else { 71 | fontsDir.permissions = 0x1ff; 72 | } 73 | return fontsDir; 74 | } 75 | 76 | function updateFontList() 77 | { 78 | if (kRuntime.OS == "WINNT") { 79 | windowsBroadCastFontChange(); 80 | } 81 | let fonts = Cc["@mozilla.org/gfx/fontenumerator;1"]. 82 | getService(Components.interfaces.nsIFontEnumerator); 83 | fonts.updateFontList(); 84 | } 85 | 86 | function startup(aData, aReason) 87 | { 88 | let fontsDir = getFontsDir(); 89 | 90 | for (var i = 0; i < kFontList.length; i++) { 91 | // Get the path of the file copied to the profile directory. 92 | let profileFontFile = fontsDir.clone(); 93 | profileFontFile.append(kFontList[i]); 94 | 95 | if (aReason == APP_STARTUP) { 96 | if (kRuntime.OS == "WINNT" && profileFontFile.exists()) { 97 | windowsRegisterFont(profileFontFile.path); 98 | } 99 | continue; 100 | } 101 | 102 | // Copy the file from the addon directory to profile directory. 103 | if (!profileFontFile.exists()) { 104 | let addonFontFile = Cc["@mozilla.org/file/directory_service;1"]. 105 | getService(Ci.nsIProperties). 106 | get("ProfD", Ci.nsIFile); 107 | addonFontFile.appendRelativePath("extensions"); 108 | addonFontFile.appendRelativePath(kAddonID); 109 | addonFontFile.append(kFontList[i]); 110 | addonFontFile.copyTo(fontsDir, kFontList[i]); 111 | if (kRuntime.OS == "WINNT") { 112 | windowsRegisterFont(profileFontFile.path); 113 | } 114 | } 115 | } 116 | 117 | updateFontList(); 118 | } 119 | 120 | function shutdown(aData, aReason) 121 | { 122 | let fontsDir = getFontsDir(); 123 | 124 | for (var i = 0; i < kFontList.length; i++) { 125 | 126 | let profileFontFile = fontsDir.clone(); 127 | profileFontFile.append(kFontList[i]); 128 | if (kRuntime.OS == "WINNT" && profileFontFile.exists()) { 129 | windowsUnregisterFont(profileFontFile.path); 130 | } 131 | 132 | if (aReason == APP_SHUTDOWN) { 133 | continue; 134 | } 135 | 136 | // Remove the file from the profile directory. 137 | if (profileFontFile.exists()) { 138 | profileFontFile.remove(true); 139 | } 140 | } 141 | 142 | updateFontList(); 143 | } 144 | 145 | function install() {} 146 | function uninstall() {} 147 | -------------------------------------------------------------------------------- /image-to-mathml/README.md: -------------------------------------------------------------------------------- 1 | # Image to MathML 2 | 3 | This directory contains the source of the [Image to MathML add-on](https://addons.mozilla.org/en-US/firefox/addon/image-to-mathml/) which is 4 | built with the [Add-on SDK](https://developer.mozilla.org/en-US/Add-ons/SDK). 5 | 6 | Users should report any bug to the 7 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 8 | 9 | Localizers should look at the `locale/` directory. To add a new translation, 10 | copy `en-US.properties` to another `*.properties` with the appropriate 11 | [Locale Code](https://wiki.mozilla.org/L10n:Locale_Codes). Please check the 12 | [GitHub Localization issue](https://github.com/fred-wang/Mathzilla/issues/17). 13 | -------------------------------------------------------------------------------- /image-to-mathml/data/LaTeX_Delimiters.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // See LaTeX_Delimiters in locale/en-US.properties and lib/predefinedRules.js 10 | // for a description of this script and its options. 11 | 12 | var options = JSON.parse(self.options); 13 | 14 | self.port.on("convert-images", function () { 15 | var images = document.body.querySelectorAll(options.selectors), 16 | i, img, alt, m; 17 | for (i = 0; i < images.length; i++) { 18 | img = images[i]; alt = img.alt; 19 | if ((m = alt.match(/^\s*\$\$([^]+)\$\$\s*$/)) || 20 | (m = alt.match(/^\s*\\\[([^]+)\\\]\s*$/)) || 21 | (m = 22 | alt.match(/^\s*\\begin{displaymath}([^]+)\\end{displaymath}\s*$/))) { 23 | // Display equations 24 | fromLaTeXRequest(img, options.preloadList, m[1], function(aMath) { 25 | if (options.useDisplayAttribute) { 26 | aMath.setAttribute("display", "block"); 27 | } else { 28 | aMath.setAttribute("displaystyle", "true"); 29 | } 30 | }); 31 | } else if ((m = alt.match(/^\s*\$([^]+)\$\s*$/)) || 32 | (m = alt.match(/^\s*\\\(([^]+)\\\)\s*$/))) { 33 | // Inline equations 34 | fromLaTeXRequest(img, options.preloadList, m[1], null); 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /image-to-mathml/data/LaTeX_NoDelimiters.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // See LaTeX_NoDelimiters in locale/en-US.properties and lib/predefinedRules.js 10 | // for a description of this script and its options. 11 | 12 | var options = JSON.parse(self.options); 13 | 14 | self.port.on("convert-images", function () { 15 | var images, i, img; 16 | if (options.selectorsNone !== "") { 17 | images = document.body.querySelectorAll(options.selectorsNone); 18 | for (i = 0; i < images.length; i++) { 19 | img = images[i]; 20 | fromLaTeXRequest(img, options.preloadList, img.alt, null); 21 | } 22 | } 23 | if (options.selectorsInlineDisplayStyle !== "") { 24 | images = document.body.querySelectorAll(options. 25 | selectorsInlineDisplayStyle); 26 | for (i = 0; i < images.length; i++) { 27 | img = images[i]; 28 | fromLaTeXRequest(img, options.preloadList, img.alt, function(aMath) { 29 | aMath.setAttribute("displaystyle", "true"); 30 | }); 31 | } 32 | } 33 | if (options.selectorsDisplay !== "") { 34 | images = document.body.querySelectorAll(options.selectorsDisplay); 35 | for (i = 0; i < images.length; i++) { 36 | img = images[i]; 37 | fromLaTeXRequest(img, options.preloadList, img.alt, function(aMath) { 38 | aMath.setAttribute("display", "block"); 39 | }); 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /image-to-mathml/data/addRulePanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 36 | 37 | 38 | 39 |
40 |
41 |
42 | icon64 43 |
44 |
45 |

46 | 47 |
48 |
49 | 50 |
51 |
52 |
53 |
54 | 55 |
56 |

57 | 58 |
59 |
60 | 61 |
62 |
63 | 64 |
65 |

66 |
67 |
68 |
69 | 70 |
71 | 72 | 73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /image-to-mathml/data/addRulePanel.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | var scripts, selectedScript; 10 | 11 | function urlPatternChanged() 12 | { 13 | var pattern = document.getElementById("urlPattern"); 14 | document.getElementById("OKButton").disabled = (pattern.value === ""); 15 | document.getElementById("DeleteButton").disabled = true; 16 | if (pattern.value !== "") { 17 | self.port.emit("get-rule-data", pattern.value); 18 | } 19 | } 20 | 21 | function selectedScriptChanged(aData) 22 | { 23 | console.log("xxxxx"+aData); 24 | var i, s, options, o; 25 | 26 | // Get the selected script 27 | if (aData) { 28 | i = 0; 29 | for (s in scripts) { 30 | if (s === aData.Script) { 31 | break; 32 | } 33 | i++; 34 | } 35 | document.getElementById("scriptSelect").selectedIndex = i; 36 | } else { 37 | i = document.getElementById("scriptSelect").selectedIndex; 38 | for (s in scripts) { 39 | if (i == 0) { 40 | break; 41 | } 42 | i--; 43 | } 44 | } 45 | selectedScript = s; 46 | s = scripts[selectedScript]; 47 | document.getElementById("infoScript").textContent = s.description; 48 | 49 | // Set the options 50 | var refOption = document.getElementById("refOption"); 51 | while (refOption.nextElementSibling) { 52 | refOption.parentNode.removeChild(refOption.nextElementSibling); 53 | } 54 | for (o in s.ScriptOptions) { 55 | var option = s.ScriptOptions[o]; 56 | var value = option.value; 57 | if (aData) { 58 | value = aData.ScriptOptions[o]; 59 | } 60 | var newOption = refOption.cloneNode(true); 61 | newOption.removeAttribute("id"); 62 | var label = newOption.getElementsByTagName("label")[0]; 63 | label.setAttribute("for", o); 64 | label.textContent = option.title; 65 | newOption.getElementsByClassName("infoOption")[0].textContent = 66 | option.description; 67 | var input = newOption.getElementsByTagName("input")[0]; 68 | input.setAttribute("id", o); 69 | if (option.type === "bool") { 70 | input.type = "checkbox"; 71 | input.checked = value; 72 | } else if (option.type === "string") { 73 | input.type = "text"; 74 | input.value = value; 75 | } else { 76 | throw "Unknown option type: " + option.type; 77 | } 78 | refOption.parentNode.appendChild(newOption); 79 | } 80 | } 81 | 82 | function submitRule() 83 | { 84 | var s = scripts[selectedScript]; 85 | var json = { 86 | URLPattern: document.getElementById("urlPattern").value, 87 | Script: selectedScript, 88 | ScriptOptions: {} 89 | }; 90 | for (var o in s.ScriptOptions) { 91 | var input = document.getElementById(o); 92 | var option = s.ScriptOptions[o]; 93 | if (option.type === "bool") { 94 | json.ScriptOptions[o] = input.checked; 95 | } else if (option.type === "string") { 96 | json.ScriptOptions[o] = input.value; 97 | } else { 98 | throw "Unknown option type: " + option.type; 99 | } 100 | } 101 | self.port.emit("update-rule", json); 102 | } 103 | 104 | self.port.on("send-main-data", function (aData) { 105 | scripts = aData.scripts; 106 | 107 | var local = aData.local, s, i, selectElement, selectChild; 108 | 109 | // Set the document direction. 110 | document.body.setAttribute("dir", aData.dir); 111 | 112 | // Localize the labels. 113 | for (s in local) { 114 | var elements = document.getElementsByClassName(s); 115 | for (i = 0; i < elements.length; i++) { 116 | elements[i].textContent = local[s]; 117 | } 118 | } 119 | 120 | // Set the default URL pattern. 121 | var urlPattern = document.getElementById("urlPattern"); 122 | urlPattern.value = aData.urlPattern; 123 | urlPattern.addEventListener("change", urlPatternChanged); 124 | urlPatternChanged(); 125 | 126 | // Set the predefined script list. 127 | selectElement = document.getElementById("scriptSelect"); 128 | selectChild = selectElement.firstElementChild; 129 | for (s in scripts) { 130 | if (!selectChild) { 131 | selectChild = document.createElement("option"); 132 | selectElement.appendChild(selectChild); 133 | } 134 | selectChild.textContent = scripts[s].title; 135 | selectChild = selectChild.nextElementSibling; 136 | } 137 | selectElement.addEventListener("change", function () { 138 | selectedScriptChanged(null); 139 | }); 140 | selectedScriptChanged(null); 141 | 142 | // Event for the cancel, OK and delete buttons. 143 | document.getElementById("CancelButton").addEventListener("click", 144 | function() { self.port.emit("cancel"); } 145 | ); 146 | document.getElementById("OKButton").addEventListener("click", submitRule); 147 | document.getElementById("DeleteButton").addEventListener("click", 148 | function() { 149 | self.port.emit("delete-rule", 150 | document.getElementById("urlPattern").value); 151 | } 152 | ); 153 | }); 154 | 155 | self.port.on("send-rule-data", function (aData) { 156 | var pattern = document.getElementById("urlPattern").value; 157 | if (aData.URLPattern !== pattern || !aData.Script) { 158 | return; 159 | } 160 | aData.ScriptOptions = JSON.parse(aData.ScriptOptions); 161 | 162 | // The rule data has been found, enable the button. 163 | document.getElementById("DeleteButton").disabled = false; 164 | 165 | // Select the script 166 | selectedScriptChanged(aData) 167 | }); 168 | -------------------------------------------------------------------------------- /image-to-mathml/data/convert.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // Associative array indexed by the LaTeX source. The elements are arrays of 10 | // JSON objects 11 | // 12 | // { image: ..., 13 | // callback: function(aMath) { ... } } 14 | // 15 | // where image is the element to convert into a element and the 16 | // callback function takes the resulting element as argument. 17 | let pendingFromLaTeXRequest = {}; 18 | 19 | // Send a request to convert LaTeX to MathML. 20 | function fromLaTeXRequest(aImage, aPreloadList, aLaTeX, aCallback) { 21 | if (aLaTeX === "") { 22 | // Do nothing if the source is empty 23 | return; 24 | } 25 | var data = { image: aImage, callback: aCallback }; 26 | if (pendingFromLaTeXRequest[aLaTeX]) { 27 | // The same request has already been sent in a previous call. Let's add this 28 | // to the array of JSON objects. 29 | pendingFromLaTeXRequest[aLaTeX].push(data); 30 | } else { 31 | // Create a one-element array and send a new request. 32 | pendingFromLaTeXRequest[aLaTeX] = [data]; 33 | self.port.emit("fromLaTeX-request", aPreloadList, aLaTeX); 34 | } 35 | } 36 | 37 | // Handle the fromLaTeX response. 38 | self.port.on("fromLaTeX-response", function (aResponse) { 39 | var JSONarray, data, previous, parent, i; 40 | if (aResponse.output) { 41 | // Conversion succeeded. Replace all the images by elements. 42 | JSONarray = pendingFromLaTeXRequest[aResponse.input]; 43 | for (i = 0; i < JSONarray.length; i++) { 44 | data = JSONarray[i]; 45 | previous = data.image.previousElementSibling; 46 | parent = data.image.parentNode; 47 | data.image.outerHTML = aResponse.output; 48 | if (data.callback) { 49 | // Execute the callback to do some postprocessing on the tag. 50 | data.callback(previous ? 51 | previous.nextElementSibling : parent.firstElementChild); 52 | } 53 | } 54 | } 55 | // Remove this request. 56 | delete pendingFromLaTeXRequest[aResponse.input]; 57 | }); 58 | -------------------------------------------------------------------------------- /image-to-mathml/data/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/image-to-mathml/data/icon16.png -------------------------------------------------------------------------------- /image-to-mathml/data/icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/image-to-mathml/data/icon32.png -------------------------------------------------------------------------------- /image-to-mathml/data/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/image-to-mathml/data/icon64.png -------------------------------------------------------------------------------- /image-to-mathml/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/image-to-mathml/icon.png -------------------------------------------------------------------------------- /image-to-mathml/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/image-to-mathml/icon64.png -------------------------------------------------------------------------------- /image-to-mathml/lib/LaTeXML.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // This module communicates with the LaTeXML Web service. 10 | 11 | var Request = require("sdk/request").Request, 12 | simplePrefs = require('sdk/simple-prefs'), 13 | prefs = simplePrefs.prefs, 14 | sanitizer = require("sanitizer"); 15 | 16 | function generatePreloadComponents(aPreloadList) 17 | { 18 | var components = ""; 19 | var list = aPreloadList.split(",").map(function(value) { 20 | components += "&preload=" + encodeURIComponent(value); 21 | }); 22 | return components; 23 | } 24 | 25 | // Determine the URL for the POST request. 26 | function getLaTeXMLUrl(aPreloadList, aLaTeX) 27 | { 28 | var url = prefs.LaTeXMLUrl; 29 | url += "?format=xhtml&whatsin=math&whatsout=math&pmml&nodefaultresources"; 30 | url += generatePreloadComponents(prefs.LaTeXMLPreload); 31 | url += generatePreloadComponents(aPreloadList); 32 | url += "&tex=" + encodeURIComponent(aLaTeX); 33 | return url; 34 | } 35 | 36 | // Send the LaTeXML request. 37 | function sendLaTeXMLRequest(aDatabase, aWorker, aPreloadList, aLaTeX, aCallback, 38 | aMaxAttempts) { 39 | Request({ 40 | url: getLaTeXMLUrl(aPreloadList, aLaTeX), 41 | onComplete: function (aResponse) { 42 | var json = aResponse.json; 43 | if (!json || !json.result) { 44 | // Conversion failed. Either we try again or we give up and submit an 45 | // empty reply. 46 | if (aMaxAttempts > 0) { 47 | sendLaTeXMLRequest(aDatabase, aWorker, aPreloadList, aLaTeX, 48 | aCallback, aMaxAttempts - 1); 49 | return; 50 | } 51 | console.warn("LaTeXML failed to convert '" + aLaTeX + "'\n" + 52 | aResponse.text); 53 | json = {}; 54 | } else { 55 | json.result = sanitizer.sanitize(json.result); 56 | if (prefs.LaTeXMLCache) { 57 | // Cache the sanitized result. 58 | aDatabase.putMathML("LaTeXML", aLaTeX, json.result); 59 | } 60 | } 61 | aCallback({ input: aLaTeX, output: json.result }); 62 | } 63 | }).post(); 64 | } 65 | 66 | // Public LaTeXML.fromLaTeX function. 67 | exports.fromLaTeX = function(aDatabase, aWorker, aPreloadList, aLaTeX, 68 | aCallback) { 69 | // Try to get the MathML from the cache. 70 | aDatabase.getMathML("LaTeXML", aLaTeX, function(aMathML) { 71 | if (prefs.LaTeXMLCache && aMathML) { 72 | aCallback({ input: aLaTeX, output: aMathML}); 73 | } else { 74 | sendLaTeXMLRequest(aDatabase, aWorker, aPreloadList, aLaTeX, aCallback, 75 | prefs.LaTeXMLMaxAttempts); 76 | } 77 | }); 78 | }; 79 | -------------------------------------------------------------------------------- /image-to-mathml/lib/Mathematica.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // This module communicates with the Mathematica Web service. 10 | 11 | // Public Mathematica.fromMathematica function. 12 | exports.fromMathematica = function(aDatabase, aWorker, aMathematica, 13 | aCallback) { 14 | // Try to get the MathML from the cache. 15 | aDatabase.getMathML("Mathematica", aMathematica, function(aMathML) { 16 | if (prefs["MathematicaCache"] && aMathML) { 17 | aCallback({ input: aMathematica, output: aMathML}); 18 | } else { 19 | // FIXME: this is not implemented yet. 20 | aCallback({ input: aMathematica}); 21 | } 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /image-to-mathml/lib/main.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | var selfData = require("sdk/self").data, 10 | pageMod = require("sdk/page-mod"), 11 | simplePrefs = require('sdk/simple-prefs'), 12 | prefs = simplePrefs.prefs, 13 | LaTeXML = require("./LaTeXML"), 14 | { indexedDB } = require('sdk/indexed-db'), 15 | { predefinedRules, predefinedScripts, 16 | localizePredefinedScripts } = require("./predefinedRules"), 17 | _ = require("sdk/l10n").get, 18 | tabs = require('sdk/tabs'), 19 | url = require('sdk/url'); 20 | 21 | var database = { version: 1 }; 22 | var activePageMods = {}; 23 | 24 | function onAttach(aWorker) 25 | { 26 | // LaTeX-to-MathML conversion. 27 | aWorker.port.on("fromLaTeX-request", function(aPreloadList, aLaTeX) { 28 | LaTeXML.fromLaTeX(database, aWorker, aPreloadList, aLaTeX, 29 | function(aJSON) { 30 | aWorker.port.emit("fromLaTeX-response", aJSON); 31 | }); 32 | }); 33 | 34 | // Mathematica-to-MathML conversion. 35 | aWorker.port.on("fromMathematica-request", function(aMathematica) { 36 | Mathematical.fromMathematica(database, aWorker, aMathematica, 37 | function(aJSON) { 38 | aWorker.port.emit("fromMathematica-response", aJSON); 39 | }); 40 | }); 41 | 42 | // Ask the worker script to convert all images into MathML. 43 | aWorker.port.emit("convert-images"); 44 | } 45 | 46 | function addPageMod(aURLPatternList, aScript, aScriptOptions) 47 | { 48 | var p = pageMod.PageMod({ 49 | include: aURLPatternList, 50 | contentScriptFile: [ 51 | selfData.url("convert.js"), 52 | selfData.url(aScript + ".js") 53 | ], 54 | contentScriptOptions: aScriptOptions, 55 | onAttach: onAttach, 56 | attachTo: ["existing", "top", "frame"] 57 | }); 58 | for (var i = 0; i < aURLPatternList.length; i++) { 59 | activePageMods[aURLPatternList[i]] = p; 60 | } 61 | } 62 | 63 | function removeURLPatternFromPageMod(aURLPattern) 64 | { 65 | // Remove the url from the page mod. 66 | activePageMods[aURLPattern].include.remove(aURLPattern); 67 | if (activePageMods[aURLPattern].include.length === 0) { 68 | // The page mod is empty so we destroy it. 69 | activePageMods[aURLPattern].destroy(); 70 | } 71 | } 72 | 73 | // Initialize a database to store the page mod and cache the MathML output. 74 | database.onerror = function(e) { 75 | console.error(e.value); 76 | } 77 | var request = indexedDB.open("ImageToMathML", database.version); 78 | request.onerror = database.onerror; 79 | request.onupgradeneeded = function(e) { 80 | var db, store; 81 | db = e.target.result; 82 | e.target.transaction.onerror = database.onerror; 83 | 84 | // Initialize the database with a set of predefined rules. 85 | if(db.objectStoreNames.contains("PageMod")) { 86 | db.deleteObjectStore("PageMod"); 87 | } 88 | store = db.createObjectStore("PageMod", { keyPath: "URLPattern" }); 89 | store.createIndex("byConversionMethod", 90 | ["Script", "ScriptOptions"], { unique: false }); 91 | store.transaction.oncomplete = function(e) { 92 | var request, objectStore, i, j, patternList, script, scriptoptions; 93 | objectStore = db.transaction("PageMod", "readwrite").objectStore("PageMod"); 94 | for (i = 0; i < predefinedRules.length; i++) { 95 | // It seems that script option must be a string or this item won't 96 | // be listed in index.openCursor(). It will be stringified to be passed 97 | // to the worker scripts anyway. 98 | scriptoptions = JSON.stringify(predefinedRules[i].ScriptOptions); 99 | patternList = predefinedRules[i].URLPatternList; 100 | for (j = 0; j < patternList.length; j++) { 101 | request = objectStore.add({ 102 | URLPattern: patternList[j], 103 | Script: predefinedRules[i].Script, 104 | ScriptOptions: scriptoptions 105 | }); 106 | request.onerror = database.onerror; 107 | } 108 | } 109 | } 110 | 111 | // Create empty stores to cache the MathML output. 112 | if(db.objectStoreNames.contains("LaTeXML")) { 113 | db.deleteObjectStore("LaTeXML"); 114 | } 115 | db.createObjectStore("LaTeXML"); 116 | if(db.objectStoreNames.contains("Mathematica")) { 117 | db.deleteObjectStore("Mathematica"); 118 | } 119 | db.createObjectStore("Mathematica"); 120 | } 121 | request.onsuccess = function(e) { 122 | database.db = e.target.result; 123 | 124 | // Read all the entries from the database and create the 125 | // corresponding Page Mod. 126 | var store = database.db.transaction("PageMod").objectStore("PageMod"); 127 | var index = store.index("byConversionMethod"); 128 | var pageModInclude = [], pageModKey = {}; 129 | index.openCursor().onsuccess = function(e) { 130 | var cursor = e.target.result; 131 | if (cursor) { 132 | if (pageModKey.Script === cursor.value.Script && 133 | pageModKey.ScriptOptions === cursor.value.ScriptOptions) { 134 | pageModInclude.push(cursor.value.URLPattern); 135 | cursor.continue(); 136 | return; 137 | } 138 | } 139 | 140 | if (pageModInclude.length > 0) { 141 | addPageMod(pageModInclude, pageModKey.Script, pageModKey.ScriptOptions); 142 | } 143 | 144 | if (cursor) { 145 | pageModInclude = [cursor.value.URLPattern]; 146 | pageModKey.Script = cursor.value.Script; 147 | pageModKey.ScriptOptions = cursor.value.ScriptOptions; 148 | cursor.continue(); 149 | } 150 | }; 151 | }; 152 | 153 | // Update a PageMod. 154 | database.putPageMod = function(aURLPattern, aScript, aScriptOptions) { 155 | var store = database.db. 156 | transaction(["PageMod"], "readwrite").objectStore("PageMod"); 157 | var request = store.put({ 158 | URLPattern: aURLPattern, 159 | Script: aScript, 160 | ScriptOptions: JSON.stringify(aScriptOptions) 161 | }); 162 | request.onerror = database.onerror; 163 | }; 164 | 165 | // Get the pageMod 166 | database.getPageMod = function(aURLPattern, aCallback) { 167 | var json = { URLPattern: aURLPattern }; 168 | if (!this.db) { 169 | aCallback(json); 170 | } 171 | var store = this.db. 172 | transaction(["PageMod"], "readwrite").objectStore("PageMod"); 173 | var request = store.get(aURLPattern); 174 | request.onerror = function() { 175 | database.onerror(); 176 | aCallback(json); 177 | }; 178 | request.onsuccess = function() { 179 | aCallback(request.result ? request.result : json); 180 | }; 181 | }; 182 | 183 | // Delete the pageMod 184 | database.deletePageMod = function(aURLPattern) { 185 | if (this.db) { 186 | var store = this.db. 187 | transaction(["PageMod"], "readwrite").objectStore("PageMod"); 188 | store.delete(aURLPattern); 189 | } 190 | }; 191 | 192 | // Clear the MathML cache 193 | database.clearMathMLCache = function(aStore) { 194 | if (this.db) { 195 | this.db.transaction([aStore], "readwrite").objectStore(aStore).clear(); 196 | } 197 | } 198 | simplePrefs.on("LaTeXMLCache", function() { 199 | if (!prefs["LaTeXMLCache"]) { 200 | database.clearMathMLCache("LaTeXML"); 201 | } 202 | }); 203 | 204 | // Update the MathML cache 205 | database.putMathML = function(aStore, aSource, aMathML) { 206 | if (this.db) { 207 | var store = this.db. 208 | transaction([aStore], "readwrite").objectStore(aStore); 209 | var request = store.put(aMathML, aSource); 210 | request.onerror = this.onerror; 211 | } 212 | }; 213 | 214 | // Try and get the MathML cache 215 | database.getMathML = function(aStore, aSource, aCallback) { 216 | if (!this.db) { 217 | aCallback(null); 218 | } 219 | var store = this.db. 220 | transaction([aStore], "readwrite").objectStore(aStore); 221 | var request = store.get(aSource); 222 | request.onerror = function() { 223 | database.onerror(); 224 | aCallback(null); 225 | }; 226 | request.onsuccess = function() { 227 | aCallback(request.result); 228 | }; 229 | }; 230 | 231 | //////////////////////////////////////////////////////////////////////////////// 232 | var addRulePanelLocal = { 233 | addRule: null, 234 | deleteRule: null, 235 | urlPatternLabel: null, 236 | scriptLabel: null, 237 | Cancel: null, 238 | OK: null, 239 | } 240 | function addRulePanelLocalize() { 241 | for (var key in addRulePanelLocal) { 242 | addRulePanelLocal[key] = _("addRulePanel_" + key); 243 | } 244 | } 245 | 246 | var addRulePanel = require("sdk/panel").Panel({ 247 | contentURL: selfData.url("addRulePanel.html"), 248 | contentScriptFile: selfData.url("addRulePanel.js"), 249 | }); 250 | 251 | require("sdk/ui/button/action").ActionButton({ 252 | id: "addRulePanel", 253 | label: _("addRulePanel_addRule"), 254 | icon: { 255 | "16": "./icon16.png", 256 | "32": "./icon32.png", 257 | "64": "./icon64.png" 258 | }, 259 | onClick: function(aState) { 260 | var urlPattern = ""; 261 | var currentURL = url.URL(tabs.activeTab.url); 262 | if (currentURL.host) { 263 | urlPattern = currentURL.scheme + "://" + currentURL.host + "/*"; 264 | } 265 | localizePredefinedScripts(); 266 | addRulePanelLocalize(); 267 | addRulePanel.port.emit("send-main-data", { 268 | dir: _("addRulePanel_dir"), 269 | local: addRulePanelLocal, 270 | scripts: predefinedScripts, 271 | urlPattern: urlPattern 272 | }); 273 | addRulePanel.show({ 274 | width: 600, 275 | height: 600, 276 | }); 277 | } 278 | }); 279 | 280 | addRulePanel.port.on("cancel", function() { 281 | addRulePanel.hide(); 282 | }); 283 | 284 | addRulePanel.port.on("update-rule", function(aJSON) { 285 | database.putPageMod(aJSON.URLPattern, aJSON.Script, aJSON.ScriptOptions); 286 | if (activePageMods.hasOwnProperty(aJSON.URLPattern)) { 287 | // Remove the url from the previous page mod. 288 | removeURLPatternFromPageMod(aJSON.URLPattern); 289 | } 290 | addPageMod([aJSON.URLPattern], aJSON.Script, 291 | JSON.stringify(aJSON.ScriptOptions)); 292 | 293 | addRulePanel.hide(); 294 | }); 295 | 296 | addRulePanel.port.on("delete-rule", function(aURLPattern) { 297 | database.deletePageMod(aURLPattern); 298 | removeURLPatternFromPageMod(aURLPattern); 299 | addRulePanel.hide(); 300 | }); 301 | 302 | addRulePanel.port.on("get-rule-data", function(aURLPattern) { 303 | database.getPageMod(aURLPattern, function(aRuleData) { 304 | addRulePanel.port.emit("send-rule-data", aRuleData); 305 | }); 306 | }); 307 | -------------------------------------------------------------------------------- /image-to-mathml/lib/predefinedRules.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | var _ = require("sdk/l10n").get; 10 | 11 | exports.predefinedScripts = { 12 | "LaTeX_NoDelimiters": { 13 | ScriptOptions: { 14 | selectorsInline: { 15 | type: "string", 16 | value: "" 17 | }, 18 | selectorsInlineDisplayStyle: { 19 | type: "string", 20 | value: "img" 21 | }, 22 | selectorsDisplay: { 23 | type: "string", 24 | value: "" 25 | }, 26 | preloadList: { 27 | type: "string", 28 | value: "" 29 | } 30 | } 31 | }, 32 | "LaTeX_Delimiters": { 33 | ScriptOptions: { 34 | selectors: { 35 | type: "string", 36 | value: "img" 37 | }, 38 | useDisplayAttribute: { 39 | type: "bool", 40 | value: true 41 | }, 42 | preloadList: { 43 | type: "string", 44 | value: "" 45 | } 46 | } 47 | } 48 | } 49 | 50 | // Add localized members to the predefined scripts. 51 | exports.localizePredefinedScripts = function() { 52 | for (var script in exports.predefinedScripts) { 53 | exports.predefinedScripts[script].title = _(script + "_title"); 54 | exports.predefinedScripts[script].description = _(script + "_description"); 55 | for (var option in exports.predefinedScripts[script].ScriptOptions) { 56 | exports.predefinedScripts[script].ScriptOptions[option].title = 57 | _(script + "_option_" + option + "_title"); 58 | exports.predefinedScripts[script].ScriptOptions[option].description = 59 | _(script + "_option_" + option + "_description"); 60 | } 61 | } 62 | }; 63 | 64 | //////////////////////////////////////////////////////////////////////////////// 65 | exports.predefinedRules = [ 66 | { 67 | // WordPress LaTeX plugin 68 | // See http://en.support.wordpress.com/latex/ 69 | Script: "LaTeX_NoDelimiters", 70 | ScriptOptions: { 71 | selectorsInlineDisplayStyle: "img.latex" 72 | }, 73 | URLPatternList: [ 74 | "http://en.support.wordpress.com/latex/", 75 | "https://collegemathteaching.wordpress.com/*" 76 | ] 77 | }, 78 | { 79 | // Images generated by texvc. 80 | // See https://www.mediawiki.org/wiki/Texvc 81 | Script: "LaTeX_NoDelimiters", 82 | ScriptOptions: { 83 | selectorsInlineDisplayStyle: "img.tex", 84 | preloadList: "texvc" 85 | }, 86 | URLPatternList: [ 87 | "*.wikipedia.org", 88 | "http://en.academic.ru/dic.nsf/enwiki/*" 89 | ] 90 | }, 91 | { 92 | // Images generated by gladTeX. 93 | Script: "LaTeX_NoDelimiters", 94 | ScriptOptions: { 95 | selectorsInline: ".inline_eqn > img", 96 | selectorsInlineDisplayStyle: ".display_eqn > img" 97 | }, 98 | URLPatternList: "http://myphysicslab.com/*" 99 | }, 100 | { 101 | // Spip 102 | // See http://www.spip.net/en_article3563.html 103 | Script: "LaTeX_NoDelimiters", 104 | ScriptOptions: { 105 | selectorsInlineDisplayStyle: ".spip img" 106 | }, 107 | URLPatternList: "http://www.spip.net/*" 108 | }, 109 | { 110 | Script: "LaTeX_Delimiters", 111 | URLPatternList: "http://www.les-mathematiques.net/*" 112 | } 113 | ]; 114 | 115 | // Transform exports.predefinedRules into a canonical form. 116 | for (var i = 0; i < exports.predefinedRules.length; i++) { 117 | 118 | // Make URLPatternList an array. 119 | var patternList = exports.predefinedRules[i].URLPatternList; 120 | if (typeof patternList === "string") { 121 | exports.predefinedRules[i].URLPatternList = [patternList]; 122 | } 123 | 124 | // Use the default option values if they are not specified. 125 | if (!exports.predefinedRules[i].ScriptOptions) { 126 | exports.predefinedRules[i].ScriptOptions = {}; 127 | } 128 | var script = exports.predefinedRules[i].Script; 129 | var options = exports.predefinedScripts[script].ScriptOptions; 130 | for (var option in options) { 131 | if (!exports.predefinedRules[i].ScriptOptions.hasOwnProperty(option)) { 132 | exports.predefinedRules[i].ScriptOptions[option] = options[option].value; 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /image-to-mathml/lib/sanitizer.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | // This module sanitizes a HTML string 10 | 11 | var {Cc, Ci} = require("chrome"); 12 | var gParserUtils = 13 | Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils); 14 | 15 | exports.sanitize = function(aSource) { 16 | return gParserUtils.sanitize(aSource, 17 | gParserUtils.SanitizerAllowStyle | 18 | gParserUtils.SanitizerDropNonCSSPresentation | 19 | gParserUtils.SanitizerDropForms | 20 | gParserUtils.SanitizerDropMedia); 21 | }; 22 | -------------------------------------------------------------------------------- /image-to-mathml/locale/en-US.properties: -------------------------------------------------------------------------------- 1 | # Preference Menu 2 | LaTeXMLUrl_title = URL of LaTeXML Web service 3 | LaTeXMLUrl_description = This preference contains the URL of the LaTeXML Web service to use for the LaTeX to MathML conversion. 4 | LaTeXMLPreload_title = LaTeXML preload list 5 | LaTeXMLPreload_description = Default preload list to pass to the LaTeXML server. 6 | LaTeXMLMaxAttempts_title = Maximum number of attempts for LaTeXML 7 | LaTeXMLMaxAttempts_description = The LaTeXML Web service may fail to convert the LaTeX input due to networking issue. This allows specifying a maximum number of attempts for each mathematical formula before giving up. 8 | LaTeXMLCache_title = Cache LaTeXML output 9 | LaTeXMLCache_description = If this option is enabled, the add-on will cache the MathML output returned by LaTeXML. Note that disabling this option will clear the current cache. 10 | 11 | # Predefined Scripts 12 | # Note: "displaystyle" and "display" are LaTeX/MathML terms. 13 | LaTeX_Delimiters_title = LaTeX with delimiters 14 | LaTeX_Delimiters_description = This script handles the case where images have LaTeX source with delimiters as alt text and can be enumerated by a list of CSS selectors. 15 | LaTeX_Delimiters_option_selectors_title = CSS Selectors 16 | LaTeX_Delimiters_option_selectors_description = A comma-separated list of CSS selectors to enumerate the img tags to convert. 17 | LaTeX_Delimiters_option_useDisplayAttribute_title = Use the display attribute 18 | LaTeX_Delimiters_option_useDisplayAttribute_description = If this option is enabled, mathematical formulas with display delimiters will get attribute display="true". Otherwise, they will only get attribute displaystyle="true". 19 | LaTeX_Delimiters_option_preloadList_title = LaTeXML Preload list 20 | LaTeX_Delimiters_option_preloadList_description = Preload list to pass to the LaTeXML server. 21 | # Note: "inline", "display" and "display style" are LaTeX/MathML terms. 22 | LaTeX_NoDelimiters_title = LaTeX without delimiters 23 | LaTeX_NoDelimiters_description = This script handles the case where images have LaTeX source without delimiters as alt text and can be enumerated by a list of CSS selectors. 24 | LaTeX_NoDelimiters_option_selectorsInline_title = CSS Selectors for inline equations 25 | LaTeX_NoDelimiters_option_selectorsInline_description = A comma-separated list of CSS selectors to enumerate the img tags to convert into inline equations. 26 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_title = CSS Selectors for inline equations in display style 27 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_description = A comma-separated list of CSS selectors to enumerate the img tags to convert into inline equations in display style. 28 | LaTeX_NoDelimiters_option_selectorsDisplay_title = CSS Selectors for display equations 29 | LaTeX_NoDelimiters_option_selectorsDisplay_description = A comma-separated list of CSS selectors to enumerate the img tags to convert into display equations. 30 | LaTeX_NoDelimiters_option_preloadList_title = LaTeXML Preload list 31 | LaTeX_NoDelimiters_option_preloadList_description = Preload list to pass to the LaTeXML server. 32 | 33 | # addRulePanel dialog 34 | addRulePanel_dir = ltr # This should be "ltr" or "rlt" according to the language directionality. 35 | addRulePanel_addRule = Add an Image to MathML rule 36 | addRulePanel_deleteRule = Delete the rule 37 | addRulePanel_urlPatternLabel = URL Pattern 38 | addRulePanel_scriptLabel = Script 39 | addRulePanel_Cancel = Cancel 40 | addRulePanel_OK = OK 41 | -------------------------------------------------------------------------------- /image-to-mathml/locale/fr-FR.properties: -------------------------------------------------------------------------------- 1 | # Preference Menu 2 | LaTeXMLUrl_title = URL du service Web LaTeXML 3 | LaTeXMLUrl_description = Cette option contient l'URL du service Web LaTeXML à utuliser pour la conversion de LaTeX vers MathML. 4 | LaTeXMLPreload_title = Liste de préchargement de LaTeXML 5 | LaTeXMLPreload_description = Liste de préchargement par défault passée au serveur LaTeXML. 6 | LaTeXMLMaxAttempts_title = Nombre maximum de tentatives pour LaTeXML 7 | LaTeXMLMaxAttempts_description = Le service Web LaTeXML peut ne pas convertir l'entrée LaTeX à cause de problème de réseau. Cette option permet de spécifier le nombre maximum de tentatives pour chaque formule mathématique avant d'abandonner. 8 | LaTeXMLCache_title = Cacher la sortie LaTeXML 9 | LaTeXMLCache_description = Si cette option est activée, l'extension utilisera un cache pour la sortie MathML renvoyée par LaTeXML. Notez que désactiver cette option effacera le cache courant. 10 | 11 | # Predefined Scripts 12 | LaTeX_Delimiters_title = LaTeX avec des délimiteurs 13 | LaTeX_Delimiters_description = Ce script gère le cas où les images ont le code LaTeX avec des délimiteurs en tant que le texte alternatif et peuvent être énumérées par une liste de sélecteurs CSS. 14 | LaTeX_Delimiters_option_selectors_title = Sélecteurs CSS 15 | LaTeX_Delimiters_option_selectors_description = Une liste de CSS selecteurs séparés par des virgules pour énumérer les balises img à convertir. 16 | LaTeX_Delimiters_option_useDisplayAttribute_title = Utiliser l'attribut display 17 | LaTeX_Delimiters_option_useDisplayAttribute_description = Si cette option est activée, les formules mathématiques avec des délimiteurs pour le mode "display" auront l'attribut display="true". Dans le cas contraire, elles auront l'attribut displaystyle="true". 18 | LaTeX_Delimiters_option_preloadList_title = Liste de préchargement de LaTeXML 19 | LaTeX_Delimiters_option_preloadList_description = Liste de préchargement par défault passée au serveur LaTeXML. 20 | LaTeX_NoDelimiters_title = LaTeX sans délimiteurs 21 | LaTeX_NoDelimiters_description = Ce script gère le cas où les images ont le code LaTeX sans délimiteurs en tant que texte alternatif et peuvent être énumérées par une liste de sélecteurs CSS. 22 | LaTeX_NoDelimiters_option_selectorsInline_title = Sélecteurs CSS pour les formules "inline" 23 | LaTeX_NoDelimiters_option_selectorsInline_description = Une liste de CSS selecteurs séparés par des virgules pour énumérer les balises img à convertir en formules "inline" 24 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_title = Sélecteurs CSS pour les formules "inline" avec style "display" 25 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_description = Une liste de CSS selecteurs séparés par des virgules pour énumérer les balises img à convertir en formules "inline" avec style "display" 26 | LaTeX_NoDelimiters_option_selectorsDisplay_title = Sélecteurs CSS pour les formules "display" 27 | LaTeX_NoDelimiters_option_selectorsDisplay_description = Une liste de CSS selecteurs séparés par des virgules pour énumérer les balises img à convertir en formules "display" 28 | LaTeX_NoDelimiters_option_preloadList_title = Liste de préchargement de LaTeXML 29 | LaTeX_NoDelimiters_option_preloadList_description = Liste de préchargement par défault passée au serveur LaTeXML. 30 | 31 | # addRulePanel dialog 32 | addRulePanel_dir = ltr 33 | addRulePanel_addRule = Ajouter une règle "Image to MathML" 34 | addRulePanel_deleteRule = Supprimer la règle 35 | addRulePanel_urlPatternLabel = Motif de l'URL 36 | addRulePanel_scriptLabel = Script 37 | addRulePanel_Cancel = Annuler 38 | addRulePanel_OK = OK 39 | -------------------------------------------------------------------------------- /image-to-mathml/locale/pt-BR.properties: -------------------------------------------------------------------------------- 1 | # Preference Menu 2 | LaTeXMLUrl_title = URL serviço LaTeXML Web 3 | LaTeXMLUrl_description = Essa preferencia possui a URL do serviço LaTeXML Web utilizado para a conversão de LaTeX em MathML. 4 | LaTeXMLPreload_title = Lista pré-carregada do LaTeXML 5 | LaTeXMLPreload_description = Lista pré-carregada padrão a ser enviado ao servidor LaTeXML. 6 | LaTeXMLMaxAttempts_title = Número máximo de tentativas ao LaTeXML 7 | LaTeXMLMaxAttempts_description = O serviço LaTeXML Web deve ter falhado ao converter a entrada LaTeX devido a problemas de conexão. Essa opção permite especificar o número máximo de tentativas em converter uma dada equação antes de desistir. 8 | LaTeXMLCache_title = Cache de saída do LaTeXML 9 | LaTeXMLCache_description = Se essa opção estiver habilitada, a extensão irá salvar a saída MathML retornada pelo LaTeXML. Cuidado que desabilitar essa opção irá limpar o cache atual. 10 | 11 | # Predefined Scripts 12 | LaTeX_Delimiters_title = LaTeX com delimitadores 13 | LaTeX_Delimiters_description = O script cuida dos casos em que a imagem possui código LaTeX com delimitadores como texto alternativo e podem ser enumerados por uma lista de seletores CSS. 14 | LaTeX_Delimiters_option_selectors_title = Selectores CSS 15 | LaTeX_Delimiters_option_selectors_description = Uma lista de valores separados por vírgula de seletores CSS para enumerar as tags img a serem convertidas. 16 | LaTeX_Delimiters_option_useDisplayAttribute_title = Utiliza o atribute display 17 | LaTeX_Delimiters_option_useDisplayAttribute_description = Se essa opção estiver habilitada, fórmulas matemáticas com delimitadores em destaque irão receber o atributo display="true". Caso contrário, eles irão receber apenas o atributo display="true". 18 | LaTeX_Delimiters_option_preloadList_title = Lista pre-carregada do LaTexML 19 | LaTeX_Delimiters_option_preloadList_description = Lista pre-carregada a ser enviada ao servidor LaTeXML. 20 | LaTeX_NoDelimiters_title = LaTeX sem delimitadores 21 | LaTeX_NoDelimiters_description = Esse script cuida dos casos em que a imagem possui código LaTeX sem delimitadores como texto alternativo e pode ser enumerado por uma lista de seletores CSS. 22 | LaTeX_NoDelimiters_option_selectorsInline_title = Seletores CSS para equações na mesma linha 23 | LaTeX_NoDelimiters_option_selectorsInline_description = Uma lista de valores separados por vírgula de seletores CSS para enumerar as tags img que serão convertidas em equações na mesma linha. 24 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_title = Seletor CSS para equações com estilo na mesma linha 25 | LaTeX_NoDelimiters_option_selectorsInlineDisplayStyle_description = Uma lista de valores separados por vírgula de seletores CSS para enumerar as tags img que serão convertidas em equações com estilo na mesma linha. 26 | LaTeX_NoDelimiters_option_selectorsDisplay_title = Seletor CSS para equações em destaque 27 | LaTeX_NoDelimiters_option_selectorsDisplay_description = Uma lista de valores separados por vírgula de seletores CSS para enumerar as tags img que serão convertidas em equações em destaque. 28 | LaTeX_NoDelimiters_option_preloadList_title = Lista pre-carregada do LaTeXML 29 | LaTeX_NoDelimiters_option_preloadList_description = Lista pre-carregada a ser enviada ao servidor LaTeXML. 30 | 31 | # addRulePanel dialog 32 | addRulePanel_dir = ltr 33 | addRulePanel_addRule = Adiciona uma imagem as regras de MathML 34 | addRulePanel_deleteRule = Remove regra. 35 | addRulePanel_urlPatternLabel = Padrão de URL 36 | addRulePanel_scriptLabel = Script 37 | addRulePanel_Cancel = Cancelar 38 | addRulePanel_OK = Aceitar 39 | -------------------------------------------------------------------------------- /image-to-mathml/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "image-to-mathml", 3 | "title": "Image to MathML", 4 | "id": "jid1-0pa82e1f8qz4EQ", 5 | "description": "Try to convert images of mathematical formulas into MathML.", 6 | "author": "Frédéric Wang", 7 | "license": "MPL 2.0", 8 | "version": "0.4", 9 | "preferences": [{ 10 | "name": "LaTeXMLUrl", 11 | "title": "LaTeXMLUrl_title", 12 | "description": "LaTeXMLUrl_description", 13 | "type": "string", 14 | "value": "http://latexml.mathweb.org/convert" 15 | }, { 16 | "name": "LaTeXMLPreload", 17 | "title": "LaTeXMLPreload_title", 18 | "description": "LaTeXMLPreload_description", 19 | "type": "string", 20 | "value": "LaTeX.pool,article.cls,amsmath.sty,amsthm.sty,amstext.sty,amssymb.sty,eucal.sty,[dvipsnames]xcolor.sty,url.sty,hyperref.sty,[Bids]latexml.sty" 21 | }, { 22 | "name": "LaTeXMLMaxAttempts", 23 | "title": "LaTeXMLMaxAttempts_title", 24 | "description": "LaTeXMLMaxAttempt_description", 25 | "type": "integer", 26 | "value": 5 27 | }, { 28 | "name": "LaTeXMLCache", 29 | "title": "LaTeXMLCache_title", 30 | "description": "LaTeXMLCache_description", 31 | "type": "bool", 32 | "value": true 33 | }] 34 | } 35 | -------------------------------------------------------------------------------- /mathml-copy/README.md: -------------------------------------------------------------------------------- 1 | # mathml-copy 2 | 3 | This directory contains the source of the [MathML Copy add-on](https://addons.mozilla.org/en-US/firefox/addon/mathml-copy/) which is built with the 4 | [Add-on SDK](https://developer.mozilla.org/en-US/Add-ons/SDK). 5 | 6 | Users should report any bug to the 7 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 8 | 9 | Localizers should look at the `locale/` directory. To add a new translation, 10 | copy `en-US.properties` to another `*.properties` with the appropriate 11 | [Locale Code](https://wiki.mozilla.org/L10n:Locale_Codes). Please check the 12 | [GitHub Localization issue](https://github.com/fred-wang/Mathzilla/issues/17). 13 | 14 | -------------------------------------------------------------------------------- /mathml-copy/data/get-annotations.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | var MathMLNameSpace = "http://www.w3.org/1998/Math/MathML"; 8 | 9 | function GetAnnotations(aNode) 10 | { 11 | var annotations = []; 12 | 13 | // Retrieve the ancestor and return the list of annotations. 14 | while (aNode) { 15 | if (aNode.nodeType === Node.ELEMENT_NODE && 16 | aNode.namespaceURI === MathMLNameSpace && 17 | aNode.localName === "semantics") { 18 | var children = aNode.children; 19 | var serializer = new XMLSerializer(); 20 | for (var i = 0; i < children.length; i++) { 21 | if (children[i].namespaceURI === MathMLNameSpace) { 22 | if (children[i].localName === "annotation") { 23 | // Copy the text content of . 24 | annotations.push({ 25 | label: children[i].getAttribute("encoding"), 26 | data: children[i].textContent.trim() 27 | }); 28 | } else if (children[i].localName === "annotation-xml" && 29 | children[i].children.length == 1) { 30 | // Copy the serialized unique child of . 31 | annotations.push({ 32 | label: children[i].getAttribute("encoding"), 33 | data: serializer.serializeToString(children[i].children[0]) 34 | }) 35 | } 36 | } 37 | } 38 | break; 39 | } 40 | aNode = aNode.parentNode; 41 | } 42 | return annotations; 43 | } 44 | 45 | self.on("click", function (aNode, aData) { 46 | if (aData) { 47 | self.postMessage({ name: "copy_source", source: aData}); 48 | } 49 | }); 50 | 51 | self.on("context", function (aNode) { 52 | var annotations = GetAnnotations(aNode); 53 | if (annotations.length) { 54 | var items = []; 55 | self.postMessage({ name: "set_items", items: annotations}); 56 | } 57 | return annotations.length; 58 | }); 59 | -------------------------------------------------------------------------------- /mathml-copy/data/get-mathml-source.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | var MathMLNameSpace = "http://www.w3.org/1998/Math/MathML"; 8 | 9 | self.on("click", function (aNode) { 10 | // Retrieve the ancestor, serialize it and send the source to main.js 11 | while (aNode) { 12 | if (aNode.nodeType === Node.ELEMENT_NODE && 13 | aNode.namespaceURI === MathMLNameSpace && 14 | aNode.localName === "math") { 15 | var source = (new XMLSerializer()).serializeToString(aNode); 16 | self.postMessage(source); 17 | break; 18 | } 19 | aNode = aNode.parentNode; 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /mathml-copy/lib/copy-mathml.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | var {Cc, Ci} = require("chrome"); 8 | var MathMLNameSpace = "http://www.w3.org/1998/Math/MathML"; 9 | 10 | exports.copy = function(aMathMLCode) { 11 | // Create a transferable instance. 12 | var transferable = Cc["@mozilla.org/widget/transferable;1"]. 13 | createInstance(Ci.nsITransferable); 14 | 15 | // Create a SupportsString to store the MathML. 16 | var mathString = 17 | Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString); 18 | mathString.data = aMathMLCode; 19 | var mathStringLength = 2 * aMathMLCode.length; 20 | 21 | // XXXfredw: add MathML flavors? 22 | // http://www.w3.org/TR/MathML3/chapter6.html#world-int-transfers 23 | 24 | // Add the MathML code as normal HTML5 flavor, so that it can be pasted into 25 | // other applications (Thunderbird, MDN, etc). 26 | transferable.addDataFlavor("text/html"); 27 | transferable.setTransferData("text/html", mathString, mathStringLength); 28 | 29 | // Add the MathML source, so that it can be pasted into text editor. 30 | transferable.addDataFlavor("text/unicode"); 31 | transferable.setTransferData("text/unicode", mathString, mathStringLength); 32 | 33 | // Copy the content of the transferable into the clipboard. 34 | var clipboard = 35 | Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard); 36 | clipboard.setData(transferable, null, 37 | Ci.nsIClipboard.kGlobalClipboard); 38 | } 39 | -------------------------------------------------------------------------------- /mathml-copy/lib/main.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | var contextMenu = require("sdk/context-menu"); 8 | var data = require("sdk/self").data; 9 | var clipboard = require("sdk/clipboard"); 10 | var copyMathML = require("./copy-mathml"); 11 | var _ = require("sdk/l10n").get; 12 | 13 | // Add a menu item to copy the source and element. 14 | contextMenu.Item({ 15 | label: _("copy_mathml"), 16 | context: contextMenu.SelectorContext("math"), 17 | contentScriptFile: data.url("get-mathml-source.js"), 18 | onMessage: function(aSource) { 19 | copyMathML.copy(aSource); 20 | } 21 | }); 22 | 23 | // Add a submenu enumerating the annotations attached to a element. 24 | contextMenu.Menu({ 25 | label: _("copy_annotation"), 26 | context: contextMenu.SelectorContext("semantics"), 27 | contentScriptFile: data.url("get-annotations.js"), 28 | onMessage: function(aMessage) { 29 | if (aMessage.name == "set_items") { 30 | // Retrieve all the annotations and set the items of the submenu. 31 | var items = []; 32 | for (var i = 0; i < aMessage.items.length; i++) { 33 | items.push(contextMenu.Item(aMessage.items[i])); 34 | } 35 | this.items = items; 36 | } else if (aMessage.name == "copy_source") { 37 | clipboard.set(aMessage.source); 38 | } 39 | }, 40 | // dummy item to force the submenu to be displayed the first time the context 41 | // menu is opened. 42 | items: [contextMenu.Item({ label: "?" })] 43 | }); 44 | -------------------------------------------------------------------------------- /mathml-copy/locale/ar.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=انسخ معادلة MathML -------------------------------------------------------------------------------- /mathml-copy/locale/de-DE.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=MathML Code kopieren -------------------------------------------------------------------------------- /mathml-copy/locale/en-US.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=Copy MathML Formula 2 | copy_annotation=Copy Annotation -------------------------------------------------------------------------------- /mathml-copy/locale/es-ES.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=Copiar la formula MathML 2 | copy_annotation=Copiar la anotación -------------------------------------------------------------------------------- /mathml-copy/locale/fr-FR.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=Copier la formule MathML 2 | copy_annotation=Copier l'annotation -------------------------------------------------------------------------------- /mathml-copy/locale/hi-IN.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=MathML सूत्र कॉपी करें -------------------------------------------------------------------------------- /mathml-copy/locale/hu-HU.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=MathML képlet másolása -------------------------------------------------------------------------------- /mathml-copy/locale/mr-IN.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=MathML सूत्र कॉपी करा -------------------------------------------------------------------------------- /mathml-copy/locale/pt-BR.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=Copiar Fórmula em MathML 2 | copy_annotation=Copiar Anotação -------------------------------------------------------------------------------- /mathml-copy/locale/pt-PT.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=Copiar Fórmula em MathML 2 | copy_annotation=Copiar Anotação -------------------------------------------------------------------------------- /mathml-copy/locale/zh-CN.properties: -------------------------------------------------------------------------------- 1 | copy_mathml=复制 MathML 公式 -------------------------------------------------------------------------------- /mathml-copy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mathml-copy", 3 | "title": "MathML Copy", 4 | "id": "jid1-u5w9ZJYgijZpHA@jetpack", 5 | "main": "lib/main.js", 6 | "description": "Add items to the context menu to copy a MathML formula and other annotations attached to it (e.g. LaTeX) into the clipboard.", 7 | "author": "Frédéric Wang", 8 | "license": "MPL 2.0", 9 | "version": "1.3" 10 | } 11 | -------------------------------------------------------------------------------- /mathml-ctop/.gitignore: -------------------------------------------------------------------------------- 1 | ctop/ 2 | MathML-ctop/ 3 | MathML-mml3ff/ 4 | mathml-ctop.xpi 5 | mathml-mml3ff.xpi 6 | -------------------------------------------------------------------------------- /mathml-ctop/Makefile: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | include config 6 | 7 | MARKER_ADD_ON_NAME = ADD_ON_NAME 8 | MARKER_ADD_ON_DESCRIPTION = ADD_ON_DESCRIPTION 9 | 10 | SOURCE = src 11 | 12 | CTOP_SVN = ctop 13 | CTOP_CTOP_XSL = ctopff.xsl 14 | CTOP_MML3FF_XSL = mml3ff.xsl 15 | 16 | MATHML_CTOP = MathML-ctop 17 | MATHML_CTOP_XPI = mathml-ctop.xpi 18 | MATHML_CTOP_DESC = Converter from content MathML to presentation MathML. 19 | 20 | MATHML_MML3FF = MathML-mml3ff 21 | MATHML_MML3FF_XPI = mathml-mml3ff.xpi 22 | MATHML_MML3FF_DESC = Add support for MathML 3 features not implemented in Gecko. 23 | 24 | INSTALL_RDF = install.rdf 25 | STYLESHEET_XSL = stylesheet.xsl 26 | 27 | all: download ctop mml3ff xpi 28 | 29 | clean: 30 | @ echo "Removing temporary files..." 31 | @ rm -rf $(CTOP_SVN) 32 | @ rm -rf $(MATHML_CTOP) 33 | @ rm -rf $(MATHML_MML3FF) 34 | @ echo "done." 35 | @ echo 36 | 37 | download: 38 | @ echo "Downloading ctop..." 39 | @ $(SVN) checkout $(CTOP_REPOSITORY) $(CTOP_SVN) 40 | @ echo "done." 41 | @ echo 42 | 43 | ctop: 44 | @ echo "Preparing $(MATHML_CTOP)..." 45 | @ rm -rf $(MATHML_CTOP) 46 | @ cp -r $(SOURCE) $(MATHML_CTOP) 47 | @ ls $(MATHML_CTOP)/* | grep -v $(STYLESHEET_XSL) | xargs $(SED) -i 's/$(MARKER_ADD_ON_NAME)/$(MATHML_CTOP)/g' 48 | @ $(SED) -i 's/$(MARKER_ADD_ON_DESCRIPTION)/$(MATHML_CTOP_DESC)/g' $(MATHML_CTOP)/$(INSTALL_RDF) 49 | @ cp $(CTOP_SVN)/$(CTOP_CTOP_XSL) $(MATHML_CTOP)/$(STYLESHEET_XSL) 50 | @ echo "done." 51 | @ echo 52 | 53 | mml3ff: 54 | @ echo "Preparing $(MATHML_MML3FF)..." 55 | @ rm -rf $(MATHML_MML3FF) 56 | @ cp -r $(SOURCE) $(MATHML_MML3FF) 57 | @ ls $(MATHML_MML3FF)/* | grep -v $(STYLESHEET_XSL) | xargs $(SED) -i 's/$(MARKER_ADD_ON_NAME)/$(MATHML_MML3FF)/g' 58 | @ $(SED) -i 's/$(MARKER_ADD_ON_DESCRIPTION)/$(MATHML_MML3FF_DESC)/g' $(MATHML_MML3FF)/$(INSTALL_RDF) 59 | @ cp $(CTOP_SVN)/$(CTOP_MML3FF_XSL) $(MATHML_MML3FF)/$(STYLESHEET_XSL) 60 | @ echo "done." 61 | @ echo 62 | 63 | xpi: 64 | @ echo "Creating $(MATHML_CTOP_XPI) and $(MATHML_MML3FF_XPI)..." 65 | @ mkdir -p $(MATHML_MML3FF) ; cd $(MATHML_CTOP) ; $(ZIP) -r ../$(MATHML_CTOP_XPI) * 66 | @ mkdir -p $(MATHML_MML3FF) ; cd $(MATHML_MML3FF) ; $(ZIP) -r ../$(MATHML_MML3FF_XPI) * 67 | @ echo "done." 68 | @ echo 69 | 70 | .PHONY: clean ctop mml3ff 71 | -------------------------------------------------------------------------------- /mathml-ctop/README.md: -------------------------------------------------------------------------------- 1 | # mathml-ctop and mathml-mml3ff 2 | 3 | Source of the MathML-ctop and MathML-mml3ff add-ons and the scripts to generate 4 | them. They essentially apply [David Carlisle's ctop stylesheets](http://web-xslt.googlecode.com/svn/trunk/ctop/) to MathML elements. 5 | 6 | Users should report any bug to the 7 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 8 | 9 | To build the extension, edit the config file 10 | (if necessary) and type `make`. You should find generated `mathml-ctop.xpi` and 11 | `mathml-mml3ff` files. 12 | -------------------------------------------------------------------------------- /mathml-ctop/config: -------------------------------------------------------------------------------- 1 | CTOP_REPOSITORY = http://web-xslt.googlecode.com/svn/trunk/ctop/ 2 | PERL = perl 3 | SED = sed 4 | SVN = svn 5 | ZIP = zip 6 | -------------------------------------------------------------------------------- /mathml-ctop/src/bootstrap.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode:nil; -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | const Cc = Components.classes; 8 | const Ci = Components.interfaces; 9 | const Cr = Components.results; 10 | const Cu = Components.utils; 11 | 12 | // URI of the style sheet 13 | const kXSLTStyleSheet = "chrome://ADD_ON_NAME/content/stylesheet.xsl"; 14 | 15 | // Define XMLHttpRequest. This only works correctly with Gecko >= 16. See 16 | // developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest 17 | const XMLHttpRequest = 18 | Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1"); 19 | 20 | // Global variable to store the XSLT processor. It is created only once, the 21 | // first time we need it, and kept at least until the add-on is disabled. 22 | var gXSLTProcessor = null; 23 | 24 | function initXSLTProcessor(aDocument) 25 | { 26 | // Start a XHR request to load the XSLT style sheet. 27 | var xhr = XMLHttpRequest(); 28 | xhr.open("GET", kXSLTStyleSheet, true); 29 | xhr.onload = function (aEvent) { 30 | // Create the XSLT processor and initialize it with the style sheet. 31 | gXSLTProcessor = 32 | Cc["@mozilla.org/document-transformer;1?type=xslt"]. 33 | createInstance(Ci.nsIXSLTProcessor); 34 | gXSLTProcessor.importStylesheet(xhr.response); 35 | // We are done, let's try to apply the XSLT style sheet again. 36 | applyXSLTStyleSheetToMathML(aDocument); 37 | }; 38 | xhr.responseType = "document"; 39 | xhr.send(null); 40 | } 41 | 42 | function applyXSLTStyleSheetToMathML(aDocument) 43 | { 44 | // Search all 's on the page, but do nothing if none are found. 45 | var mathElements = aDocument. 46 | getElementsByTagNameNS("http://www.w3.org/1998/Math/MathML", "math"); 47 | if (mathElements.length == 0) return; 48 | 49 | // If the XSLT processor is not loaded yet, do it now. 50 | if (!gXSLTProcessor) { 51 | initXSLTProcessor(aDocument); 52 | return; 53 | } 54 | 55 | // Now apply the XSLT style sheet to each element. 56 | for (var i = 0; i < mathElements.length; i++) { 57 | var newMath = 58 | gXSLTProcessor.transformToFragment(mathElements[i], aDocument); 59 | if (newMath != null) { 60 | mathElements[i].parentNode.replaceChild(newMath, mathElements[i]); 61 | } 62 | } 63 | } 64 | 65 | function onDOMContentLoaded(aEvent) 66 | { 67 | // DOMContentLoaded: let's try to apply the XSLT style sheet 68 | var doc = aEvent.originalTarget; 69 | applyXSLTStyleSheetToMathML(doc); 70 | } 71 | 72 | //////////////////////////////////////////////////////////////////////////////// 73 | // Implement bootstrap main functions and a basic observer for browser windows. 74 | // The code is based on 75 | // developer.mozilla.org/en-US/docs/Extensions/Mobile/Addons_developer_guide 76 | //////////////////////////////////////////////////////////////////////////////// 77 | 78 | function loadIntoWindow(aWindow) { 79 | if (aWindow && aWindow.gBrowser) { 80 | // Add a listener to the tabbrowser 81 | aWindow.gBrowser.addEventListener("DOMContentLoaded", 82 | onDOMContentLoaded, false); 83 | } 84 | } 85 | 86 | function unloadFromWindow(aWindow) { 87 | if (aWindow && aWindow.gBrowser) { 88 | // Remove the listener from the tabbrowser 89 | aWindow.gBrowser.removeEventListener("DOMContentLoaded", 90 | onDOMContentLoaded, false); 91 | } 92 | } 93 | 94 | var windowListener = { 95 | onOpenWindow: function(aWindow) { 96 | // Wait for the window to finish loading. 97 | let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor). 98 | getInterface(Ci.nsIDOMWindow); 99 | domWindow.addEventListener("load", function() { 100 | domWindow.removeEventListener("load", arguments.callee, false); 101 | loadIntoWindow(domWindow); 102 | }, false); 103 | }, 104 | 105 | onCloseWindow: function(aWindow) {}, 106 | onWindowTitleChange: function(aWindow, aTitle) {} 107 | }; 108 | 109 | function startup(aData, aReason) { 110 | let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. 111 | getService(Ci.nsIWindowMediator); 112 | 113 | // Load into any existing windows. 114 | let windows = wm.getEnumerator("navigator:browser"); 115 | while (windows.hasMoreElements()) { 116 | let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow); 117 | loadIntoWindow(domWindow); 118 | } 119 | 120 | // Load into any new windows. 121 | wm.addListener(windowListener); 122 | } 123 | 124 | function shutdown(aData, aReason) { 125 | // When the application is shutting down we normally don't have to clean 126 | // up anything. 127 | if (aReason == APP_SHUTDOWN) 128 | return; 129 | 130 | // Reset the gXSLTProcessor variable. 131 | gXSLTProcessor = null; 132 | 133 | let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. 134 | getService(Ci.nsIWindowMediator); 135 | 136 | // Stop listening for new windows. 137 | wm.removeListener(windowListener); 138 | 139 | // Unload from any existing windows. 140 | let windows = wm.getEnumerator("navigator:browser"); 141 | while (windows.hasMoreElements()) { 142 | let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow); 143 | unloadFromWindow(domWindow); 144 | } 145 | } 146 | 147 | function install(aData, aReason) {} 148 | function uninstall(aData, aReason) {} 149 | -------------------------------------------------------------------------------- /mathml-ctop/src/chrome.manifest: -------------------------------------------------------------------------------- 1 | content ADD_ON_NAME ./ 2 | -------------------------------------------------------------------------------- /mathml-ctop/src/install.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 9 | 10 | 11 | ADD_ON_NAME@mozilla.com 12 | 1.2 13 | 2 14 | 15 | 16 | 17 | 18 | {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 19 | 2.12 20 | 2.15.* 21 | 22 | 23 | 24 | 25 | 26 | 27 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 28 | 16.0 29 | 19.0a1 30 | 31 | 32 | 33 | ADD_ON_NAME 34 | true 35 | ADD_ON_DESCRIPTION 36 | Frédéric Wang 37 | David Carlisle 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /mathml-fonts/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | MathML-fonts/resource/LatinModern 3 | MathML-fonts/resource/MathFonts-gh-pages 4 | MathML-fonts/resource/XITS 5 | autom4te.cache 6 | config.log 7 | config.status 8 | mathml-fonts.xpi 9 | mathml-fonts.zip 10 | -------------------------------------------------------------------------------- /mathml-fonts/Makefile.in: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | MATHML_FONTS = MathML-fonts 6 | MATHML_FONTS_GH = $(MATHML_FONTS)/resource/MathFonts-gh-pages 7 | MATHML_FONTS_URI=https://github.com/fred-wang/MathFonts/archive/gh-pages.zip 8 | MATHML_FONTS_XPI = mathml-fonts.xpi 9 | MATHML_FONTS_ZIP = mathml-fonts.zip 10 | 11 | all: $(MATHML_FONTS_XPI) 12 | 13 | clean: 14 | @ echo "Removing temporary files..." 15 | @ rm -rf $(MATHML_FONTS_ZIP) $(MATHML_FONTS)/resource/LatinModern \ 16 | $(MATHML_FONTS)/resource/XITS 17 | 18 | distclean: clean 19 | @ echo "Removing all untracked files..." 20 | @ rm -rf Makefile autom4te.cache config.log config.status \ 21 | mathml-fonts.xpi $(MATHML_FONTS_GH) 22 | 23 | $(MATHML_FONTS_ZIP): 24 | @ echo "Downloading MathML fonts..." 25 | @ @WGET@ $(MATHML_FONTS_URI) -O $(MATHML_FONTS_ZIP) 26 | 27 | $(MATHML_FONTS_GH): $(MATHML_FONTS_ZIP) 28 | @ echo "Extracting MathML fonts..." 29 | @ @UNZIP@ -o $(MATHML_FONTS_ZIP) -d $(MATHML_FONTS)/resource 30 | 31 | $(MATHML_FONTS)/resource/LatinModern: $(MATHML_FONTS_GH) 32 | @ echo "Preparing LatinModern..." 33 | @ cp -r $(MATHML_FONTS_GH)/LatinModern $(MATHML_FONTS)/resource/ 34 | @ cd $(MATHML_FONTS)/resource/LatinModern/; rm -f *.css lmroman*.woff \ 35 | MANIFEST-Latin-Modern.TXT README-Latin-Modern.TXT INSTALL.txt \ 36 | lm-hist.txt 37 | 38 | $(MATHML_FONTS)/resource/XITS: $(MATHML_FONTS_GH) 39 | @ echo "Preparing XITS..." 40 | @ cp -r $(MATHML_FONTS_GH)/XITS $(MATHML_FONTS)/resource/ 41 | @ cd $(MATHML_FONTS)/resource/XITS/; rm -f *.css \ 42 | xits-regular.woff xits-mathbold.woff \ 43 | xits-bold.woff xits-italic.woff xits-bolditalic.woff 44 | 45 | $(MATHML_FONTS_XPI): $(MATHML_FONTS)/resource/LatinModern $(MATHML_FONTS)/resource/XITS $(MATHML_FONTS)/bootstrap.js $(MATHML_FONTS)/install.rdf $(MATHML_FONTS)/resource/mathml.css 46 | @ echo "Creating the xpi file..." 47 | @ cd $(MATHML_FONTS) ; @ZIP@ -r ../$(MATHML_FONTS_XPI) install.rdf bootstrap.js resource/mathml.css resource/LatinModern resource/XITS 48 | -------------------------------------------------------------------------------- /mathml-fonts/MathML-fonts/bootstrap.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode:nil; -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | function startup(aData, aReason) { 8 | var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] 9 | .getService(Components.interfaces.nsIStyleSheetService); 10 | var ios = Components.classes["@mozilla.org/network/io-service;1"] 11 | .getService(Components.interfaces.nsIIOService); 12 | var uri = ios.newURI("resource/mathml.css", null, aData.resourceURI); 13 | sss.loadAndRegisterSheet(uri, sss.USER_SHEET); 14 | } 15 | 16 | function shutdown(aData, aReason) { 17 | if (aReason != APP_SHUTDOWN) { 18 | var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] 19 | .getService(Components.interfaces.nsIStyleSheetService); 20 | var ios = Components.classes["@mozilla.org/network/io-service;1"] 21 | .getService(Components.interfaces.nsIIOService); 22 | var u = ios.newURI("resource/mathml.css", null, aData.resourceURI); 23 | if(sss.sheetRegistered(u, sss.USER_SHEET)) { 24 | sss.unregisterSheet(u, sss.USER_SHEET); 25 | } 26 | } 27 | } 28 | 29 | function install(aData, aReason) { 30 | } 31 | 32 | function uninstall(aData, aReason) { 33 | } 34 | -------------------------------------------------------------------------------- /mathml-fonts/MathML-fonts/install.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 9 | 10 | 11 | MathML-fonts@mozilla.com 12 | 2.1 13 | 2 14 | 15 | 16 | 17 | 18 | toolkit@mozilla.org 19 | 31.0 20 | 36.0 21 | 22 | 23 | 24 | 25 | 26 | 27 | {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 28 | 2.28 29 | 2.33 30 | 31 | 32 | 33 | 34 | 35 | 36 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 37 | 31.0 38 | 36.0 39 | 40 | 41 | 42 | 43 | 44 | 45 | {3550f703-e582-4d05-9a08-453d09bdfdc6} 46 | 31.0 47 | 36.0 48 | 49 | 50 | 51 | 52 | 53 | 54 | {aa3c5121-dab2-40e2-81ca-7ea25febc110} 55 | 31.0 56 | 36.0 57 | 58 | 59 | 60 | 61 | 62 | 63 | {a23983c0-fd0e-11dc-95ff-0800200c9a66} 64 | 31.0 65 | 36.0 66 | 67 | 68 | 69 | MathML-fonts 70 | true 71 | Fonts for Mozilla's MathML engine. 72 | Frédéric Wang 73 | Bill Gianopoulos 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /mathml-fonts/MathML-fonts/resource/mathml.css: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | /* Latin Modern Math. */ 6 | @font-face { 7 | font-family: 'Latin Modern Math'; 8 | src: local('Latin Modern Math'), local('LatinModernMath-Regular'), url('LatinModern/latinmodern-math.woff'); 9 | } 10 | 11 | /* XITS. */ 12 | @font-face { 13 | font-family: 'XITS Math'; 14 | src: local('XITS Math'), local('XITSMath-Regular'), url('XITS/xits-math.woff'); 15 | } 16 | -------------------------------------------------------------------------------- /mathml-fonts/README.md: -------------------------------------------------------------------------------- 1 | # mathml-fonts 2 | 3 | This directory contains the sources of the mathml-fonts extension, which adds 4 | mathematical fonts necessary for Gecko's MathML engine (in WOFF format) and 5 | automatically attachs to each page a CSS style sheet with `@font-face` rules to 6 | load the fonts. To build it, do: 7 | 8 | ./configure 9 | make 10 | 11 | Users should report any bug to the 12 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 13 | -------------------------------------------------------------------------------- /mathml-fonts/configure.ac: -------------------------------------------------------------------------------- 1 | dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*- 2 | dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4: 3 | dnl This Source Code Form is subject to the terms of the Mozilla Public 4 | dnl License, v. 2.0. If a copy of the MPL was not distributed with this 5 | dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | AC_PREREQ(2.13) 8 | AC_INIT(mathml-fonts-addon, 1.0) 9 | AC_CONFIG_SRCDIR(MathML-fonts) 10 | 11 | AC_CHECK_PROGS(PYTHON, python) 12 | AC_CHECK_PROGS(UNZIP, unzip) 13 | AC_CHECK_PROGS(WGET, wget) 14 | AC_CHECK_PROGS(ZIP, zip) 15 | 16 | AC_CONFIG_FILES(Makefile) 17 | AC_OUTPUT 18 | -------------------------------------------------------------------------------- /mathml-fontsettings/README.md: -------------------------------------------------------------------------------- 1 | # MathML font settings 2 | 3 | This directory contains the source of the [mathjax-native-mathml add-on](https://addons.mozilla.org/en-US/firefox/addon/mathml-fontsettings/) which is built with the 4 | [Add-on SDK](https://developer.mozilla.org/en-US/Add-ons/SDK). 5 | 6 | Users should report any bug to the 7 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 8 | 9 | Localizers should look at the `locale/` directory. To add a new translation, 10 | copy `en-US.properties` to another `*.properties` with the appropriate 11 | [Locale Code](https://wiki.mozilla.org/L10n:Locale_Codes). Please check the 12 | [GitHub Localization issue](https://github.com/fred-wang/Mathzilla/issues/17). 13 | -------------------------------------------------------------------------------- /mathml-fontsettings/data/set-style.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | var gStyleElement = null; 9 | 10 | // Update the CSS rules for the MathML rendering. 11 | function updateStyle(aPrefs) { 12 | var mathCSS = ""; 13 | var ruleEnd = aPrefs.mathFontImportant ? " !important;" : ";" 14 | if (!gStyleElement) { 15 | return; 16 | } 17 | if (aPrefs.mathFontFamily !== "") { 18 | aPrefs.mathFontFamily.replace("'", "\\'"); 19 | mathCSS += "font-family: '" + aPrefs.mathFontFamily + "'" + ruleEnd; 20 | } 21 | if (aPrefs.mathFontScale > 0 && aPrefs.mathFontScale !== 100) { 22 | mathCSS += "font-size:" + aPrefs.mathFontScale + "%" + ruleEnd; 23 | } 24 | gStyleElement.textContent = "/* MathML Font Settings */\n"; 25 | if (mathCSS !== "") { 26 | gStyleElement.textContent += 27 | "@namespace m 'http://www.w3.org/1998/Math/MathML';" + 28 | "m|math {" + mathCSS + "}" 29 | } 30 | }; 31 | 32 | // Create the "),n=document.createElement("span"),n.className="line-numbers-rows",n.innerHTML=m,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(n)}}})}(); 5 | !function(){function e(e){this.defaults=r({},e)}function n(e){return e.replace(/-(\w)/g,function(e,n){return n.toUpperCase()})}function t(e){for(var n=0,t=0;tn&&(o[l]="\n"+o[l],a=s)}r[i]=o.join("")}return r.join("\n")}},Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),Prism.hooks.add("before-highlight",function(e){var n=e.element.parentNode;if(e.code&&n&&"pre"===n.nodeName.toLowerCase()&&(!e.settings||e.settings["whitespace-normalization"]!==!1)){for(var t=n.childNodes,r="",i="",o=!1,a=Prism.plugins.NormalizeWhitespace,l=0;l 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /mathml-viewsource/data/view-mathml-source.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | self.port.on("setContent", function(aTitle, aSource) { 6 | document.title = aTitle; 7 | document.getElementById("code").textContent = aSource; 8 | unsafeWindow.Prism.highlightAll(); 9 | }); 10 | -------------------------------------------------------------------------------- /mathml-viewsource/index.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | var _ = require("sdk/l10n").get; 8 | var contextMenu = require("sdk/context-menu"); 9 | var data = require("sdk/self").data; 10 | var tabs = require("sdk/tabs"); 11 | 12 | // FIXME: accessKey does not seem to work. 13 | // See https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Add_a_Context_Menu_Item#Adding_an_access_key 14 | contextMenu.Item({ 15 | label: _("viewPartialSourceForMathMLCmdLabel"), 16 | accessKey: _("viewPartialSourceCmdAccessKey"), 17 | context: contextMenu.SelectorContext("math"), 18 | contentScriptFile: data.url("get-mathml-source.js"), 19 | onMessage: function(aSource) { 20 | // Print invisible characters in a readable way. 21 | var source = aSource.replace(/[\u2061-\u2064]/g, function(c) { 22 | var codePoint = c.charCodeAt(0); 23 | var unicodeName = ["FUNCTION APPLICATION", 24 | "INVISIBLE TIMES", 25 | "INVISIBLE SEPARATOR", 26 | "INVISIBLE PLUS"][codePoint - 0x2061]; 27 | return "&#x" + codePoint.toString(16) + ";"; 28 | }); 29 | // Open a new tab with the MathML source. 30 | tabs.open({ 31 | url: data.url("view-mathml-source.html"), 32 | onLoad: function(aTab) { 33 | aTab.attach({ 34 | contentScriptFile: data.url("view-mathml-source.js") 35 | }).port.emit("setContent", _("viewMathMLSourceTitle"), source); 36 | } 37 | }); 38 | } 39 | }); 40 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ar.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=اعرض مصدر MathML 2 | viewPartialSourceCmdAccessKey=ص 3 | viewMathMLSourceTitle=مصدر DOM ل‍ MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ast.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver el códigu fonte MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fonte DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/cs.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Zobrazit zdrojový kód MathML 2 | viewPartialSourceCmdAccessKey=j 3 | viewMathMLSourceTitle=Zdrojový kód MathML v DOM 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/de.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML-Quelle anzeigen 2 | viewPartialSourceCmdAccessKey=A 3 | viewMathMLSourceTitle=DOM des MathML-Quelltextes 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/en-GB.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=View MathML Source 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=DOM Source of MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/en-US.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=View MathML Source 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=DOM Source of MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/eo.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Vidi fonton de MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=DOM Fonto de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/es-AR.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver fuente MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fuente DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/es-CL.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver código fuente MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fuente DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/es-ES.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver el código fuente MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fuente DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/es-MX.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver el código fuente MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fuente DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/fa.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=نمایش کدمنبع MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=مبدأ MathML‎ 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/fr.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Code MathML de la sélection 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Source DOM MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/fy-NL.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML-boarne besjen 2 | viewPartialSourceCmdAccessKey=B 3 | viewMathMLSourceTitle=DOM-boarne fan MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/gl.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver a fonte MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Fonte DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/he.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=הצגת קוד מקור MathML 2 | viewPartialSourceCmdAccessKey=ה 3 | viewMathMLSourceTitle=מקור DOM של MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/hu.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML forrás megtekintése 2 | viewPartialSourceCmdAccessKey=M 3 | viewMathMLSourceTitle=MathML DOM-forrása 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/id.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Lihat Kode Sumber MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Sumber DOM dari MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/it.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Visualizza sorgente MathML 2 | viewPartialSourceCmdAccessKey=u 3 | viewMathMLSourceTitle=Sorgente DOM MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ja-JP-mac.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML のソースを表示 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML の DOM ソース 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ja.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML のソースを表示 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML の DOM ソース 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/kk.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML бастапқы коды 2 | viewPartialSourceCmdAccessKey=ы 3 | viewMathMLSourceTitle=DOM MathML бастапқы коды 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ko.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML 소스 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML의 DOM 소스 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/lt.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Rodyti „MathML“ pirminį tekstą 2 | viewPartialSourceCmdAccessKey=d 3 | viewMathMLSourceTitle=DOM „MathML“ pirminis tekstas 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/lv.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Skatīt MathML pirmkodu 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML DOM pirmkods 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/nb-NO.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Vis MathML-kildekode 2 | viewPartialSourceCmdAccessKey=k 3 | viewMathMLSourceTitle=DOM-kildekode for MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/nl.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML-bron bekijken 2 | viewPartialSourceCmdAccessKey=B 3 | viewMathMLSourceTitle=DOM-bron van MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/nn-NO.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Vis MathML-kjeldekode 2 | viewPartialSourceCmdAccessKey=k 3 | viewMathMLSourceTitle=DOM-kjeldekode for MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/pl.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Pokaż źródło MathML 2 | viewPartialSourceCmdAccessKey=d 3 | viewMathMLSourceTitle=Źródło DOM dokumentu MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/pt-BR.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver código-fonte MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Código-fonte DOM de MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/pt-PT.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Ver código fonte MathML 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=Código DOM do MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/ru.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Исходный код MathML 2 | viewPartialSourceCmdAccessKey=д 3 | viewMathMLSourceTitle=Исходный код DOM MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/sk.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Zobraziť zdrojový kód MathML 2 | viewPartialSourceCmdAccessKey=r 3 | viewMathMLSourceTitle=DOM zdrojový kód MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/sl.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Pokaži izvorno kodo MathML 2 | viewPartialSourceCmdAccessKey=r 3 | viewMathMLSourceTitle=Izvorna koda DOM MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/sv-SE.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Visa MathML-källkod 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=DOM-källan för MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/th.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=ดูโค้ด MathML 2 | viewPartialSourceCmdAccessKey=ก 3 | viewMathMLSourceTitle=ต้นฉบับ DOM ของ MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/tr.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=MathML kaynağını göster 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML'nin DOM kaynağı 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/uk.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Програмний код MathML 2 | viewPartialSourceCmdAccessKey=к 3 | viewMathMLSourceTitle=DOM-джерело MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/vi.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=Xem mã nguồn MathML 2 | viewPartialSourceCmdAccessKey=X 3 | viewMathMLSourceTitle=Mã Nguồn DOM của MathML 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/zh-CN.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=查看 MathML 源代码 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML 的 DOM 源代码 4 | -------------------------------------------------------------------------------- /mathml-viewsource/locale/zh-TW.properties: -------------------------------------------------------------------------------- 1 | viewPartialSourceForMathMLCmdLabel=檢視 MathML 原始碼 2 | viewPartialSourceCmdAccessKey=e 3 | viewMathMLSourceTitle=MathML 的 DOM 原始碼 4 | -------------------------------------------------------------------------------- /mathml-viewsource/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "MathML View Source", 3 | "name": "mathml-viewsource", 4 | "version": "0.0.1", 5 | "description": "A 'View MathML Source' context menu item", 6 | "main": "index.js", 7 | "author": "Frédéric Wang", 8 | "engines": { 9 | "firefox": ">=38.0a1", 10 | "fennec": ">=38.0a1" 11 | }, 12 | "license": "MPL", 13 | "keywords": [ 14 | "jetpack" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /mathml-zoom/README.md: -------------------------------------------------------------------------------- 1 | # MathML Zoom 2 | 3 | This directory contains the source of the [MathML Zoom add-on](https://addons.mozilla.org/en-US/firefox/addon/mathml-zoom/) which is built with the 4 | [Add-on SDK](https://developer.mozilla.org/en-US/Add-ons/SDK). 5 | 6 | Users should report any bug to the 7 | [GitHub tracker](https://github.com/fred-wang/Mathzilla/issues). 8 | -------------------------------------------------------------------------------- /mathml-zoom/data/zoom.css: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | div.MathMLAddOnZoomed { 8 | position: absolute !important; 9 | background-color: #f0f0f0 !important; 10 | overflow: none !important; 11 | display: inline-block !important; 12 | z-index: 1000 !important; 13 | padding: .5em !important; 14 | border: 1px solid black !important; 15 | margin: 0 !important; 16 | box-shadow: 5px 5px 15px #aaaaaa !important; 17 | } 18 | -------------------------------------------------------------------------------- /mathml-zoom/data/zoom.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | var MathMLNameSpace = "http://www.w3.org/1998/Math/MathML"; 10 | var XHTMLNameSpace = "http://www.w3.org/1999/xhtml" 11 | 12 | function unzoom(aEvent) 13 | { 14 | // Remove the zoomed math from the document. 15 | var zoomedMath = aEvent.currentTarget; 16 | zoomedMath.removeEventListener("click", unzoom); 17 | zoomedMath.parentNode.removeChild(zoomedMath); 18 | } 19 | 20 | function zoom(aEvent) 21 | { 22 | var math = aEvent.currentTarget; 23 | if (!math.parentNode || math.parentNode.namespaceURI !== XHTMLNameSpace) { 24 | // Ignore zoom request if the is not inside an HTML container. 25 | // XXXfredw: Do we want to handle the case of MathML in SVG? 26 | return; 27 | } 28 | 29 | var previous = math.previousElementSibling; 30 | if (previous && previous.getAttribute("class") === "MathMLAddOnZoomed") { 31 | // The zoom is already visible, so we ignore this request. 32 | return; 33 | } 34 | 35 | // Create a div to store the zoomed math and register listener to unzoom it. 36 | var zoomedMath = document.createElement("div"); 37 | zoomedMath.setAttribute("class", "MathMLAddOnZoomed"); 38 | zoomedMath.style.fontSize = "200%"; 39 | zoomedMath.appendChild(math.cloneNode(true)); 40 | math.parentNode.insertBefore(zoomedMath, math); 41 | zoomedMath.addEventListener("click", unzoom); 42 | 43 | // Center the zoomed formula over the original one. 44 | var mathRect = math.getBoundingClientRect(); 45 | var zoomedMathRect = zoomedMath.getBoundingClientRect(); 46 | zoomedMath.style.left = (mathRect.left + 47 | (mathRect.width - zoomedMathRect.width) / 2 ) + "px"; 48 | zoomedMath.style.top = (mathRect.top + 49 | (mathRect.heigth - zoomedMathRect.height) / 2) + "px"; 50 | } 51 | 52 | function isMathElement(aNode) 53 | { 54 | return (aNode.nodeType === Node.ELEMENT_NODE && 55 | aNode.tagName === "math" && 56 | aNode.namespaceURI === MathMLNameSpace); 57 | } 58 | 59 | function registerZoom(aMath) 60 | { 61 | aMath.addEventListener("click", zoom); 62 | } 63 | 64 | function unregisterZoom(aMath) 65 | { 66 | aMath.removeEventListener("click", zoom); 67 | } 68 | 69 | // Register the zoom event for the existing elements. 70 | var maths = document.body.getElementsByTagNameNS(MathMLNameSpace, "math"); 71 | for (var i = 0; i < maths.length; i++) { 72 | registerZoom(maths[i]); 73 | } 74 | 75 | // Track addition/removal of elements. 76 | var observer = new MutationObserver(function(aMutations) { 77 | aMutations.forEach(function(aMutation) { 78 | var i, node; 79 | 80 | // Register zoom event for new elements. 81 | for (i = 0; i < aMutation.addedNodes.length; i++) { 82 | node = aMutation.addedNodes[i]; 83 | if (!isMathElement(node)) { 84 | continue; 85 | } 86 | if (node.parentNode.getAttribute("class") !== "MathMLAddOnZoomed") { 87 | registerZoom(node); 88 | } 89 | } 90 | 91 | // Unregister zoom event for removed elements. 92 | for (i = 0; i < aMutation.removedNodes.length; i++) { 93 | node = aMutation.removedNodes[i]; 94 | if (!isMathElement(node)) { 95 | continue; 96 | } 97 | if (node.parentNode.getAttribute("class") !== "MathMLAddOnZoomed") { 98 | unregisterZoom(node); 99 | } 100 | } 101 | }); 102 | }); 103 | observer.observe(document.body, { childList: true, subtree: true }); 104 | 105 | self.port.on("detach", function() { 106 | // Remove the listener 107 | var maths = document.body.getElementsByTagNameNS(MathMLNameSpace, "math"); 108 | var i, node; 109 | for (i = 0; i < maths.length; i++) { 110 | node = maths[i]; 111 | if (node.parentNode.getAttribute("class") !== "MathMLAddOnZoomed") { 112 | unregisterZoom(node); 113 | } 114 | } 115 | 116 | // Remove the observer. 117 | observer.disconnect(); 118 | }); 119 | -------------------------------------------------------------------------------- /mathml-zoom/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/mathml-zoom/icon64.png -------------------------------------------------------------------------------- /mathml-zoom/lib/main.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 2 | /* vim: set ts=2 et sw=2 tw=80: */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | "use strict"; 8 | 9 | var data = require("sdk/self").data, 10 | pageMod = require("sdk/page-mod"); 11 | 12 | pageMod.PageMod({ 13 | include: "*", 14 | contentScriptFile: data.url("zoom.js"), 15 | contentStyleFile: data.url("zoom.css"), 16 | attachTo: ["existing", "top", "frame"], 17 | }); 18 | -------------------------------------------------------------------------------- /mathml-zoom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mathml-zoom", 3 | "title": "MathML Zoom", 4 | "id": "jid1-umYSoqNlFpsxzQ@jetpack", 5 | "main": "lib/main.js", 6 | "description": "Allow zooming mathematical formulas", 7 | "author": "Frédéric Wang", 8 | "license": "MPL 2.0", 9 | "version": "0.4" 10 | } 11 | -------------------------------------------------------------------------------- /mathparser/README.md: -------------------------------------------------------------------------------- 1 | # mathparser 2 | 3 | **This is no longer maintained. It is deprecated in favor of TeXZilla.** 4 | 5 | This is a set of patches to add a mathparser extension to mozilla-central. 6 | 7 | 1. Install [GNU bison](http://www.gnu.org/software/bison/) if it is not present on your system. 8 | 2. Apply these patches to your sources from mozilla-central, in that order: 9 | mathparser-base.diff, mathparser-utils.diff, A mathparser-dictionary.diff, 10 | mathparser-simple.diff A mathparser-itex.diff. 11 | 3. Enable the mathparser extension: 12 | `ac_add_options --enable-extensions=default,mathparser` 13 | 4. Compile Mozilla 14 | 5. Once the build is complete, you should have mathparser available in the 15 | add-on menu. You should also find an XPI in your objdir: 16 | `dist/xpi-stage/mathparser.xpi` 17 | 18 | You can test the parser with `mathzilla-parser.xhtml` 19 | 20 | For itex2MML commands, see 21 | - 22 | - 23 | - 24 | 25 | The idl interface of nsIMathParser is: 26 | 27 | const short MATHPARSER_MODE_SIMPLE = 0; 28 | const short MATHPARSER_MODE_ITEX = 1; 29 | const short MATHPARSER_NUMBER_OF_MODES = 2; 30 | 31 | attribute short parsingMode; 32 | attribute boolean reportErrors; 33 | attribute boolean splitMiTokens; 34 | 35 | nsIDOMElement parse(in nsIDOMDocument aDocument, 36 | in AString aString); 37 | 38 | -------------------------------------------------------------------------------- /mathparser/mathparser-dictionary.diff: -------------------------------------------------------------------------------- 1 | # HG changeset patch 2 | # Parent b1631c81b9ed7e438a612a7707964410d5187f6b 3 | 4 | diff --git a/extensions/mathparser/src/Makefile.in b/extensions/mathparser/src/Makefile.in 5 | --- a/extensions/mathparser/src/Makefile.in 6 | +++ b/extensions/mathparser/src/Makefile.in 7 | @@ -49,16 +49,17 @@ MODULE = mathparser 8 | LIBRARY_NAME = mathparser 9 | SHORT_LIBNAME = mathpars 10 | IS_COMPONENT = 1 11 | MODULE_NAME = nsMathParser 12 | 13 | CPPSRCS += \ 14 | nsMathParser.cpp \ 15 | nsMathParserModule.cpp \ 16 | + nsMathMLOperatorDictionary.cpp \ 17 | $(NULL) 18 | 19 | EXTRA_DSO_LDOPTS = \ 20 | $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ 21 | $(XPCOM_FROZEN_LDOPTS) \ 22 | $(NSPR_LIBS) \ 23 | $(NULL) 24 | 25 | diff --git a/extensions/mathparser/src/nsMathMLOperatorDictionary.cpp b/extensions/mathparser/src/nsMathMLOperatorDictionary.cpp 26 | new file mode 100644 27 | --- /dev/null 28 | +++ b/extensions/mathparser/src/nsMathMLOperatorDictionary.cpp 29 | @@ -0,0 +1,321 @@ 30 | +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 31 | +/* vim: set ts=2 et sw=2 tw=80: */ 32 | +/* ***** BEGIN LICENSE BLOCK ***** 33 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 34 | + * 35 | + * The contents of this file are subject to the Mozilla Public License Version 36 | + * 1.1 (the "License"); you may not use this file except in compliance with 37 | + * the License. You may obtain a copy of the License at 38 | + * http://www.mozilla.org/MPL/ 39 | + * 40 | + * Software distributed under the License is distributed on an "AS IS" basis, 41 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 42 | + * for the specific language governing rights and limitations under the 43 | + * License. 44 | + * 45 | + * The Original Code is Mozilla MathML Project. 46 | + * 47 | + * The Initial Developer of the Original Code is 48 | + * The University Of Queensland. 49 | + * Portions created by the Initial Developer are Copyright (C) 1999 50 | + * the Initial Developer. All Rights Reserved. 51 | + * 52 | + * Contributor(s): 53 | + * Roger B. Sidje 54 | + * Karl Tomlinson , Mozilla Corporation 55 | + * Frederic Wang 56 | + * 57 | + * Alternatively, the contents of this file may be used under the terms of 58 | + * either the GNU General Public License Version 2 or later (the "GPL"), or 59 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 60 | + * in which case the provisions of the GPL or the LGPL are applicable instead 61 | + * of those above. If you wish to allow use of your version of this file only 62 | + * under the terms of either the GPL or the LGPL, and not to allow others to 63 | + * use your version of this file under the terms of the MPL, indicate your 64 | + * decision by deleting the provisions above and replace them with the notice 65 | + * and other provisions required by the GPL or the LGPL. If you do not delete 66 | + * the provisions above, a recipient may use your version of this file under 67 | + * the terms of any one of the MPL, the GPL or the LGPL. 68 | + * 69 | + * ***** END LICENSE BLOCK ***** */ 70 | + 71 | +// Note: this file is adapted from layout/mathml/nsMathMLOperators.cpp 72 | + 73 | +#include "nsCOMPtr.h" 74 | + 75 | +#include "nsIComponentManager.h" 76 | +#include "nsIPersistentProperties2.h" 77 | +#include "nsNetUtil.h" 78 | + 79 | +#include "nsDataHashtable.h" 80 | +#include "nsCRT.h" 81 | +#include "nsMathMLOperatorDictionary.h" 82 | + 83 | +static PRInt32 gTableRefCount = 0; 84 | +static PRUint32 gOperatorCount = 0; 85 | +static nsDataHashtable *gOperatorTable; 86 | +static bool gInitialized = false; 87 | + 88 | +#define kNotFound -1 89 | +static const PRUnichar kNullCh = PRUnichar('\0'); 90 | +static const PRUnichar kDashCh = PRUnichar('#'); 91 | +static const PRUnichar kColonCh = PRUnichar(':'); 92 | + 93 | +static void 94 | +SetBooleanProperty(nsOperatorFlags* aOperatorFlags, 95 | + nsString aName) 96 | +{ 97 | + if (aName.IsEmpty()) 98 | + return; 99 | + 100 | + else if (aName.EqualsLiteral("largeop")) 101 | + *aOperatorFlags |= NS_MATHML_OPERATOR_LARGEOP; 102 | + else if (aName.EqualsLiteral("movablelimits")) 103 | + *aOperatorFlags |= NS_MATHML_OPERATOR_MOVABLELIMITS; 104 | +} 105 | + 106 | +static bool 107 | +SetOperator(nsOperatorFlags aForm, 108 | + const nsCString& aOperator, 109 | + nsString& aAttributes) 110 | + 111 | +{ 112 | + // aOperator is in the expanded format \uNNNN\uNNNN ... 113 | + // First compress these Unicode points to the internal nsString format 114 | + PRInt32 i = 0; 115 | + nsAutoString name, value; 116 | + PRInt32 len = aOperator.Length(); 117 | + PRUnichar c = aOperator[i++]; 118 | + PRUint32 state = 0; 119 | + PRUnichar uchar = 0; 120 | + while (i <= len) { 121 | + if (0 == state) { 122 | + if (c != '\\') 123 | + return false; 124 | + if (i < len) 125 | + c = aOperator[i]; 126 | + i++; 127 | + if (('u' != c) && ('U' != c)) 128 | + return false; 129 | + if (i < len) 130 | + c = aOperator[i]; 131 | + i++; 132 | + state++; 133 | + } 134 | + else { 135 | + if (('0' <= c) && (c <= '9')) 136 | + uchar = (uchar << 4) | (c - '0'); 137 | + else if (('a' <= c) && (c <= 'f')) 138 | + uchar = (uchar << 4) | (c - 'a' + 0x0a); 139 | + else if (('A' <= c) && (c <= 'F')) 140 | + uchar = (uchar << 4) | (c - 'A' + 0x0a); 141 | + else return false; 142 | + if (i < len) 143 | + c = aOperator[i]; 144 | + i++; 145 | + state++; 146 | + if (5 == state) { 147 | + value.Append(uchar); 148 | + uchar = 0; 149 | + state = 0; 150 | + } 151 | + } 152 | + } 153 | + if (0 != state) return false; 154 | + 155 | + // Quick return when the caller doesn't care about the attributes and just 156 | + // wants to know if this is a valid operator (this is the case at the first 157 | + // pass of the parsing of the dictionary in InitOperators()) 158 | + if (!aForm) return true; 159 | + 160 | + value.AppendInt(aForm); 161 | + nsAutoString key(value); 162 | + nsOperatorFlags flags = aForm; 163 | + 164 | +#ifdef NS_DEBUG 165 | + NS_LossyConvertUTF16toASCII str(aAttributes); 166 | +#endif 167 | + // Loop over the space-delimited list of attributes 168 | + aAttributes.Append(kNullCh); // put an extra null at the end 169 | + PRUnichar* start = aAttributes.BeginWriting(); 170 | + PRUnichar* end = start; 171 | + while ((kNullCh != *start) && (kDashCh != *start)) { 172 | + name.SetLength(0); 173 | + value.SetLength(0); 174 | + // skip leading space, the dash amounts to the end of the line 175 | + while ((kNullCh!=*start) && (kDashCh!=*start) && 176 | + nsCRT::IsAsciiSpace(*start)) { 177 | + ++start; 178 | + } 179 | + end = start; 180 | + // look for ':' 181 | + while ((kNullCh!=*end) && (kDashCh!=*end) && !nsCRT::IsAsciiSpace(*end) && 182 | + (kColonCh!=*end)) { 183 | + ++end; 184 | + } 185 | + // If ':' is not found, then it's a boolean property 186 | + bool IsBooleanProperty = (kColonCh != *end); 187 | + *end = kNullCh; // end segment here 188 | + // this segment is the name 189 | + if (start < end) { 190 | + name.Assign(start); 191 | + } 192 | + if (IsBooleanProperty) { 193 | + SetBooleanProperty(&flags, name); 194 | + } else { 195 | + start = ++end; 196 | + // look for space or end of line 197 | + while ((kNullCh!=*end) && (kDashCh!=*end) && 198 | + !nsCRT::IsAsciiSpace(*end)) { 199 | + ++end; 200 | + } 201 | + *end = kNullCh; // end segment here 202 | + } 203 | + start = ++end; 204 | + } 205 | + 206 | + // Add operator to hash table 207 | + gOperatorTable->Put(key, flags); 208 | + 209 | + return true; 210 | +} 211 | + 212 | +static nsresult 213 | +InitOperators(void) 214 | +{ 215 | + bool tableInitialized = false; 216 | + 217 | + // Load the property file containing the Operator Dictionary 218 | + nsresult rv; 219 | + nsCOMPtr mathfontProp; 220 | + rv = NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(mathfontProp), 221 | + NS_LITERAL_CSTRING("resource://gre/res/fonts/mathfont.properties")); 222 | + if (NS_FAILED(rv)) return rv; 223 | + 224 | + // Parse the Operator Dictionary in two passes. 225 | + // The first pass is to count the number of operators; the second pass is to 226 | + // allocate the necessary space for them and to add them in the hash table. 227 | + for (PRInt32 pass = 1; pass <= 2; pass++) { 228 | + nsCOMPtr iterator; 229 | + if (NS_SUCCEEDED(mathfontProp->Enumerate(getter_AddRefs(iterator)))) { 230 | + bool more; 231 | + PRUint32 index = 0; 232 | + nsCAutoString name; 233 | + nsAutoString attributes; 234 | + while ((NS_SUCCEEDED(iterator->HasMoreElements(&more))) && more) { 235 | + nsCOMPtr element; 236 | + if (NS_SUCCEEDED(iterator->GetNext(getter_AddRefs(element)))) { 237 | + if (NS_SUCCEEDED(element->GetKey(name)) && 238 | + NS_SUCCEEDED(element->GetValue(attributes))) { 239 | + // expected key: operator.\uNNNN.{infix,postfix,prefix} 240 | + if ((21 <= name.Length()) && (0 == name.Find("operator.\\u"))) { 241 | + name.Cut(0, 9); // 9 is the length of "operator."; 242 | + PRInt32 len = name.Length(); 243 | + nsOperatorFlags form = 0; 244 | + if (kNotFound != name.RFind(".infix")) { 245 | + form = NS_MATHML_OPERATOR_FORM_INFIX; 246 | + len -= 6; // 6 is the length of ".infix"; 247 | + } 248 | + else if (kNotFound != name.RFind(".postfix")) { 249 | + form = NS_MATHML_OPERATOR_FORM_POSTFIX; 250 | + len -= 8; // 8 is the length of ".postfix"; 251 | + } 252 | + else if (kNotFound != name.RFind(".prefix")) { 253 | + form = NS_MATHML_OPERATOR_FORM_PREFIX; 254 | + len -= 7; // 7 is the length of ".prefix"; 255 | + } 256 | + else continue; // input is not applicable 257 | + name.SetLength(len); 258 | + if (2 == pass) { // allocate space and start the storage 259 | + if (!gOperatorTable) { 260 | + if (0 == gOperatorCount) return NS_ERROR_UNEXPECTED; 261 | + gOperatorTable = new nsDataHashtable(); 263 | + if (!gOperatorTable) return NS_ERROR_OUT_OF_MEMORY; 264 | + gOperatorTable->Init(gOperatorCount); 265 | + } 266 | + } 267 | + else { 268 | + form = 0; // to quickly return from SetOperator() at pass 1 269 | + } 270 | + // See if the operator should be retained 271 | + if (SetOperator(form, name, attributes)) { 272 | + index++; 273 | + if (1 == pass) gOperatorCount = index; 274 | + } 275 | + } 276 | + } 277 | + } 278 | + } 279 | + } 280 | + } 281 | + return NS_OK; 282 | +} 283 | + 284 | +static nsresult 285 | +InitGlobals() 286 | +{ 287 | + gInitialized = true; 288 | + nsresult rv = NS_ERROR_OUT_OF_MEMORY; 289 | + rv = InitOperators(); 290 | + if (NS_FAILED(rv)) 291 | + nsMathMLOperatorDictionary::CleanUp(); 292 | + return rv; 293 | +} 294 | + 295 | +void 296 | +nsMathMLOperatorDictionary::CleanUp() 297 | +{ 298 | + if (gOperatorTable) { 299 | + delete gOperatorTable; 300 | + gOperatorTable = nsnull; 301 | + } 302 | +} 303 | + 304 | +void 305 | +nsMathMLOperatorDictionary::AddRefTable(void) 306 | +{ 307 | + gTableRefCount++; 308 | +} 309 | + 310 | +void 311 | +nsMathMLOperatorDictionary::ReleaseTable(void) 312 | +{ 313 | + if (0 == --gTableRefCount) { 314 | + CleanUp(); 315 | + } 316 | +} 317 | + 318 | +static bool 319 | +GetOperatorData(const nsString& aOperator, 320 | + nsOperatorFlags &aFlag) 321 | +{ 322 | + nsAutoString key(aOperator); 323 | + key.AppendInt(aFlag); 324 | + return gOperatorTable->Get(key, &aFlag); 325 | +} 326 | + 327 | +void 328 | +nsMathMLOperatorDictionary::LookupOperator(const nsString& aOperator, 329 | + nsOperatorFlags& aFlags) 330 | +{ 331 | + if (!gInitialized) { 332 | + InitGlobals(); 333 | + } 334 | + 335 | + if (gOperatorTable) { 336 | + nsOperatorFlags flags; 337 | + flags = NS_MATHML_OPERATOR_FORM_INFIX; 338 | + if (GetOperatorData(aOperator, flags)) { 339 | + aFlags |= flags; 340 | + } 341 | + flags = NS_MATHML_OPERATOR_FORM_POSTFIX; 342 | + if (GetOperatorData(aOperator, flags)) { 343 | + aFlags |= flags; 344 | + } 345 | + flags = NS_MATHML_OPERATOR_FORM_PREFIX; 346 | + if (GetOperatorData(aOperator, flags)) { 347 | + aFlags |= flags; 348 | + } 349 | + } 350 | +} 351 | diff --git a/extensions/mathparser/src/nsMathMLOperatorDictionary.h b/extensions/mathparser/src/nsMathMLOperatorDictionary.h 352 | --- a/extensions/mathparser/src/nsMathMLOperatorDictionary.h 353 | +++ b/extensions/mathparser/src/nsMathMLOperatorDictionary.h 354 | @@ -67,13 +67,17 @@ enum { 355 | 356 | #define NS_MATHML_OPERATOR_IS_MOVABLELIMITS(_flags) \ 357 | (NS_MATHML_OPERATOR_MOVABLELIMITS == \ 358 | ((_flags) & NS_MATHML_OPERATOR_MOVABLELIMITS)) 359 | 360 | class nsMathMLOperatorDictionary 361 | { 362 | public: 363 | + static void AddRefTable(void); 364 | + static void ReleaseTable(void); 365 | + static void CleanUp(); 366 | + 367 | static void LookupOperator(const nsString& aOperator, 368 | - nsOperatorFlags& aFlags) {} 369 | + nsOperatorFlags& aFlags); 370 | }; 371 | 372 | #endif // nsMathMLOperatorDictionary_h__ 373 | diff --git a/extensions/mathparser/src/nsMathParser.cpp b/extensions/mathparser/src/nsMathParser.cpp 374 | --- a/extensions/mathparser/src/nsMathParser.cpp 375 | +++ b/extensions/mathparser/src/nsMathParser.cpp 376 | @@ -42,20 +42,22 @@ 377 | #include "nsIClassInfoImpl.h" 378 | 379 | NS_IMPL_CLASSINFO(nsMathParser, NULL, 0, NS_MATHPARSER_CID) 380 | NS_IMPL_ISUPPORTS1_CI(nsMathParser, nsIMathParser) 381 | 382 | nsMathParser::nsMathParser() : mParsingMode(MATHPARSER_MODE_SIMPLE), 383 | mReportErrors(true), mSplitMiTokens(false), mConsoleService(nsnull) 384 | { 385 | + nsMathMLOperatorDictionary::AddRefTable(); 386 | } 387 | 388 | nsMathParser::~nsMathParser() 389 | { 390 | + nsMathMLOperatorDictionary::ReleaseTable(); 391 | } 392 | 393 | NS_IMETHODIMP 394 | nsMathParser::GetParsingMode(MathParserMode *aParsingMode) 395 | { 396 | *aParsingMode = mParsingMode; 397 | return NS_OK; 398 | } 399 | -------------------------------------------------------------------------------- /mathparser/mathzilla-parser.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 37 | 39 | 40 | 41 | 42 | Mathzilla Parser 43 | 96 | 97 | 98 | 99 | 100 | 101 | 159 | 160 |
161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /texzilla/data/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/texzilla/data/logo.png -------------------------------------------------------------------------------- /texzilla/data/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 10 | 13 | n 14 | 15 | 16 | √n 18 | 19 | 20 | -------------------------------------------------------------------------------- /texzilla/lib/main.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | var data = require("sdk/self").data; 6 | var action = require("sdk/ui/button/action") 7 | var tabs = require("sdk/tabs"); 8 | 9 | action.ActionButton({ 10 | id: "texzilla-editor", 11 | label: "TeXZilla Editor", 12 | icon: { 13 | "32": data.url("logo.png"), 14 | }, 15 | onClick: function() { 16 | tabs.open(data.url("index.html")); 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /texzilla/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "texzilla", 3 | "title": "texzilla", 4 | "id": "jid1-eTgiiG7aEZuPdg@jetpack", 5 | "main": "lib/main.js", 6 | "description": "Add-on giving access to the TeXZilla parser.", 7 | "author": "Frédéric Wang", 8 | "license": "MPL 2.0", 9 | "version": "0.9.9" 10 | } 11 | -------------------------------------------------------------------------------- /texzilla/test/test-TeXZilla.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | var TeXZilla = require("./TeXZilla"); 6 | var {Cc, Ci} = require("chrome"); 7 | TeXZilla.setDOMParser(Cc["@mozilla.org/xmlextras/domparser;1"]. 8 | createInstance(Ci.nsIDOMParser)); 9 | 10 | exports["test toMathMLString"] = function(assert) { 11 | assert.ok(TeXZilla.toMathMLString("\\sqrt{\\frac{x}{2}+y}") == 'x2+y\\sqrt{\\frac{x}{2}+y}', "toMathMLString works"); 12 | } 13 | 14 | exports["test toMathML and getTeXSource"] = function(assert) { 15 | assert.ok(TeXZilla.getTeXSource(TeXZilla.toMathML("\\sqrt{\\frac{x}{2}+y}")) == "\\sqrt{\\frac{x}{2}+y}", "toMathML and getTeXSource work"); 16 | } 17 | 18 | require("sdk/test").run(exports); 19 | -------------------------------------------------------------------------------- /xpi/mathparser-0.1.xpi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/xpi/mathparser-0.1.xpi -------------------------------------------------------------------------------- /xpi/mathzilla-0.1.xpi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fred-wang/Mathzilla/ff1382d1e340511ff3b2039cd12fff53fa6a3328/xpi/mathzilla-0.1.xpi --------------------------------------------------------------------------------