3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/z-load-complete.js:
--------------------------------------------------------------------------------
1 | // This file starting with the letter `z` to make sure it gets concatenated last!
2 | MathJax.Ajax.loadComplete("[arabic]/unpacked/arabic.js");
3 |
--------------------------------------------------------------------------------
/testcases/test-extensions/hacks.js:
--------------------------------------------------------------------------------
1 | MathJax.Hub.Config({
2 | // Arabic decimal mark
3 | Arabic: {
4 | numbersMap: {
5 | '\\.': '٫'
6 | }
7 | }
8 | });
9 |
10 | MathJax.Ajax.loadComplete("[Test]/hacks.js");
11 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | main:
2 | image: node:9.4.0
3 |
4 | working_dir: /code/
5 | environment:
6 | PORT: "1990"
7 | command: node node_modules/.bin/gulp
8 |
9 | ports:
10 | - "1990:1990"
11 |
12 | volumes:
13 | - ".:/code/"
14 |
--------------------------------------------------------------------------------
/src/css/html-css.css:
--------------------------------------------------------------------------------
1 | /* HTML-CSS Output Jax CSS */
2 | .MathJax .mfliph {
3 | display: inline-block !important;
4 | -moz-transform: scaleX(-1);
5 | -webkit-transform: scaleX(-1);
6 | -o-transform: scaleX(-1);
7 | transform: scaleX(-1);
8 | -ms-filter: fliph;
9 | filter: fliph;
10 | }
11 |
12 | .MathJax .mar {
13 | font-style: normal !important;
14 | }
15 | .MathJax .mar > span {
16 | font-style: normal !important;
17 | }
18 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | correct_perms:
2 | sudo chown -R $$USER .
3 | chmod -R a+r .
4 | find extensions/ testcases/ -type d -exec chmod a+x {} \;
5 |
6 |
7 | init:
8 | docker-compose run main npm install
9 | make correct_perms
10 |
11 | deploy:
12 | cat extensions/arabic/arabic.js > static/arabic/arabic.js
13 | cd static/ \
14 | && git add arabic/arabic.js \
15 | && git push \
16 | && (git ci -m "Auto update on `date`" || true) \
17 | && git push
18 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | root = true
4 |
5 | # Unix-style newlines with a newline ending every file
6 | [*]
7 | end_of_line = lf
8 | insert_final_newline = true
9 | charset = utf-8
10 |
11 |
12 | # Matches multiple files with brace expansion notation
13 | # Set default charset
14 | [*.js]
15 | indent_style = space
16 | indent_size = 2
17 |
18 |
19 | # Tab indentation (no size specified)
20 | [Makefile]
21 | indent_style = tab
22 |
23 |
24 | # Matches the exact files either package.json or .travis.yml
25 | [{package.json,.*.yml,*.html}]
26 | indent_style = space
27 | indent_size = 2
28 |
--------------------------------------------------------------------------------
/testcases/testcases.css:
--------------------------------------------------------------------------------
1 | /* Test Cases Styles */
2 | #wrapper {
3 | margin: 0 auto;
4 | padding-top: 40px;
5 | }
6 |
7 | table {
8 | margin: 0 auto;
9 | }
10 |
11 | hr {
12 | margin-top: 30px;
13 | margin-bottom: 30px;
14 | }
15 |
16 | .MathJax_Display {
17 | margin: 20px auto;
18 | }
19 |
20 | .inline-link {
21 | opacity: 0;
22 | display: block;
23 | position: absolute;
24 | background-color: white;
25 | border: solid white;
26 | border-width: 0 4px;
27 | box-shadow: 1px 1px 3px black;
28 | border-radius: 4px;
29 | }
30 |
31 | td:hover .inline-link {
32 | opacity: 0.5;
33 | }
34 |
35 | td:hover .inline-link:hover {
36 | opacity: 1;
37 | }
38 |
39 | .hidden {
40 | display: none;
41 | }
42 |
--------------------------------------------------------------------------------
/testcases/test-extensions/phys2.js:
--------------------------------------------------------------------------------
1 | //MathJax.Hub.Register.StartupHook('Arabic TeX Startup', function () {
2 | // var ArabicText = MathJax.Arabic.ArabicText;
3 | // var ArabicTeX = MathJax.Arabic.ArabicTeX;
4 | // var ArabicSymbols = MathJax.Arabic.ArabicSymbols;
5 | //
6 | // MathJax.Arabic.AugmentDict({
7 | // // Solar Energy Course Part #2
8 | // //'mass': 'MaterialMassAr', 'm', 'ك',
9 | // //'capacity': 'CapacityAr': 'C', 'ح',
10 | // //'materialheat': 'MaterialHeat': 'p', 'ن',
11 | // //'temperature': 'Temperature': 'T', 'د',
12 | // //'latentheat': 'LatentHeat': 'Q', 'ح_ك',
13 | // //'latentenergy': 'LatentEnergy': '\\lambda', 'ط_ك',
14 | // //'heatflux': 'HeatFlux': 'Q_\\text{cond}', 'ح_ت',
15 | // //'thermalconduct': 'ThermalConductivity': 'K', 'ت_ح',
16 | // //'area': 'Area': 'A', 'م',
17 | // //'heattransfcoeff': 'HeatTransferCoefficient': 'h', 'م.ح',
18 | // });
19 | //});
20 |
21 | MathJax.Ajax.loadComplete("[Test]/phys2.js");
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "arabic-mathjax",
3 | "version": "2.1.1",
4 | "description": "A docker container for developing my MathJax plugins.",
5 | "main": "gulpfile.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/OmarIthawi/arabic-mathjax.git"
12 | },
13 | "devDependencies": {
14 | "browser-sync": "^2.26.3",
15 | "gulp": "^4.0.2",
16 | "gulp-uglifycss": "^1.1.0",
17 | "gulp-concat": "^2.6.0",
18 | "gulp-order": "^1.2.0",
19 | "gulp-plumber": "1.0.0",
20 | "gulp-replace": "^0.5.4",
21 | "gulp-uglify": "^1.2.0",
22 | "run-sequence": "^1.2.1"
23 | },
24 | "author": "Omar Al-Ithawi ",
25 | "generator": "Quench ",
26 | "license": "MIT",
27 | "bugs": {
28 | "url": "https://github.com/OmarIthawi/arabic-mathjax/issues"
29 | },
30 | "homepage": "http://www.omardo.com/arabic-mathjax/index.html",
31 | "dependencies": {}
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Edraak.org, Omar Al-Ithawi and contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/dist/License.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2015 Edraak.org, Omar Al-Ithawi and contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/testcases/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Edraak.org, Omar Al-Ithawi and contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/license.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * The MIT License
3 | *
4 | * Copyright (c) 2015-2016 Edraak.org, Omar Al-Ithawi and contributors.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
--------------------------------------------------------------------------------
/testcases/render-equations.js:
--------------------------------------------------------------------------------
1 | var renderEquations = function () {
2 | var $ = jQuery;
3 |
4 | var loadTestCases = function (cb) {
5 | $.get('testcases.yml', function (testcasesYAMLStr) {
6 | cb(jsyaml.load(testcasesYAMLStr));
7 | });
8 | };
9 |
10 |
11 | $.get('equations.html', function (template) {
12 | loadTestCases(function (testCases) {
13 | var rendered = Mustache.render(template, {
14 | equations: testCases.equations.reverse()
15 | });
16 |
17 | $('#equations').html(rendered);
18 |
19 |
20 | var render = function () {
21 | var $scriptTemplate = $('
48 |
49 |
202 |
203 |
204 |
--------------------------------------------------------------------------------
/dist/arabic.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * The MIT License
3 | *
4 | * Copyright (c) 2015-2016 Edraak.org, Omar Al-Ithawi and contributors.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | !function(){var a=["mfrac","mi","mn","mo","mroot","mrow","ms","msqrt","mstyle","msubsup","mtext"];MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function(){var t=MathJax.OutputJax.CommonHTML,r=t.unknownChar;t.Augment({unknownChar:function(){var a=MathJax.Hub.config.Arabic.arabicUnicodeStart,t=MathJax.Hub.config.Arabic.arabicUnicodeEnd,n=r.apply(this,arguments),e=n.n,i=a<=e&&e<=t;return i&&(n.type="char"),n}}),MathJax.Hub.Register.StartupHook("Arabic TeX Ready",function(){var t=MathJax.ElementJax.mml,r=function(a){var r=t[a].prototype.toCommonHTML;t[a].Augment({toCommonHTML:function(){var a=r.apply(this,arguments);if(this.arabicFlipH){var t=document.createElement("span");for(t.className="mfliph","ar"===this.arabicFontLang&&(t.className+=" mar");a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t)}return a}})};["mtr","mtd"].concat(a).forEach(r),MathJax.Hub.Register.StartupHook("CommonHTML multiline Ready",function(){var a=t.mbase.prototype.CHTMLaddLine;t.mbase.Augment({CHTMLaddLine:function(){var t=arguments[0];t&&t.querySelector(".mfliph")&&(t.className="mfliph"),a.apply(this,arguments)}}),MathJax.Hub.Startup.signal.Post("Arabic CommonHTML multiline Ready")}),MathJax.Hub.Register.StartupHook("CommonHTML mtable Ready",function(){r("mtable"),MathJax.Hub.Startup.signal.Post("Arabic CommonHTML mtable Ready")}),MathJax.Hub.Startup.signal.Post("Arabic CommonHTML Ready")})}),MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function(){MathJax.Hub.Register.StartupHook("Arabic TeX Ready",function(){var t=MathJax.ElementJax.mml,r=function(a){var r=t[a].prototype.toHTML;t[a].Augment({toHTML:function(){var a=r.apply(this,arguments);if(this.arabicFlipH){var t=document.createElement("span");for(t.className="mfliph","ar"===this.arabicFontLang&&(t.className+=" mar");a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t)}return a}})};a.forEach(r),MathJax.Hub.Register.StartupHook("HTML-CSS multiline Ready",function(){var a=t.mbase.prototype.HTMLaddLine;t.mbase.Augment({HTMLaddLine:function(){var t=arguments[0];t&&t.querySelector(".mfliph")&&(t.className="mfliph"),a.apply(this,arguments)}}),MathJax.Hub.Startup.signal.Post("Arabic HTML-CSS multiline Ready")}),MathJax.Hub.Register.StartupHook("HTML-CSS mtable Ready",function(){r("mtable"),MathJax.Hub.Startup.signal.Post("Arabic HTML-CSS mtable Ready")}),MathJax.Hub.Startup.signal.Post("Arabic HTML-CSS Ready")})})}(),MathJax.Extension.Arabic={version:"2.1.1",config:MathJax.Hub.CombineConfig("Arabic",{dict:{Zero:["zero","Text",["0","\u0635\u0641\u0631"]],Radius:["radius","Text",["r","\u0646\u0642"]],Area:["Area","Text",["A","\u0645"]],Charge:["charge","TeX",["C","\\fliph{\\text{\u069b}}"]]},identifiersMap:{a:"\u0623",b:"\u0628",c:"\u062c\u0640",x:"\u0633",y:"\u0635",z:"\u0639",n:"\u0646",f:"\u0642",g:"\u062c\u0640",h:"\u0647\u0640",k:"\u0643",r:"\u0631",t:"\u062a",d:"\u062f",e:"\u0647\u0640",m:"\u0645",l:"\u0644",sin:"\u062c\u0627",cos:"\u062c\u062a\u0627",tan:"\u0638\u0627",cot:"\u0638\u062a\u0627",sec:"\u0642\u0627",csc:"\u0642\u062a\u0627",log:"\u0644\u0648"},numbersMap:{0:"\u0660",1:"\u0661",2:"\u0662",3:"\u0663",4:"\u0664",5:"\u0665",6:"\u0666",7:"\u0667",8:"\u0668",9:"\u0669"},arabicUnicodeStart:1536,arabicUnicodeEnd:1791,arabicLanguageRegExp:/([\u0600-\u06FF]+)/g,arabicDecimalSplitter:"\u066b",operatorsMap:{",":"\u060c",";":"\u061b",lim:"\u0646\u0647\u0640\u0640\u0627"},isArabicPage:function(){return"ar"===document.documentElement.lang}}),TeX:function(a,t){return function(r){var n,e=MathJax.InputJax.TeX;n="ar"===this.stack.env.lang?t:a,this.Push(e.Parse(n).mml())}},Text:function(a,t){return MathJax.Extension.Arabic.TeX(a,"\\fliph{\\text{"+t+"}}")},Symbols:function(a,t){var r=t.replace(MathJax.Hub.config.Arabic.arabicLanguageRegExp,"\\fliph{\\text{$1}}");return MathJax.Extension.Arabic.TeX(a,r)},MapNumbers:function(a){var t=MathJax.Hub.config.Arabic.numbersMap,r=function(a){return t[a]};return a.replace(/[0-9]/g,r)}},MathJax.Hub.Startup.signal.Post("Arabic TeX Startup"),MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var a=MathJax.InputJax.TeX,t=MathJax.Extension.Arabic,r=a.Parse.prototype.mmlToken,n=MathJax.Hub.config.Arabic.dict,e=function(){var a=/[\\^$.*+?()[\]{}|]/g;return function(t){return t.replace(a,"\\$&")}}(),i=function(a){var t=Object.keys(a).sort(function(a,t){return t.length-a.length});return new RegExp(t.map(e).join("|"),"gi")};a.Definitions.Add({macros:{ar:"HandleArabic",alwaysar:"MarkAsArabic",fliph:"HandleFlipHorizontal",transn:"TranslateNumbers",tmfrac:"TranslateMixedFraction",transx:"TranslateTeX",transt:"TranslateText",transs:"TranslateSymbols"}});var o=a.Stack.Item.array,c=o.prototype.clearEnv,u=o.prototype.Init;o.Augment({Init:function(){u.apply(this,arguments),this.copyEnv=!0},clearEnv:function(){var a=this.env.lang;c.apply(this,arguments),a&&(this.env.lang=a)}}),a.Definitions.Add({macros:function(){var a={};return Object.keys(n).forEach(function(t){var r=n[t][0];a[r]=t}),a}()}),a.Parse.Augment(function(){var a={};return Object.keys(n).forEach(function(r){var e=n[r][1],i=n[r][2];a[r]=t[e].apply(null,i)}),a}()),a.Parse.Augment({flipHorizontal:function(a){return a.arabicFlipH=!a.arabicFlipH,a},arabicNumber:function(a){var r=a.data[0].data[0],n=t.MapNumbers(r);return n!==r&&(a.data[0].data[0]=n,a.arabicFontLang="ar"),this.flipHorizontal(a)},arabicIdentifier:function(){var a=MathJax.Hub.config.Arabic.identifiersMap,t=i(a),r=function(t){return a[t.toLowerCase()]};return function(a){var n=a.data[0].data[0];if("chars"===a.data[0].type){var e=n.replace(t,r);e!==n&&(a.data[0].data[0]=e,a.arabicFontLang="ar")}return this.flipHorizontal(a)}}(),arabicOperator:function(){var a=MathJax.Hub.config.Arabic.operatorsMap,t=i(a),r=function(t){return a[t]};return function(a){var n=a.data[0].data[0],e=n.replace(t,r);return e!==n&&(a=this.flipHorizontal(a),a.arabicFontLang="ar",a.data[0].data[0]=e),a}}(),_getArgumentMML:function(a){var t=this.ParseArg(a);return t.inferred&&1===t.data.length?t=t.data[0]:delete t.inferred,t},mmlToken:function(a){var t=r.call(this,a);return"ar"===this.stack.env.lang&&this.markArabicToken(t),t},markArabicToken:function(a){return"mn"===a.type?this.arabicNumber(a):"mi"===a.type?this.arabicIdentifier(a):"mo"===a.type?this.arabicOperator(a):a},HandleArabic:function(a){MathJax.Hub.config.Arabic.isArabicPage&&this.MarkAsArabic(a)},TranslateTeX:function(a){var r=this.GetArgument(a),n=this.GetArgument(a),e=t.TeX(r,n);return e.call(this,a)},TranslateText:function(a){var r=this.GetArgument(a),n=this.GetArgument(a),e=t.Text(r,n);return e.call(this,a)},TranslateNumbers:function(a){var r=this.GetArgument(a),n=MathJax.Hub.config.Arabic.arabicDecimalSplitter,e=t.MapNumbers(r,!0).replace(/,/g,"").replace(/\./g,n),i=MathJax.Extension.Arabic.TeX(r,"\\fliph{\\text{"+e+"}}");return i.call(this,a)},TranslateSymbols:function(a){var r=this.GetArgument(a),n=this.GetArgument(a),e=t.Symbols(r,n);return e.call(this,a)},TranslateMixedFraction:function(){var a=this.GetArgument(name),t=this.GetArgument(name),r=this.GetArgument(name),n=MathJax.Extension.Arabic.TeX(a+"\\frac{"+t+"}{"+r+"}","\\alwaysar{\\fliph{\\frac{"+t+"}{"+r+"}"+a+"}}");return n.call(this,name)},MarkAsArabic:function(a){var t=this.stack.env.lang;this.stack.env.lang="ar";var r=this._getArgumentMML(a);this.stack.env.lang=t,this.Push(this.flipHorizontal(r))},HandleFlipHorizontal:function(a){var t=this._getArgumentMML(a);this.Push(this.flipHorizontal(t))}}),MathJax.Hub.Startup.signal.Post("Arabic TeX Ready")}),MathJax.Ajax.loadComplete("[arabic]/arabic.js");
--------------------------------------------------------------------------------
/dist/README.md:
--------------------------------------------------------------------------------
1 | # MathJax Arabic Extension
2 | This is an extension to MathJax (v2.5+), that provides basic Arabic support to MathJax.
3 |
4 | The extension so far only supports TeX input with HTML-CSS output. However, support to other input and output
5 | jaxes is possible.
6 |
7 | ## Key Features
8 | It provides the following:
9 |
10 | - Flip the Equation and render it the Right-to-left (RTL) way!
11 | - Translate commonly used identifiers and functions.
12 |
13 | ## How to Use the Extension
14 | ### Install the Extension
15 | First you'd like to [install](http://mathjax.readthedocs.org/en/latest/installation.html)
16 | and [configure](http://mathjax.readthedocs.org/en/latest/configuration.html) MathJax in your page.
17 |
18 | Then you'll need to include the `arabic.js` as an extension, here's an example configuration:
19 |
20 | MathJax.Ajax.config.path["arabic"] = "https://cdn.rawgit.com/OmarIthawi/arabic-mathjax/v1.2/dist";
21 |
22 | MathJax.Hub.Config({
23 | extensions: [
24 | "[arabic]/arabic.js"
25 | ]
26 | });
27 |
28 |
29 | ### The Amiri Font
30 | The extension relies (sort of) on the
31 | [Amiri font](https://www.google.com/fonts#UsePlace:use/Collection:Amiri)
32 | to render beautifully (kinda).
33 |
34 | One way to include the font is to add the following CSS from Google Fonts:
35 |
36 |
37 |
38 |
39 | Also you'd like to set the font as the undefined family. Because of a bug in MathJax, you should stick with a single
40 | font-family e.g. use `Amiri` or `serif` but not `Amiri, serif`.
41 |
42 | MathJax.Hub.Config({
43 | 'HTML-CSS': {
44 | undefinedFamily: 'Amiri'
45 | }
46 | });
47 |
48 | ### Typeset an Arabic Equation
49 | The extension provides the following additional TeX commands to be typeset an Arabic equation:
50 |
51 | 1. **`\alwaysar`**
52 |
53 | `\alwaysar{EQUATION}` A macro to translate and RTL'ize an `EQUATION`, where `EQUATION` can be anything from
54 | `x = 1` to `e^x=\lim_{n\to\infty}`.
55 |
56 | Wrap any TeX equation with it, and it *should* just work.
57 |
58 | 2. **`\ar`**
59 |
60 | `\ar{EQUATION}` (**Recommended**) A similar macro to `\alwaysar{EQUATION}`, but it only translate and RTL'ize the equation if the page is Arabic.
61 |
62 | Bellow is an example equation:
63 |
64 | \ar{x=1}
65 |
66 | The above would render **x=1** beautifully in an English page, while it should render **س=١** in an Arabic page
67 | even more beautifully ( in my opinion :) ).
68 |
69 | ## Supported Features
70 | - Flip everything (almost) including:
71 | * Parentheses `()`, braces `{}`, and brackets `[]`
72 | * Things that should be flipped like: Integration `∫`, Root `√` and Sigma `Σ`
73 |
74 | - Doesn't flip the things that should't be flipped,
75 | like the following letters: Theta `Θ`, Pi `π`, and Epsilon `ε`
76 |
77 | - Translate the basic math functions:
78 | * `\sin` --> `جا`
79 | * `\cos` --> `تا`
80 | * `\tan` --> `ظا`
81 | * `\cot` --> `ظتا`
82 | * `\sec` --> `قا`
83 | * `\csc` --> `قتا`
84 | * `\log` --> `لو`
85 |
86 |
87 | - Translate `\lim` into `نها`, Although some would prefer `غــا`, but that's just
88 | a preference, may someone can patch it to support `ar_IQ` for the Iraqi people!
89 |
90 | - Render the Arabic numbers (١, ٢, ٣) instead of (1, 2, 3), which is awesome!
91 |
92 | - The following new commands:
93 | * **Circle radius:** `\radius` Translates to `r` and `نق`
94 | * **Area of circle:** (and other stuff) `\Area` Translates to `A` and `م`
95 | * **Arabic Zero:** `\zero` Renders the `صفر`in Arabic while printing normal `0` in English.
96 | The former is usually preferred by the Arabic Math textbooks.
97 | * **Charge Sheen Character:** `\charge` Renders the
98 | [`ڛ` (Unicode U+069B)](https://www.compart.com/en/unicode/U+069B)
99 | character in Arabic while printing `C` in English.
100 |
101 | This sheen character is then replaced by a more appropriate Ruqa (رقعة) character, when using
102 | the [modified Amiri font](https://github.com/OmarIthawi/amiri/releases).
103 |
104 | - Bilingual commands, which prints the first argument on English pages and the second argument on Arabic pages.
105 | Useful to to build bilingual equations for strings that the extension provides no explicit support to.
106 | **Note** The first (English) argument is always a TeX input, while the second (Arabic) can be
107 | TeX, Text or TeX with Symbols, depending on the command you're using.
108 | * **Translate a TeX input** `\transx`
109 | * **Translate a text input** `\transt` e.g. `\transt{\text{if}}{إذا}` for the Math piecewise equations.
110 | * **Translate a TeX input with Arabic symbols** `\transs`: e.g. `\transs{A_b}{أ_ب}`
111 | * **Translate Arabic numbers** `\transn`: e.g. `\transn{2000,000.195}`
112 | * **Translate Mixed Fractions** `\tmfrac`: e.g. `\tmfrac{10}{1}{2}` to denote `10.5` as a mixed fraction
113 |
114 | - Basic variable and function names translation:
115 | * `A` --> `أ`
116 | * `B` --> `ب`
117 | * `C` --> `حـ`
118 | * `a` --> `ا`
119 | * `b` --> `ب`
120 | * `c` --> `حـ`
121 | * `d` --> `د`
122 | * `e` --> `هـ`
123 | * `m` --> `م`
124 | * `l` --> `ل`
125 | * `n` --> `ن`
126 | * `f` --> `ق`
127 | * `g` --> `حـ`
128 | * `h` --> `هـ`
129 | * `k` --> `ك`
130 | * `r` --> `ر`
131 | * `t` --> `ت`
132 | * `x` --> `س`
133 | * `y` --> `ص`
134 | * `z` --> `ع`
135 |
136 |
137 | - Translation to other identifiers and operators like limits (`\lim`), sine, cosine and tan.
138 |
139 |
140 | - A very configurable translation utility to provide English/Arabic TeX
141 | commands (same command, with language-dependent output).
142 |
143 | - A configurable page language detection (defaults to the `lang` attribute of `` tag).
144 |
145 | - It is generally configurable, but I haven't documented how to do it!
146 |
147 | ## Experimental Stuff
148 | Additional extensions for Physics and some Chemistry units and symbols exists,
149 | however, it is not tested/developed well. If you're curious, you can take a look
150 | at the following extensions:
151 |
152 | - [`phys1.js`](https://github.com/OmarIthawi/arabic-mathjax/blob/master/testcases/test-extensions/phys1.js):
153 | Contains general physics units like Farad and speed of light. Interesting stuff, but haven't had proper
154 | testing and usage (yet).
155 |
156 | - [`phys2.js`](https://github.com/OmarIthawi/arabic-mathjax/blob/master/testcases/test-extensions/phys2.js):
157 | Additional advanced physics units that I don't understand as much!
158 |
159 | - [`hacks.js`](https://github.com/OmarIthawi/arabic-mathjax/blob/master/testcases/test-extensions/hacks.js):
160 | A hack to convert the English decimal mark from `.` to `٫`
161 | ([Arabic decimal mark, Unicode 0x066b](http://www.unicodemap.org/details/0x066B/index.html)).
162 | Although the Arabic decimal mark exists, I'm not sure if it is
163 | [common enough](https://en.wikipedia.org/wiki/Decimal_mark#Countries_using_Arabic_numerals_with_decimal_comma)
164 | to include it in the main installation.
165 |
166 | # How to Contribute
167 | Well, just issue a pull request to this repo and ping me (my GitHub username is @OmarIthawi).
168 | Even better, grab my docker-based development environment from here so you can have a better development experience:
169 |
170 | $ git clone https://github.com/OmarIthawi/arabic-mathjax.git
171 | $ cd arabic-mathjax
172 | $ git clone git@github.com:mathjax/MathJax mathjax
173 | $ cd mathjax
174 | $ git checkout 2.7.1
175 | $ cd ..
176 | $ make init
177 | $ docker-compose up
178 |
179 |
180 | # License
181 | The MIT License
182 |
183 | Copyright (c) 2015-2016 Edraak.org, Omar Al-Ithawi and contributors.
184 |
185 | # Author
186 |
187 | - Omar Al-Ithawi
188 |
189 | # A bit of a Background
190 | Why this plugin exists? Well, I could tell you an interesting story like I wanted to change the world,
191 | but frankly we needed it to display Math equations for our Arabic learners at [Edraak.org](https://www.edraak.org),
192 | and therefore I made it.
193 |
194 | Well, it does change the world somehow, at the least in the eyes of our learners ^\_^
195 |
196 | # Fork Info
197 | The original repository is:
198 | - https://github.com/Edraak/arabic-mathjax
199 |
200 | This fork aims to be more updated and supported.
201 |
--------------------------------------------------------------------------------
/testcases/responsive.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Arabic.js Responsive Test Case
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
36 |
37 |
38 |
65 |
66 |
112 |
113 |
114 |
177 |
178 |
179 |
180 |