Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Arabic numerals and decimal separator #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SamirElkhatib
Copy link

Added two options:
useHindiNumerals: defaults to true. If false uses the Arabic (modern) numerals (0, 1, 2...)
useArabicDecimalSeparator: defaults to true. Uses the comma instead of the point as the decimal separator

Requires proper documentation and building...

Added two options:
useHindiNumerals: defaults to true. If false uses the Arabic (modern) numerals (0, 1, 2...)
useArabicDecimalSeparator: defaults to true. Uses the comma instead of the point as the decimal separator
Require proper documentation
@OmarIthawi OmarIthawi self-requested a review October 31, 2018 11:18
src/tex.js Outdated Show resolved Hide resolved
@OmarIthawi
Copy link
Owner

@SamirElkhatib thank you so much for the contribution! I'll take a look at it in a week or so.

Please excuse my limited availability, as I've never expected anyone to contribute 😄

Copy link
Owner

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SamirElkhatib for the updates!

We're close! I've added a couple of other notes.

'6.': '\u0666\u066b',
'7.': '\u0667\u066b',
'8.': '\u0668\u066b',
'9.': '\u0669\u066b',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SamirElkhatib please use literal values like ٩ instead of \u0669. There's a build step to do that conversion. Let's keep the work human friendly.

},

// support for arabic (modern) numerals
arabicNumbersMap: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this is needed. We can disable the numbersMap instead of doing this. Right?


// Default options
if (useHindiNumeral == null) useHindiNumeral = true
if (useArabicDecimalSeparator == null) useArabicDecimalSeparator = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that we identify a better pattern than this e.g. use falsey variables like: disableArabicDecimalSeparator and disableHinduArabicNumbers

var englishNumbersRegExp = /[0-9]/g;
if(useHindiNumeral) var numbersMap = arConfig.numbersMap;
else var numbersMap = arConfig.arabicNumbersMap
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the section above needs refactoring:

  • The for looop isn't protected with hasOwnProperty
  • Avoid for-loops and use RegExp replace functions like var mapped = text.replace(englishNumbersRegExp, replaceNumber);

@@ -57,6 +57,34 @@ MathJax.Extension.Arabic = {
'8': '٨',
'9': '٩'
},
// numbers with arabic decimal separator ','
arabicDecimalSeparator: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this map, we can use RegExp instead without the need to repeat what's in numbersMap. I can add more details if you'd like.

@OmarIthawi
Copy link
Owner

@SamirElkhatib it would be great if you can update the README as we go. You're adding cool features to the plugin, let's make them visible!

@OmarIthawi
Copy link
Owner

@SamirElkhatib #7 have added the support for Arabic decimal separator, so there's no need to do the same work in this PR again.

Could you please refactor it to focus on the optional Arabic numerals only? Thanks!

@OmarIthawi OmarIthawi mentioned this pull request Feb 18, 2019
@OmarIthawi
Copy link
Owner

@shadinaif do we still need this pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants