@drghaliasri/butex 5.5.5 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/document.js +36 -0
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +36 -0
- package/dist/document.mjs.map +1 -1
- package/dist/document2.d.mts +4 -2
- package/dist/document2.d.ts +4 -2
- package/dist/document2.js +173 -20
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +173 -20
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.global.js +79 -14
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +79 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -14
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +254 -7
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +254 -7
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2.d.mts +5 -3
- package/dist/react-document2.d.ts +5 -3
- package/dist/react-document2.js +375 -33
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +375 -33
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +35 -0
- package/dist/react.d.ts +35 -0
- package/dist/react.js +1277 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1277 -7
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.mjs
CHANGED
|
@@ -70,7 +70,9 @@ function butexBasmalaDisplayTex() {
|
|
|
70
70
|
}
|
|
71
71
|
function butexBasmalaDisplayLatex() {
|
|
72
72
|
return `\\[
|
|
73
|
-
|
|
73
|
+
\\begin{gathered}
|
|
74
|
+
${BASMALA_LINES.map((line) => butexMaghribiDisplayTex(line)).join(" \\\\\n")}
|
|
75
|
+
\\end{gathered}
|
|
74
76
|
\\]`;
|
|
75
77
|
}
|
|
76
78
|
function butexInColumnMaketitleHook() {
|
|
@@ -2066,6 +2068,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2066
2068
|
category: "operators1",
|
|
2067
2069
|
Tex: "\\neq",
|
|
2068
2070
|
mirror: true,
|
|
2071
|
+
compileMirror: true,
|
|
2069
2072
|
Label: "\u2260",
|
|
2070
2073
|
title: "\u0644\u0627 \u064A\u0633\u0627\u0648\u064A",
|
|
2071
2074
|
svg_path: null
|
|
@@ -2105,6 +2108,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2105
2108
|
Tex: "\\leq",
|
|
2106
2109
|
mirror: true,
|
|
2107
2110
|
displayMirror: false,
|
|
2111
|
+
compileMirror: true,
|
|
2108
2112
|
Label: "\u2264",
|
|
2109
2113
|
title: "\u0623\u0635\u063A\u0631 \u0645\u0646 \u0623\u0648 \u064A\u0633\u0627\u0648\u064A",
|
|
2110
2114
|
svg_path: null
|
|
@@ -2115,6 +2119,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2115
2119
|
Tex: "\\geq",
|
|
2116
2120
|
mirror: true,
|
|
2117
2121
|
displayMirror: false,
|
|
2122
|
+
compileMirror: true,
|
|
2118
2123
|
Label: "\u2265",
|
|
2119
2124
|
title: "\u0623\u0643\u0628\u0631 \u0645\u0646 \u0623\u0648 \u064A\u0633\u0627\u0648\u064A",
|
|
2120
2125
|
svg_path: null
|
|
@@ -2125,6 +2130,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2125
2130
|
Tex: "\\coloneqq",
|
|
2126
2131
|
mirror: true,
|
|
2127
2132
|
displayMirror: false,
|
|
2133
|
+
compileMirror: true,
|
|
2128
2134
|
Label: "\u2254",
|
|
2129
2135
|
title: "\u064A\u0639\u0631\u0641 \u0628\u0623\u0646\u0647 \u064A\u0633\u0627\u0648\u064A",
|
|
2130
2136
|
svg_path: null
|
|
@@ -2135,6 +2141,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2135
2141
|
Tex: "\\eqqcolon",
|
|
2136
2142
|
mirror: true,
|
|
2137
2143
|
displayMirror: false,
|
|
2144
|
+
compileMirror: true,
|
|
2138
2145
|
Label: "\u2255",
|
|
2139
2146
|
title: "\u064A\u0633\u0627\u0648\u064A \u0628\u0627\u0644\u062A\u0639\u0631\u064A\u0641",
|
|
2140
2147
|
svg_path: null
|
|
@@ -2146,6 +2153,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2146
2153
|
Tex: "\\propto",
|
|
2147
2154
|
mirror: true,
|
|
2148
2155
|
displayMirror: false,
|
|
2156
|
+
compileMirror: true,
|
|
2149
2157
|
Label: "\u221D",
|
|
2150
2158
|
title: "\u064A\u062A\u0646\u0627\u0633\u0628 \u0645\u0639",
|
|
2151
2159
|
svg_path: null
|
|
@@ -2156,6 +2164,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2156
2164
|
Tex: "\\in",
|
|
2157
2165
|
mirror: true,
|
|
2158
2166
|
displayMirror: false,
|
|
2167
|
+
compileMirror: true,
|
|
2159
2168
|
Label: "\u2208",
|
|
2160
2169
|
title: "\u064A\u0646\u062A\u0645\u064A \u0625\u0644\u0649",
|
|
2161
2170
|
svg_path: null
|
|
@@ -2176,6 +2185,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2176
2185
|
Tex: "\\subset",
|
|
2177
2186
|
mirror: true,
|
|
2178
2187
|
displayMirror: false,
|
|
2188
|
+
compileMirror: true,
|
|
2179
2189
|
Label: "\u2282",
|
|
2180
2190
|
title: "\u0645\u062C\u0645\u0648\u0639\u0629 \u062C\u0632\u0626\u064A\u0629 \u0645\u0646",
|
|
2181
2191
|
svg_path: null
|
|
@@ -2186,6 +2196,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2186
2196
|
Tex: "\\supset",
|
|
2187
2197
|
mirror: true,
|
|
2188
2198
|
displayMirror: false,
|
|
2199
|
+
compileMirror: true,
|
|
2189
2200
|
Label: "\u2283",
|
|
2190
2201
|
title: "\u0645\u062C\u0645\u0648\u0639\u0629 \u0634\u0627\u0645\u0644\u0629 \u0644\u0640",
|
|
2191
2202
|
svg_path: null
|
|
@@ -2196,6 +2207,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2196
2207
|
Tex: "\\subseteq",
|
|
2197
2208
|
mirror: true,
|
|
2198
2209
|
displayMirror: false,
|
|
2210
|
+
compileMirror: true,
|
|
2199
2211
|
Label: "\u2286",
|
|
2200
2212
|
title: "\u0645\u062C\u0645\u0648\u0639\u0629 \u062C\u0632\u0626\u064A\u0629 \u0623\u0648 \u062A\u0633\u0627\u0648\u064A",
|
|
2201
2213
|
svg_path: null
|
|
@@ -2206,6 +2218,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2206
2218
|
Tex: "\\supseteq",
|
|
2207
2219
|
mirror: true,
|
|
2208
2220
|
displayMirror: false,
|
|
2221
|
+
compileMirror: true,
|
|
2209
2222
|
Label: "\u2287",
|
|
2210
2223
|
title: "\u0645\u062C\u0645\u0648\u0639\u0629 \u0634\u0627\u0645\u0644\u0629 \u0623\u0648 \u062A\u0633\u0627\u0648\u064A",
|
|
2211
2224
|
svg_path: null
|
|
@@ -2246,6 +2259,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2246
2259
|
Tex: "\\nsubseteq",
|
|
2247
2260
|
mirror: true,
|
|
2248
2261
|
displayMirror: false,
|
|
2262
|
+
compileMirror: true,
|
|
2249
2263
|
Label: "\u2288",
|
|
2250
2264
|
title: "\u0644\u064A\u0633\u062A \u0645\u062C\u0645\u0648\u0639\u0629 \u062C\u0632\u0626\u064A\u0629 \u0623\u0648 \u062A\u0633\u0627\u0648\u064A",
|
|
2251
2265
|
svg_path: null
|
|
@@ -2256,6 +2270,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2256
2270
|
Tex: "\\nsupseteq",
|
|
2257
2271
|
mirror: true,
|
|
2258
2272
|
displayMirror: false,
|
|
2273
|
+
compileMirror: true,
|
|
2259
2274
|
Label: "\u2289",
|
|
2260
2275
|
title: "\u0644\u064A\u0633\u062A \u0645\u062C\u0645\u0648\u0639\u0629 \u0634\u0627\u0645\u0644\u0629 \u0623\u0648 \u062A\u0633\u0627\u0648\u064A",
|
|
2261
2276
|
svg_path: null
|
|
@@ -2303,6 +2318,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2303
2318
|
Tex: "\\ddots",
|
|
2304
2319
|
mirror: true,
|
|
2305
2320
|
displayMirror: false,
|
|
2321
|
+
compileMirror: true,
|
|
2306
2322
|
Label: "\u22F1",
|
|
2307
2323
|
title: "\u0646\u0642\u0627\u0637 \u0642\u0637\u0631\u064A\u0629",
|
|
2308
2324
|
svg_path: null
|
|
@@ -2322,6 +2338,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2322
2338
|
category: "operators3",
|
|
2323
2339
|
Tex: "\\implies",
|
|
2324
2340
|
mirror: true,
|
|
2341
|
+
compileMirror: true,
|
|
2325
2342
|
Label: "\u21D2",
|
|
2326
2343
|
title: "\u064A\u0633\u062A\u0644\u0632\u0645",
|
|
2327
2344
|
svg_path: null
|
|
@@ -2331,6 +2348,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2331
2348
|
category: "operators3",
|
|
2332
2349
|
Tex: "\\impliedby",
|
|
2333
2350
|
mirror: true,
|
|
2351
|
+
compileMirror: true,
|
|
2334
2352
|
Label: "\u21D0",
|
|
2335
2353
|
title: "\u0645\u0633\u062A\u0644\u0632\u0645 \u0645\u0646",
|
|
2336
2354
|
svg_path: null
|
|
@@ -2349,6 +2367,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2349
2367
|
category: "operators3",
|
|
2350
2368
|
Tex: "\\Longrightarrow",
|
|
2351
2369
|
mirror: true,
|
|
2370
|
+
compileMirror: true,
|
|
2352
2371
|
Label: "\u27F9",
|
|
2353
2372
|
title: "\u0633\u0647\u0645 \u0645\u0632\u062F\u0648\u062C \u0637\u0648\u064A\u0644 \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
2354
2373
|
svg_path: null
|
|
@@ -2358,6 +2377,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2358
2377
|
category: "operators3",
|
|
2359
2378
|
Tex: "\\Longleftarrow",
|
|
2360
2379
|
mirror: true,
|
|
2380
|
+
compileMirror: true,
|
|
2361
2381
|
Label: "\u27F8",
|
|
2362
2382
|
title: "\u0633\u0647\u0645 \u0645\u0632\u062F\u0648\u062C \u0637\u0648\u064A\u0644 \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
2363
2383
|
svg_path: null
|
|
@@ -2367,6 +2387,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2367
2387
|
category: "operators3",
|
|
2368
2388
|
Tex: "\\to",
|
|
2369
2389
|
mirror: true,
|
|
2390
|
+
compileMirror: true,
|
|
2370
2391
|
Label: "\u2192",
|
|
2371
2392
|
title: "\u064A\u0624\u0648\u0644 \u0625\u0644\u0649",
|
|
2372
2393
|
svg_path: null
|
|
@@ -2376,6 +2397,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2376
2397
|
category: "operators3",
|
|
2377
2398
|
Tex: "\\rightleftharpoons",
|
|
2378
2399
|
mirror: true,
|
|
2400
|
+
compileMirror: true,
|
|
2379
2401
|
Label: "\u21CC",
|
|
2380
2402
|
title: "\u0627\u062A\u0632\u0627\u0646",
|
|
2381
2403
|
svg_path: null
|
|
@@ -2385,6 +2407,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2385
2407
|
category: "operators3",
|
|
2386
2408
|
Tex: "\\leftarrow",
|
|
2387
2409
|
mirror: true,
|
|
2410
|
+
compileMirror: true,
|
|
2388
2411
|
Label: "\u2190",
|
|
2389
2412
|
title: "\u0633\u0647\u0645 \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
2390
2413
|
svg_path: null
|
|
@@ -2394,6 +2417,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2394
2417
|
category: "operators3",
|
|
2395
2418
|
Tex: "\\rightarrow",
|
|
2396
2419
|
mirror: true,
|
|
2420
|
+
compileMirror: true,
|
|
2397
2421
|
Label: "\u2192",
|
|
2398
2422
|
title: "\u0633\u0647\u0645 \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
2399
2423
|
svg_path: null
|
|
@@ -2403,6 +2427,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2403
2427
|
category: "operators3",
|
|
2404
2428
|
Tex: "\\Leftarrow",
|
|
2405
2429
|
mirror: true,
|
|
2430
|
+
compileMirror: true,
|
|
2406
2431
|
Label: "\u21D0",
|
|
2407
2432
|
title: "\u0633\u0647\u0645 \u0645\u0632\u062F\u0648\u062C \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
2408
2433
|
svg_path: null
|
|
@@ -2412,6 +2437,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2412
2437
|
category: "operators3",
|
|
2413
2438
|
Tex: "\\Rightarrow",
|
|
2414
2439
|
mirror: true,
|
|
2440
|
+
compileMirror: true,
|
|
2415
2441
|
Label: "\u21D2",
|
|
2416
2442
|
title: "\u0633\u0647\u0645 \u0645\u0632\u062F\u0648\u062C \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
2417
2443
|
svg_path: null
|
|
@@ -2421,6 +2447,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2421
2447
|
category: "operators3",
|
|
2422
2448
|
Tex: "\\leftharpoonup",
|
|
2423
2449
|
mirror: true,
|
|
2450
|
+
compileMirror: true,
|
|
2424
2451
|
Label: "\u21BC",
|
|
2425
2452
|
title: "\u0633\u0647\u0645 \u062E\u0637\u0627\u0641\u064A \u0639\u0644\u0648\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
2426
2453
|
svg_path: null
|
|
@@ -2430,6 +2457,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2430
2457
|
category: "operators3",
|
|
2431
2458
|
Tex: "\\rightharpoonup",
|
|
2432
2459
|
mirror: true,
|
|
2460
|
+
compileMirror: true,
|
|
2433
2461
|
Label: "\u21C0",
|
|
2434
2462
|
title: "\u0633\u0647\u0645 \u062E\u0637\u0627\u0641\u064A \u0639\u0644\u0648\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
2435
2463
|
svg_path: null
|
|
@@ -2439,6 +2467,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2439
2467
|
category: "operators3",
|
|
2440
2468
|
Tex: "\\leftharpoondown",
|
|
2441
2469
|
mirror: true,
|
|
2470
|
+
compileMirror: true,
|
|
2442
2471
|
Label: "\u21BD",
|
|
2443
2472
|
title: "\u0633\u0647\u0645 \u062E\u0637\u0627\u0641\u064A \u0633\u0641\u0644\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631",
|
|
2444
2473
|
svg_path: null
|
|
@@ -2448,6 +2477,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2448
2477
|
category: "operators3",
|
|
2449
2478
|
Tex: "\\rightharpoondown",
|
|
2450
2479
|
mirror: true,
|
|
2480
|
+
compileMirror: true,
|
|
2451
2481
|
Label: "\u21C1",
|
|
2452
2482
|
title: "\u0633\u0647\u0645 \u062E\u0637\u0627\u0641\u064A \u0633\u0641\u0644\u064A \u0625\u0644\u0649 \u0627\u0644\u064A\u0645\u064A\u0646",
|
|
2453
2483
|
svg_path: null
|
|
@@ -2458,6 +2488,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2458
2488
|
category: "integrals",
|
|
2459
2489
|
Tex: "\\int",
|
|
2460
2490
|
mirror: true,
|
|
2491
|
+
compileMirror: true,
|
|
2461
2492
|
Label: "\u222B",
|
|
2462
2493
|
title: "\u062A\u0643\u0627\u0645\u0644",
|
|
2463
2494
|
svg_path: null
|
|
@@ -2468,6 +2499,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2468
2499
|
Tex: "\\iint",
|
|
2469
2500
|
mirror: true,
|
|
2470
2501
|
displayMirror: false,
|
|
2502
|
+
compileMirror: true,
|
|
2471
2503
|
Label: "\u222C",
|
|
2472
2504
|
title: "\u062A\u0643\u0627\u0645\u0644 \u0645\u0632\u062F\u0648\u062C",
|
|
2473
2505
|
svg_path: null
|
|
@@ -2478,6 +2510,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2478
2510
|
Tex: "\\iiint",
|
|
2479
2511
|
mirror: true,
|
|
2480
2512
|
displayMirror: false,
|
|
2513
|
+
compileMirror: true,
|
|
2481
2514
|
Label: "\u222D",
|
|
2482
2515
|
title: "\u062A\u0643\u0627\u0645\u0644 \u062B\u0644\u0627\u062B\u064A",
|
|
2483
2516
|
svg_path: null
|
|
@@ -2488,6 +2521,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2488
2521
|
Tex: "\\iiiint",
|
|
2489
2522
|
mirror: true,
|
|
2490
2523
|
displayMirror: false,
|
|
2524
|
+
compileMirror: true,
|
|
2491
2525
|
Label: "\u2A0C",
|
|
2492
2526
|
title: "\u062A\u0643\u0627\u0645\u0644 \u0631\u0628\u0627\u0639\u064A",
|
|
2493
2527
|
svg_path: null
|
|
@@ -2498,6 +2532,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2498
2532
|
Tex: "\\oint",
|
|
2499
2533
|
mirror: true,
|
|
2500
2534
|
displayMirror: false,
|
|
2535
|
+
compileMirror: true,
|
|
2501
2536
|
Label: "\u222E",
|
|
2502
2537
|
title: "\u062A\u0643\u0627\u0645\u0644 \u0645\u063A\u0644\u0642",
|
|
2503
2538
|
svg_path: null
|
|
@@ -2508,6 +2543,7 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2508
2543
|
Tex: "\\oiint",
|
|
2509
2544
|
mirror: true,
|
|
2510
2545
|
displayMirror: false,
|
|
2546
|
+
compileMirror: true,
|
|
2511
2547
|
Label: "\u222F",
|
|
2512
2548
|
title: "\u062A\u0643\u0627\u0645\u0644 \u0633\u0637\u062D\u064A \u0645\u063A\u0644\u0642",
|
|
2513
2549
|
svg_path: null
|
|
@@ -2518,12 +2554,76 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
2518
2554
|
Tex: "\\oiiint",
|
|
2519
2555
|
mirror: true,
|
|
2520
2556
|
displayMirror: false,
|
|
2557
|
+
compileMirror: true,
|
|
2521
2558
|
Label: "\u2230",
|
|
2522
2559
|
title: "\u062A\u0643\u0627\u0645\u0644 \u062D\u062C\u0645\u064A \u0645\u063A\u0644\u0642",
|
|
2523
2560
|
svg_path: null
|
|
2524
2561
|
}
|
|
2525
2562
|
};
|
|
2526
2563
|
var MIRRORED_OPERATOR_TEX = Object.values(ATOMIC_OPERATOR_COMMANDS).filter((command) => command.mirror).map((command) => command.Tex).sort((a, b) => b.length - a.length);
|
|
2564
|
+
var COMPILE_MIRRORED_OPERATOR_TEX = Object.values(ATOMIC_OPERATOR_COMMANDS).filter((command) => "compileMirror" in command && command.compileMirror).map((command) => command.Tex).sort((a, b) => b.length - a.length);
|
|
2565
|
+
function matchingMirroredOperatorFrom(tex, index, operatorTexList) {
|
|
2566
|
+
for (const operatorTex of operatorTexList) {
|
|
2567
|
+
if (!tex.startsWith(operatorTex, index)) {
|
|
2568
|
+
continue;
|
|
2569
|
+
}
|
|
2570
|
+
const next = tex[index + operatorTex.length];
|
|
2571
|
+
if (next != null && /[A-Za-z]/.test(next)) {
|
|
2572
|
+
continue;
|
|
2573
|
+
}
|
|
2574
|
+
return operatorTex;
|
|
2575
|
+
}
|
|
2576
|
+
return null;
|
|
2577
|
+
}
|
|
2578
|
+
function findMatchingBrace(tex, openIndex) {
|
|
2579
|
+
let depth = 0;
|
|
2580
|
+
for (let index = openIndex; index < tex.length; index += 1) {
|
|
2581
|
+
const char = tex[index];
|
|
2582
|
+
if (char === "\\") {
|
|
2583
|
+
index += 1;
|
|
2584
|
+
continue;
|
|
2585
|
+
}
|
|
2586
|
+
if (char === "{") {
|
|
2587
|
+
depth += 1;
|
|
2588
|
+
} else if (char === "}") {
|
|
2589
|
+
depth -= 1;
|
|
2590
|
+
if (depth === 0) {
|
|
2591
|
+
return index;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
return -1;
|
|
2596
|
+
}
|
|
2597
|
+
function mirrorBuTeXOperatorsInTex(tex, options = {}) {
|
|
2598
|
+
const mirroredOperatorTex = options.target === "compile" ? COMPILE_MIRRORED_OPERATOR_TEX : MIRRORED_OPERATOR_TEX;
|
|
2599
|
+
let result = "";
|
|
2600
|
+
let index = 0;
|
|
2601
|
+
while (index < tex.length) {
|
|
2602
|
+
if (tex.startsWith("\\butexmirror{", index)) {
|
|
2603
|
+
const end = findMatchingBrace(tex, index + "\\butexmirror".length);
|
|
2604
|
+
if (end !== -1) {
|
|
2605
|
+
const bodyStart = index + "\\butexmirror{".length;
|
|
2606
|
+
const body = tex.slice(bodyStart, end);
|
|
2607
|
+
if (options.target === "compile" && MIRRORED_OPERATOR_TEX.includes(body) && !mirroredOperatorTex.includes(body)) {
|
|
2608
|
+
result += body;
|
|
2609
|
+
} else {
|
|
2610
|
+
result += tex.slice(index, end + 1);
|
|
2611
|
+
}
|
|
2612
|
+
index = end + 1;
|
|
2613
|
+
continue;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
const operatorTex = matchingMirroredOperatorFrom(tex, index, mirroredOperatorTex);
|
|
2617
|
+
if (operatorTex) {
|
|
2618
|
+
result += `\\butexmirror{${operatorTex}}`;
|
|
2619
|
+
index += operatorTex.length;
|
|
2620
|
+
continue;
|
|
2621
|
+
}
|
|
2622
|
+
result += tex[index];
|
|
2623
|
+
index += 1;
|
|
2624
|
+
}
|
|
2625
|
+
return result;
|
|
2626
|
+
}
|
|
2527
2627
|
function atomicOperatorCommandSpec(id) {
|
|
2528
2628
|
return Object.prototype.hasOwnProperty.call(ATOMIC_OPERATOR_COMMANDS, id) ? ATOMIC_OPERATOR_COMMANDS[id] : null;
|
|
2529
2629
|
}
|
|
@@ -3006,6 +3106,28 @@ function renderArabicLatexFromSession(session) {
|
|
|
3006
3106
|
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
3007
3107
|
}
|
|
3008
3108
|
|
|
3109
|
+
// src/editor/state.ts
|
|
3110
|
+
function appendDebug(session, command, note) {
|
|
3111
|
+
const entry = {
|
|
3112
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3113
|
+
command,
|
|
3114
|
+
activeSide: session.activeSide,
|
|
3115
|
+
englishLatex: renderEnglishLatexFromSession(session),
|
|
3116
|
+
arabicLatex: renderArabicLatexFromSession(session),
|
|
3117
|
+
renderOk: true,
|
|
3118
|
+
renderError: null,
|
|
3119
|
+
note
|
|
3120
|
+
};
|
|
3121
|
+
const nextLog = session.debugLog.concat(entry);
|
|
3122
|
+
session.debugLog = nextLog.slice(-120);
|
|
3123
|
+
}
|
|
3124
|
+
function setCurrentDigitForm(session, digitForm) {
|
|
3125
|
+
const next = cloneEditorSession(session);
|
|
3126
|
+
next.currentDigitForm = digitForm;
|
|
3127
|
+
appendDebug(next, "setCurrentDigitForm", digitForm);
|
|
3128
|
+
return next;
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3009
3131
|
// src/editor/display/delimiter.ts
|
|
3010
3132
|
var DELIMITER_CSS = `
|
|
3011
3133
|
.delim-pair {
|
|
@@ -4325,18 +4447,19 @@ function mathNodeFromSession(session, opening = "$", closing = "$") {
|
|
|
4325
4447
|
function mathNodeFromArabicSession(session, opening = "$", closing = "$") {
|
|
4326
4448
|
return mathNodeFromSession(session, opening, closing);
|
|
4327
4449
|
}
|
|
4328
|
-
function mathTokenSourceForSide(token, side) {
|
|
4450
|
+
function mathTokenSourceForSide(token, side, digitForm) {
|
|
4329
4451
|
if (!token.math || token.sourceOwner === "raw") {
|
|
4330
4452
|
return token.source;
|
|
4331
4453
|
}
|
|
4332
|
-
if (token.sourceSide === side) {
|
|
4454
|
+
if (token.sourceSide === side && digitForm === void 0) {
|
|
4333
4455
|
return token.source;
|
|
4334
4456
|
}
|
|
4335
4457
|
const result = mathTokenToEditorSession(token.math, side);
|
|
4336
4458
|
if (!result.editable) {
|
|
4337
4459
|
return token.source;
|
|
4338
4460
|
}
|
|
4339
|
-
|
|
4461
|
+
const session = digitForm === void 0 ? result.session : setCurrentDigitForm(result.session, digitForm);
|
|
4462
|
+
return mathSourceFromSession(session, side, token.opening, token.closing);
|
|
4340
4463
|
}
|
|
4341
4464
|
|
|
4342
4465
|
// src/document2/commands.ts
|
|
@@ -5136,6 +5259,19 @@ function document2KeyError(key, namespace = {}) {
|
|
|
5136
5259
|
}
|
|
5137
5260
|
|
|
5138
5261
|
// src/document2/arabicPreamble.ts
|
|
5262
|
+
function fontOptions(digitsMapping, includeScript = true) {
|
|
5263
|
+
const parts = [];
|
|
5264
|
+
if (includeScript) {
|
|
5265
|
+
parts.push("Script=Arabic");
|
|
5266
|
+
}
|
|
5267
|
+
if (digitsMapping !== "digits") {
|
|
5268
|
+
parts.push(`Mapping=${digitsMapping}`);
|
|
5269
|
+
}
|
|
5270
|
+
if (parts.length === 0) {
|
|
5271
|
+
return "";
|
|
5272
|
+
}
|
|
5273
|
+
return `[${parts.join(",")}]`;
|
|
5274
|
+
}
|
|
5139
5275
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
5140
5276
|
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
5141
5277
|
return `
|
|
@@ -5164,25 +5300,27 @@ function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
|
5164
5300
|
% save back tick for use - copy paste -> ` + "`";
|
|
5165
5301
|
}
|
|
5166
5302
|
function arabicXeLatexPreambleFont(digitsMapping = "arabicdigits") {
|
|
5167
|
-
const customFonts = NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.latexFontCommand && font.latexFontFamily).map((font) => `\\newfontfamily${font.latexFontCommand}
|
|
5303
|
+
const customFonts = NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.latexFontCommand && font.latexFontFamily).map((font) => `\\newfontfamily${font.latexFontCommand}${fontOptions(digitsMapping)}{${font.latexFontFamily}}`).join("\n");
|
|
5304
|
+
const mathFontOptions = fontOptions(digitsMapping, false);
|
|
5168
5305
|
return `
|
|
5169
5306
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
5170
5307
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
5171
|
-
%
|
|
5308
|
+
% Persian digits: Mapping=farsidigits
|
|
5309
|
+
% Arabic-Indic digits: Mapping=arabicdigits
|
|
5310
|
+
% Western digits: omit Mapping entirely
|
|
5172
5311
|
\\setdefaultlanguage[calendar=gregorian]{arabic} % from polyglossia
|
|
5173
|
-
\\setmainfont
|
|
5312
|
+
\\setmainfont${fontOptions(digitsMapping)}{Amiri}
|
|
5174
5313
|
${customFonts}
|
|
5175
|
-
\\newfontfamily\\boldarabic
|
|
5176
|
-
\\newfontfamily\\italicarabic
|
|
5314
|
+
\\newfontfamily\\boldarabic${fontOptions(digitsMapping)}{Amiri Bold}
|
|
5315
|
+
\\newfontfamily\\italicarabic${fontOptions(digitsMapping)}{Amiri Italic}
|
|
5177
5316
|
|
|
5178
5317
|
% for polyglossia url I dont know, sugggested by cursor
|
|
5179
|
-
\\newfontfamily\\arabicfonttt
|
|
5180
|
-
\\newfontfamily\\arabicfontsf
|
|
5318
|
+
\\newfontfamily\\arabicfonttt${fontOptions(digitsMapping)}{Amiri}
|
|
5319
|
+
\\newfontfamily\\arabicfontsf${fontOptions(digitsMapping)}{Amiri}
|
|
5181
5320
|
|
|
5182
5321
|
|
|
5183
5322
|
% Explicitly set math font to XITS Math
|
|
5184
|
-
%
|
|
5185
|
-
\\setmathfont[Script=Arabic , Mapping=${digitsMapping}]{XITS Math} % Ensure XITS Math is correctly installed and available
|
|
5323
|
+
\\setmathfont${mathFontOptions}{XITS Math} % Ensure XITS Math is correctly installed and available
|
|
5186
5324
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
5187
5325
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
5188
5326
|
`;
|
|
@@ -5344,8 +5482,20 @@ function getArabicXeLatexPreamble(digitsMappingOrOptions = "arabicdigits") {
|
|
|
5344
5482
|
}
|
|
5345
5483
|
|
|
5346
5484
|
// src/document2/exportLatex.ts
|
|
5485
|
+
function digitsMappingFromDigitForm(digitForm) {
|
|
5486
|
+
if (digitForm === "western") {
|
|
5487
|
+
return "digits";
|
|
5488
|
+
}
|
|
5489
|
+
if (digitForm === "persianIndic") {
|
|
5490
|
+
return "farsidigits";
|
|
5491
|
+
}
|
|
5492
|
+
return "arabicdigits";
|
|
5493
|
+
}
|
|
5347
5494
|
function mathBodyLatex(token) {
|
|
5348
|
-
if (
|
|
5495
|
+
if (token.sourceOwner === "editor") {
|
|
5496
|
+
return stripDisplayMathDelimiters(mirrorBuTeXOperatorsInTex(token.source, { target: "compile" }));
|
|
5497
|
+
}
|
|
5498
|
+
if (!token.math || token.sourceOwner === "raw") {
|
|
5349
5499
|
return stripDisplayMathDelimiters(token.source);
|
|
5350
5500
|
}
|
|
5351
5501
|
const rendered = renderMathNodeLatex(token.math);
|
|
@@ -5381,7 +5531,10 @@ ${body}
|
|
|
5381
5531
|
\\label{${token.label.trim()}}
|
|
5382
5532
|
\\end{equation}`;
|
|
5383
5533
|
}
|
|
5384
|
-
if (
|
|
5534
|
+
if (token.sourceOwner === "editor") {
|
|
5535
|
+
return mirrorBuTeXOperatorsInTex(token.source, { target: "compile" });
|
|
5536
|
+
}
|
|
5537
|
+
if (!token.math || token.sourceOwner === "raw") {
|
|
5385
5538
|
return token.source;
|
|
5386
5539
|
}
|
|
5387
5540
|
return renderMathNodeLatex(token.math);
|
|
@@ -5499,7 +5652,7 @@ function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
|
5499
5652
|
if (meta.authors.trim().length > 0) {
|
|
5500
5653
|
parts.push(`\\author{${authorLatex(meta.authors)}}`);
|
|
5501
5654
|
}
|
|
5502
|
-
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "
|
|
5655
|
+
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "western" })}}`);
|
|
5503
5656
|
return parts.join("\n");
|
|
5504
5657
|
}
|
|
5505
5658
|
function articleFrontMatterLatex(meta) {
|
|
@@ -5531,7 +5684,7 @@ function document2Latex(document2, options = {}) {
|
|
|
5531
5684
|
${body}` : body;
|
|
5532
5685
|
}
|
|
5533
5686
|
const preamble = getArabicXeLatexPreamble({
|
|
5534
|
-
digitsMapping: options.digitsMapping ??
|
|
5687
|
+
digitsMapping: options.digitsMapping ?? digitsMappingFromDigitForm(options.digitForm),
|
|
5535
5688
|
twocolumn
|
|
5536
5689
|
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
5537
5690
|
return `${preamble}
|
|
@@ -5787,8 +5940,8 @@ function remapSelectionAfterRangeMove(selection, direction) {
|
|
|
5787
5940
|
}
|
|
5788
5941
|
|
|
5789
5942
|
// src/document2/previewModel.ts
|
|
5790
|
-
function mathTex(token, equationSide) {
|
|
5791
|
-
return mathTokenSourceForSide(token, equationSide);
|
|
5943
|
+
function mathTex(token, equationSide, digitForm) {
|
|
5944
|
+
return mathTokenSourceForSide(token, equationSide, digitForm);
|
|
5792
5945
|
}
|
|
5793
5946
|
function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
|
|
5794
5947
|
return field.tokens.map((token) => {
|
|
@@ -5820,7 +5973,7 @@ function previewInlines(field, islands, output, equationSide, document2, preview
|
|
|
5820
5973
|
}
|
|
5821
5974
|
const island = {
|
|
5822
5975
|
id: token.id,
|
|
5823
|
-
tex: mathTex(token, equationSide),
|
|
5976
|
+
tex: mathTex(token, equationSide, previewOptions.digitForm),
|
|
5824
5977
|
display: token.display,
|
|
5825
5978
|
output,
|
|
5826
5979
|
editable: token.editable
|