@drghaliasri/butex 7.4.1 → 7.4.2
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/index.global.js +19 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Peer dependency: `mathjax` ^4.x (aligned with MathJax 4 components). If you use
|
|
|
61
61
|
2. Load BuTeX’s IIFE bundle (`dist/index.global.js` exposes global `BuTeX`).
|
|
62
62
|
3. In `MathJax.startup.ready`, call `BuTeX.registerBuTeX(MathJax)` before `MathJax.startup.defaultReady()`.
|
|
63
63
|
4. Inject styles once: `BuTeX.injectBuTeXStyles()` (or embed `BuTeX.BUTEX_CHROME_CSS` yourself).
|
|
64
|
-
5. When using **SVG** (`tex-svg.js`), call `BuTeX.registerBuTeXSvgTextWrapper(MathJax)` **after** `defaultReady()` so Takween/Diwani/Maghribi text, `\ad`, and Arabic atomic commands (`\arsin`, etc.) render in the preview
|
|
64
|
+
5. When using **SVG** (`tex-svg.js`), call `BuTeX.registerBuTeXSvgTextWrapper(MathJax)` **after** `defaultReady()` so Takween/Diwani/Maghribi text, RTL multiword `\unit{وحدة تجريبية}` displays, `\ad`, and Arabic atomic commands (`\arsin`, etc.) render correctly in the preview. SVG units use one upright, RTL-isolated text element; neither the unit identity nor the stored notation is reversed. CommonHTML (`tex-chtml.js`) uses the injected CSS classes instead.
|
|
65
65
|
6. Render math with `renderBuTeXMathIsland(tex, options?)` or mount into a host element via `mountBuTeXMathIsland(host, tex, options?)`. Pass `output: 'svg'` when the host loads `tex-svg.js`, or `output: 'chtml'` with `tex-chtml.js`. For raw Arabic TeX that did not come from the editor AST, pass `mirrorOperators: true` to wrap directional operators according to BuTeX's shared operator table. `ButexEditor` picks SVG vs CHTML automatically from the loaded MathJax bundle (`tex2svg` vs `tex2chtml`).
|
|
66
66
|
|
|
67
67
|
Ensure TeX `packages` includes `butex-arabic-math` (use `BUTEX_TEX_PACKAGE` in config when using `{ '[+]': [...] }`). BuTeX registers lightweight browser compatibility macros for toolbar symbols such as `\coloneqq` and `\eqqcolon`; XeLaTeX export still relies on the document preamble's `mathtools`.
|
package/dist/index.global.js
CHANGED
|
@@ -910,7 +910,7 @@ mjx-container[jax="CHTML"] .butex-preview-mirror {
|
|
|
910
910
|
const node = parser.create(
|
|
911
911
|
"token",
|
|
912
912
|
"mtext",
|
|
913
|
-
{ class: "butex-unit-text", "data-butex-unit": text },
|
|
913
|
+
{ class: "butex-unit-text", "data-butex-unit": text, "data-butex-svg-text": text },
|
|
914
914
|
text
|
|
915
915
|
);
|
|
916
916
|
parser.Push(node);
|
|
@@ -7837,6 +7837,15 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7837
7837
|
baselineShift: 0,
|
|
7838
7838
|
fontWeight: 700
|
|
7839
7839
|
};
|
|
7840
|
+
var UNIT_LAYOUT = {
|
|
7841
|
+
key: "unit",
|
|
7842
|
+
stack: BOLD_LAYOUT.stack,
|
|
7843
|
+
height: 0.75,
|
|
7844
|
+
depth: 0.25,
|
|
7845
|
+
drawScale: 1,
|
|
7846
|
+
baselineShift: 0,
|
|
7847
|
+
fontWeight: 400
|
|
7848
|
+
};
|
|
7840
7849
|
var FONT_LAYOUTS = Object.fromEntries(
|
|
7841
7850
|
NON_DEFAULT_CHARACTER_FONT_SPECS.filter((font) => font.svgLayoutKey && font.browserFontStack).map((font) => {
|
|
7842
7851
|
const key = font.svgLayoutKey;
|
|
@@ -7860,6 +7869,9 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7860
7869
|
if (classes.includes("butex-bold-text")) {
|
|
7861
7870
|
return BOLD_LAYOUT;
|
|
7862
7871
|
}
|
|
7872
|
+
if (classes.includes("butex-unit-text")) {
|
|
7873
|
+
return UNIT_LAYOUT;
|
|
7874
|
+
}
|
|
7863
7875
|
for (const font of NON_DEFAULT_CHARACTER_FONT_SPECS) {
|
|
7864
7876
|
if (font.mathJaxClass && font.svgLayoutKey && classes.includes(font.mathJaxClass)) {
|
|
7865
7877
|
return FONT_LAYOUTS[font.svgLayoutKey] ?? null;
|
|
@@ -7898,7 +7910,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7898
7910
|
function formatSvgNumber(value) {
|
|
7899
7911
|
return Number.isFinite(value) ? value.toFixed(3).replace(/\.?0+$/, "") : "0";
|
|
7900
7912
|
}
|
|
7901
|
-
function measureAdvance(wrapper, text,
|
|
7913
|
+
function measureAdvance(wrapper, text, font) {
|
|
7902
7914
|
const jax = wrapper.jax;
|
|
7903
7915
|
const adaptor = jax.adaptor;
|
|
7904
7916
|
const body = adaptor.document == null ? null : adaptor.body(adaptor.document);
|
|
@@ -7910,16 +7922,16 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7910
7922
|
{
|
|
7911
7923
|
x: 0,
|
|
7912
7924
|
y: 0,
|
|
7913
|
-
"font-family":
|
|
7925
|
+
"font-family": font.stack,
|
|
7914
7926
|
"font-size": EM,
|
|
7915
|
-
"font-weight":
|
|
7927
|
+
"font-weight": font.fontWeight,
|
|
7916
7928
|
"text-anchor": "end",
|
|
7917
7929
|
direction: "rtl",
|
|
7918
7930
|
"unicode-bidi": "isolate",
|
|
7919
7931
|
"dominant-baseline": "alphabetic",
|
|
7920
7932
|
style: {
|
|
7921
|
-
"font-family":
|
|
7922
|
-
"font-weight":
|
|
7933
|
+
"font-family": font.stack,
|
|
7934
|
+
"font-weight": font.fontWeight,
|
|
7923
7935
|
direction: "rtl",
|
|
7924
7936
|
"unicode-bidi": "isolate"
|
|
7925
7937
|
}
|
|
@@ -7962,7 +7974,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
7962
7974
|
if (!text || !font) {
|
|
7963
7975
|
return null;
|
|
7964
7976
|
}
|
|
7965
|
-
const measured = measureAdvance(wrapper, text, font
|
|
7977
|
+
const measured = measureAdvance(wrapper, text, font);
|
|
7966
7978
|
const charCount = Math.max(1, Array.from(text).length);
|
|
7967
7979
|
const anchorUnits = measured ? measured.anchorUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|
|
7968
7980
|
const widthUnits = measured ? measured.widthUnits : charCount * FALLBACK_CHAR_WIDTH * EM;
|