Skip to content

Commit

Permalink
Added tmfrac for Arabic mixed fractions
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi committed Jan 5, 2019
1 parent 52032b5 commit 892bbd3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ The extension provides the following additional TeX commands to be typeset an Ar
* **Translate a TeX input** `\transx`
* **Translate a text input** `\transt` e.g. `\transt{\text{if}}{إذا}` for the Math piecewise equations.
* **Translate a TeX input with Arabic symbols** `\transs`: e.g. `\transs{A_b}{أ_ب}`
* **Translate Arabic numbers** `\transn`: e.g. `\transn{2000,000.195}`
* **Translate Mixed Fractions** `\tmfrac`: e.g. `\tmfrac{10}{1}{2}` to denote `10.5` as a mixed fraction

- Basic variable and function names translation:
* `A` --> `أ`
Expand Down
2 changes: 1 addition & 1 deletion dist/arabic.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions dist/unpacked/arabic.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ MathJax.Hub.Register.StartupHook('TeX Jax Ready', function () {
'alwaysar': 'MarkAsArabic',
'fliph': 'HandleFlipHorizontal',
'transn': 'TranslateNumbers',
'tmfrac': 'TranslateMixedFraction',
'transx': 'TranslateTeX',
'transt': 'TranslateText',
'transs': 'TranslateSymbols'
Expand Down Expand Up @@ -531,6 +532,18 @@ MathJax.Hub.Register.StartupHook('TeX Jax Ready', function () {
var helper = Arabic.Symbols(english, arabicText);
return helper.call(this, name);
},
TranslateMixedFraction: function () {
var integer = this.GetArgument(name);
var numerator = this.GetArgument(name);
var denominator = this.GetArgument(name);

var tex = MathJax.Extension.Arabic.TeX(
integer + '\\frac{' + numerator + '}{' + denominator + '}',
'\\alwaysar{\\fliph{\\frac{' + numerator + '}{' + denominator + '}' + integer + '}}'
);

return tex.call(this, name);
},
MarkAsArabic: function (name) {
var originalLang = this.stack.env.lang;

Expand Down
13 changes: 13 additions & 0 deletions src/tex.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ MathJax.Hub.Register.StartupHook('TeX Jax Ready', function () {
'alwaysar': 'MarkAsArabic',
'fliph': 'HandleFlipHorizontal',
'transn': 'TranslateNumbers',
'tmfrac': 'TranslateMixedFraction',
'transx': 'TranslateTeX',
'transt': 'TranslateText',
'transs': 'TranslateSymbols'
Expand Down Expand Up @@ -347,6 +348,18 @@ MathJax.Hub.Register.StartupHook('TeX Jax Ready', function () {
var helper = Arabic.Symbols(english, arabicText);
return helper.call(this, name);
},
TranslateMixedFraction: function () {
var integer = this.GetArgument(name);
var numerator = this.GetArgument(name);
var denominator = this.GetArgument(name);

var tex = MathJax.Extension.Arabic.TeX(
integer + '\\frac{' + numerator + '}{' + denominator + '}',
'\\alwaysar{\\fliph{\\frac{' + numerator + '}{' + denominator + '}' + integer + '}}'
);

return tex.call(this, name);
},
MarkAsArabic: function (name) {
var originalLang = this.stack.env.lang;

Expand Down
12 changes: 12 additions & 0 deletions testcases/testcases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,15 @@ equations:
\times\textcolor{coral}{7}&=\textcolor{blue}{\transn{7,658}y}\\
\textcolor{coral}{3}\times\textcolor{coral}{4}\times
\textcolor{coral}{5}&=\textcolor{blue}{60}\end{align}
- id: "103"
name: "Mixed Fractions"
note:
equation: >
\tmfrac{20}{1}{2}
- id: "104"
name: "Mixed Fractions with Symbols"
note:
equation: >
\tmfrac{x}{y}{z}

0 comments on commit 892bbd3

Please sign in to comment.