npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mathjax4arabic

v1.1.4

Published

Arabic preprocessing helpers and RTL rendering support for MathJax v4.

Readme

MathJax4Arabic

مكتبة جاهزة للاستخدام تعرض معادلات MathJax باتجاه عربي وتترجم الرموز الشائعة تلقائياً، بدون أن يكتب المستخدم إعدادات MathJax أو يضيف CSS يدوياً.

الاستخدام الأسرع عبر CDN

انسخ سطراً واحداً فقط داخل الصفحة:

<script type="module" src="https://cdn.jsdelivr.net/npm/mathjax4arabic@1/dist/browser.js"></script>

بعدها اكتب معادلاتك كالمعتاد:

<p lang="ar" dir="rtl">
  حل المعادلة: \( x^2 + y^2 = r^2 \)
</p>

مدخل المتصفح يقوم تلقائياً بـ:

  • ضبط window.MathJax بالحزم المطلوبة مثل html و ams.
  • حقن أنماط الانعكاس العربية المطلوبة.
  • تحميل MathJax v4 من CDN عند عدم وجوده.
  • تحويل المعادلات داخل الصفحة ثم استدعاء MathJax لعرضها.

الاستخدام عبر npm

npm install mathjax4arabic

للمتصفح أو تطبيقات React/Vite/Next التي تعمل على العميل:

import "mathjax4arabic/browser";

ثم استخدم TeX داخل HTML أو JSX بدون إعدادات إضافية:

export default function Formula() {
  return <div lang="ar" dir="rtl">\( a x^2 + b x + c = 0 \)</div>;
}

الاستخدام المتقدم الاختياري

الاستخدام الافتراضي لا يتطلب شيئاً. إذا احتجت التحكم اليدوي، يمكنك استيراد المدخل الأساسي:

import ArabicMathJax from "mathjax4arabic";

const tex = ArabicMathJax.preprocess("x = 12", { forceArabic: true });

وتتوفر دوال اختيارية:

  • preprocess(tex, options) لمعالجة TeX فقط.
  • typesetArabic(target, options) لمعالجة عنصر أو محدد CSS ثم عرضه.
  • renderPage(options) لمعالجة الصفحة كاملة.
  • configureMathJax(overrides) لإنشاء إعداد MathJax جاهز مع تعديلات اختيارية.
  • installAutoSetup(options) لتفعيل التهيئة التلقائية يدوياً عند الحاجة.
  • setMathFont(fontFamily) لتغيير خط الرموز والمعادلات الرياضية في الصفحة.
  • applyMathFont(fontFamily, target) لتطبيق خط معين على الصفحة كلها أو على عنصر محدد.

اختيار خط رياضي متقدم

الاستخدام الافتراضي يختار خطاً عربياً مناسباً تلقائياً. إذا أراد المستخدم تخصيص خط الرموز والمعادلات الرياضية، يمكنه فعل ذلك بإعداد اختياري متقدم:

<script type="module">
  import ArabicMathJax from "https://cdn.jsdelivr.net/npm/mathjax4arabic@1/dist/browser.js";

  ArabicMathJax.setMathFont('"Amiri", "Times New Roman", serif');
</script>

أو على عنصر محدد فقط:

ArabicMathJax.applyMathFont('"Noto Naskh Arabic", serif', "#math-area");

وعند التهيئة اليدوية المتقدمة:

ArabicMathJax.installAutoSetup({
  mathFont: '"Amiri", "Noto Naskh Arabic", serif'
});

أوامر TeX المدعومة

يمكنك استخدام TeX عادي، أو أوامر المكتبة عند الحاجة:

| الأمر | الوصف | مثال | | --- | --- | --- | | \ar{...} | يترجم المحتوى في الصفحات العربية | \ar{x = 1} | | \alwaysar{...} | يترجم دائماً | \alwaysar{a + b} | | \transx{EN}{AR} | يختار فرعاً رياضياً حسب اللغة | \transx{x}{س} | | \transt{EN}{AR} | يختار نصاً حسب اللغة مع دعم المزج مع رموز رياضية | \transt{where x > 0}{حيث س > ٠} | | \transn{123} | يترجم الأرقام | \transn{123} |

ما الذي يترجم تلقائياً؟

  • الأرقام الغربية 0-9 إلى العربية الهندية ٠-٩.
  • المتغيرات الشائعة مثل x, y, z, a, b إلى رموز عربية.
  • الدوال مثل \sin, \cos, \tan, \log, \ln, \lim.
  • بعض الفواصل وعلامات الترقيم داخل السياق الرياضي.
  • اتجاه البنية الرياضية عبر \class{mjx-ar-flip}{...} المدعوم رسمياً من MathJax.

البناء والتطوير

npm test
npm run typecheck
npm run build

الترخيص

MIT — مستوحاة من مكتبة arabic-mathjax الأصلية، مع إعادة بناء حديثة للعمل مع MathJax v4.