@drghaliasri/butex 5.2.0 → 5.3.1
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/document2.d.mts +20 -2
- package/dist/document2.d.ts +20 -2
- package/dist/document2.js +113 -18
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +106 -18
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +106 -19
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +106 -19
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ const latex = document2Latex(documentNode);
|
|
|
253
253
|
const preview = document2Preview(documentNode, 'svg');
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
`document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Pass `{ wrapDocument: false }` for body-only blocks. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,twocolumn]{article}
|
|
256
|
+
`document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Pass `{ wrapDocument: false }` for body-only blocks. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,notitlepage,twocolumn]{article}` (title block stays in-column; figures use `\columnwidth`). See [`examples/example-latex-export.tex`](examples/example-latex-export.tex) for a full sample (regenerated by the wrap vitest). Hosts can also call `getArabicXeLatexPreamble()` alone.
|
|
257
257
|
|
|
258
258
|
Figures and tables always export as centered `figure` / `table` floats. Optional caption/label fields (checkbox-driven in the editor) emit `\caption` / `\label`. Display math stays `\[…\]` unless an equation label is enabled, then export uses `\begin{equation}…\label{…}\end{equation}`. Internal cross-refs use `\ref` / `\eqref` tokens (separate from bibliography `\cite`).
|
|
259
259
|
|
package/dist/document2.d.mts
CHANGED
|
@@ -496,12 +496,30 @@ declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block:
|
|
|
496
496
|
|
|
497
497
|
type ButexUiLocale = 'ar' | 'en';
|
|
498
498
|
|
|
499
|
-
declare const
|
|
499
|
+
declare const BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650";
|
|
500
|
+
declare const BUTEX_BASMALA_LINE2 = "\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650";
|
|
501
|
+
declare const BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
|
|
502
|
+
/** Three-line basmala joined for UI / plain-text matchers. */
|
|
503
|
+
declare const BUTEX_BASMALA = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650\n\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650\n\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
|
|
500
504
|
declare const BUTEX_CLOSING_HAMDALA = "\u0627\u0644\u0652\u062D\u064E\u0645\u0652\u062F\u064F \u0644\u0650\u0644\u064E\u0651\u0647\u0650 \u0646\u064E\u0641\u064E\u0639\u064E\u0646\u064E\u0627 \u0628\u0650\u0639\u0650\u0644\u0652\u0645\u0650\u0647\u0650";
|
|
501
505
|
/** Display-math body using BuTeX Diwani (for MathJax preview islands). */
|
|
502
506
|
declare function butexDiwaniDisplayTex(text: string): string;
|
|
503
507
|
/** Full display equation for XeLaTeX export. */
|
|
504
508
|
declare function butexDiwaniDisplayLatex(text: string): string;
|
|
509
|
+
/** Three-line Diwani body for MathJax basmala islands. */
|
|
510
|
+
declare function butexBasmalaDisplayTex(): string;
|
|
511
|
+
/** Standalone display equation when there is no \\maketitle (title-less docs). */
|
|
512
|
+
declare function butexBasmalaDisplayLatex(): string;
|
|
513
|
+
/**
|
|
514
|
+
* Keep \\maketitle inside the current column when twocolumn is on.
|
|
515
|
+
* Standard article otherwise does \\twocolumn[\\@maketitle] and spans both columns.
|
|
516
|
+
* Call after titling so \\@maketitle still includes \\pretitle hooks.
|
|
517
|
+
*/
|
|
518
|
+
declare function butexInColumnMaketitleHook(): string;
|
|
519
|
+
/** Titling hooks so the basmala stays attached to the visible title. */
|
|
520
|
+
declare function butexBasmalaTitlingPreamble(options?: {
|
|
521
|
+
twocolumn?: boolean;
|
|
522
|
+
}): string;
|
|
505
523
|
declare const HIJRI_YEAR_MIN = 1400;
|
|
506
524
|
declare const HIJRI_YEAR_MAX = 1500;
|
|
507
525
|
declare const HIJRI_MONTH_IDS: HijriMonthId[];
|
|
@@ -666,4 +684,4 @@ type Document2PreviewOptions = {
|
|
|
666
684
|
};
|
|
667
685
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
668
686
|
|
|
669
|
-
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_CLOSING_HAMDALA, type BibliographyBlock2, type BlockSelectionRange, type BlockSelectionState, type CiteToken2, DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
|
687
|
+
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT, BUTEX_CLOSING_HAMDALA, type BibliographyBlock2, type BlockSelectionRange, type BlockSelectionState, type CiteToken2, DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
package/dist/document2.d.ts
CHANGED
|
@@ -496,12 +496,30 @@ declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block:
|
|
|
496
496
|
|
|
497
497
|
type ButexUiLocale = 'ar' | 'en';
|
|
498
498
|
|
|
499
|
-
declare const
|
|
499
|
+
declare const BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650";
|
|
500
|
+
declare const BUTEX_BASMALA_LINE2 = "\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650";
|
|
501
|
+
declare const BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
|
|
502
|
+
/** Three-line basmala joined for UI / plain-text matchers. */
|
|
503
|
+
declare const BUTEX_BASMALA = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650\n\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650\n\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
|
|
500
504
|
declare const BUTEX_CLOSING_HAMDALA = "\u0627\u0644\u0652\u062D\u064E\u0645\u0652\u062F\u064F \u0644\u0650\u0644\u064E\u0651\u0647\u0650 \u0646\u064E\u0641\u064E\u0639\u064E\u0646\u064E\u0627 \u0628\u0650\u0639\u0650\u0644\u0652\u0645\u0650\u0647\u0650";
|
|
501
505
|
/** Display-math body using BuTeX Diwani (for MathJax preview islands). */
|
|
502
506
|
declare function butexDiwaniDisplayTex(text: string): string;
|
|
503
507
|
/** Full display equation for XeLaTeX export. */
|
|
504
508
|
declare function butexDiwaniDisplayLatex(text: string): string;
|
|
509
|
+
/** Three-line Diwani body for MathJax basmala islands. */
|
|
510
|
+
declare function butexBasmalaDisplayTex(): string;
|
|
511
|
+
/** Standalone display equation when there is no \\maketitle (title-less docs). */
|
|
512
|
+
declare function butexBasmalaDisplayLatex(): string;
|
|
513
|
+
/**
|
|
514
|
+
* Keep \\maketitle inside the current column when twocolumn is on.
|
|
515
|
+
* Standard article otherwise does \\twocolumn[\\@maketitle] and spans both columns.
|
|
516
|
+
* Call after titling so \\@maketitle still includes \\pretitle hooks.
|
|
517
|
+
*/
|
|
518
|
+
declare function butexInColumnMaketitleHook(): string;
|
|
519
|
+
/** Titling hooks so the basmala stays attached to the visible title. */
|
|
520
|
+
declare function butexBasmalaTitlingPreamble(options?: {
|
|
521
|
+
twocolumn?: boolean;
|
|
522
|
+
}): string;
|
|
505
523
|
declare const HIJRI_YEAR_MIN = 1400;
|
|
506
524
|
declare const HIJRI_YEAR_MAX = 1500;
|
|
507
525
|
declare const HIJRI_MONTH_IDS: HijriMonthId[];
|
|
@@ -666,4 +684,4 @@ type Document2PreviewOptions = {
|
|
|
666
684
|
};
|
|
667
685
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
668
686
|
|
|
669
|
-
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_CLOSING_HAMDALA, type BibliographyBlock2, type BlockSelectionRange, type BlockSelectionState, type CiteToken2, DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
|
687
|
+
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT, BUTEX_CLOSING_HAMDALA, type BibliographyBlock2, type BlockSelectionRange, type BlockSelectionState, type CiteToken2, DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
package/dist/document2.js
CHANGED
|
@@ -21,6 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var document2_exports = {};
|
|
22
22
|
__export(document2_exports, {
|
|
23
23
|
BUTEX_BASMALA: () => BUTEX_BASMALA,
|
|
24
|
+
BUTEX_BASMALA_LINE1: () => BUTEX_BASMALA_LINE1,
|
|
25
|
+
BUTEX_BASMALA_LINE2: () => BUTEX_BASMALA_LINE2,
|
|
26
|
+
BUTEX_BASMALA_SALAWAT: () => BUTEX_BASMALA_SALAWAT,
|
|
24
27
|
BUTEX_CLOSING_HAMDALA: () => BUTEX_CLOSING_HAMDALA,
|
|
25
28
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH: () => DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
26
29
|
DEFAULT_HIJRI_DATE: () => DEFAULT_HIJRI_DATE,
|
|
@@ -38,8 +41,12 @@ __export(document2_exports, {
|
|
|
38
41
|
arabicXeLatexPreambleFont: () => arabicXeLatexPreambleFont,
|
|
39
42
|
arabicXeLatexPreamblePkg: () => arabicXeLatexPreamblePkg,
|
|
40
43
|
bibliographyEntryLatex: () => bibliographyEntryLatex,
|
|
44
|
+
butexBasmalaDisplayLatex: () => butexBasmalaDisplayLatex,
|
|
45
|
+
butexBasmalaDisplayTex: () => butexBasmalaDisplayTex,
|
|
46
|
+
butexBasmalaTitlingPreamble: () => butexBasmalaTitlingPreamble,
|
|
41
47
|
butexDiwaniDisplayLatex: () => butexDiwaniDisplayLatex,
|
|
42
48
|
butexDiwaniDisplayTex: () => butexDiwaniDisplayTex,
|
|
49
|
+
butexInColumnMaketitleHook: () => butexInColumnMaketitleHook,
|
|
43
50
|
citeTokenLatex: () => citeTokenLatex,
|
|
44
51
|
cloneDocument2Meta: () => cloneDocument2Meta,
|
|
45
52
|
cloneDocument2Node: () => cloneDocument2Node,
|
|
@@ -166,7 +173,12 @@ function formatDigits(value, digitForm = "western") {
|
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
// src/document2/articleMeta.ts
|
|
169
|
-
var
|
|
176
|
+
var BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650";
|
|
177
|
+
var BUTEX_BASMALA_LINE2 = "\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650";
|
|
178
|
+
var BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
|
|
179
|
+
var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
|
|
180
|
+
${BUTEX_BASMALA_LINE2}
|
|
181
|
+
${BUTEX_BASMALA_SALAWAT}`;
|
|
170
182
|
var BUTEX_CLOSING_HAMDALA = "\u0627\u0644\u0652\u062D\u064E\u0645\u0652\u062F\u064F \u0644\u0650\u0644\u064E\u0651\u0647\u0650 \u0646\u064E\u0641\u064E\u0639\u064E\u0646\u064E\u0627 \u0628\u0650\u0639\u0650\u0644\u0652\u0645\u0650\u0647\u0650";
|
|
171
183
|
function escapeButexTextArg(text) {
|
|
172
184
|
return text.replace(/\\/g, "\\textbackslash{}").replace(/[{}]/g, "\\$&");
|
|
@@ -179,6 +191,61 @@ function butexDiwaniDisplayLatex(text) {
|
|
|
179
191
|
${butexDiwaniDisplayTex(text)}
|
|
180
192
|
\\]`;
|
|
181
193
|
}
|
|
194
|
+
var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
|
|
195
|
+
function butexBasmalaDisplayTex() {
|
|
196
|
+
return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
|
|
197
|
+
}
|
|
198
|
+
function butexBasmalaDisplayLatex() {
|
|
199
|
+
return `\\[
|
|
200
|
+
${butexBasmalaDisplayTex()}
|
|
201
|
+
\\]`;
|
|
202
|
+
}
|
|
203
|
+
function butexInColumnMaketitleHook() {
|
|
204
|
+
return String.raw`\makeatletter
|
|
205
|
+
\renewcommand{\maketitle}{%
|
|
206
|
+
\par
|
|
207
|
+
\begingroup
|
|
208
|
+
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
|
|
209
|
+
\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
|
|
210
|
+
\long\def\@makefntext##1{\parindent 1em\noindent
|
|
211
|
+
\hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
|
|
212
|
+
\@maketitle
|
|
213
|
+
\thispagestyle{plain}\@thanks
|
|
214
|
+
\endgroup
|
|
215
|
+
\setcounter{footnote}{0}%
|
|
216
|
+
\global\let\thanks\relax
|
|
217
|
+
\global\let\maketitle\relax
|
|
218
|
+
\global\let\@maketitle\relax
|
|
219
|
+
\global\let\@thanks\@empty
|
|
220
|
+
\global\let\@author\@empty
|
|
221
|
+
\global\let\@date\@empty
|
|
222
|
+
\global\let\@title\@empty
|
|
223
|
+
\global\let\title\relax
|
|
224
|
+
\global\let\author\relax
|
|
225
|
+
\global\let\date\relax
|
|
226
|
+
\global\let\and\relax
|
|
227
|
+
}
|
|
228
|
+
\makeatother`;
|
|
229
|
+
}
|
|
230
|
+
function butexBasmalaTitlingPreamble(options = {}) {
|
|
231
|
+
const lines = [
|
|
232
|
+
"\\usepackage{titling}",
|
|
233
|
+
"\\pretitle{%",
|
|
234
|
+
" \\begin{center}",
|
|
235
|
+
...BASMALA_LINES.map((line, index) => {
|
|
236
|
+
const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
|
|
237
|
+
return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
|
|
238
|
+
}),
|
|
239
|
+
" \\par\\vspace{1.5em}",
|
|
240
|
+
" \\LARGE",
|
|
241
|
+
"}",
|
|
242
|
+
"\\posttitle{\\par\\end{center}}"
|
|
243
|
+
];
|
|
244
|
+
if (options.twocolumn) {
|
|
245
|
+
lines.push(butexInColumnMaketitleHook());
|
|
246
|
+
}
|
|
247
|
+
return lines.join("\n");
|
|
248
|
+
}
|
|
182
249
|
var HIJRI_YEAR_MIN = 1400;
|
|
183
250
|
var HIJRI_YEAR_MAX = 1500;
|
|
184
251
|
var HIJRI_MONTH_IDS = [
|
|
@@ -4054,7 +4121,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
|
|
|
4054
4121
|
kind: "image",
|
|
4055
4122
|
command: "\\includegraphics",
|
|
4056
4123
|
value: src,
|
|
4057
|
-
options: { width: "0.8\\
|
|
4124
|
+
options: { width: "0.8\\columnwidth" },
|
|
4058
4125
|
...defaultFloatMeta()
|
|
4059
4126
|
};
|
|
4060
4127
|
return insertDocument2BlockAfter(document2, afterBlockId, block);
|
|
@@ -4379,7 +4446,7 @@ function updateDocument2Meta(document2, patch) {
|
|
|
4379
4446
|
|
|
4380
4447
|
// src/document2/arabicPreamble.ts
|
|
4381
4448
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
4382
|
-
const classOptions = twocolumn ? "12pt,a4paper,twocolumn" : "12pt,a4paper";
|
|
4449
|
+
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
4383
4450
|
return `
|
|
4384
4451
|
\\documentclass[${classOptions}]{article}
|
|
4385
4452
|
` + String.raw`\usepackage{amsmath,amsfonts,amssymb,mathrsfs,tikz,fancyhdr, mathtools}
|
|
@@ -4659,8 +4726,16 @@ function tableBlockLatex(block) {
|
|
|
4659
4726
|
lines.push("\\end{table}");
|
|
4660
4727
|
return lines.join("\n");
|
|
4661
4728
|
}
|
|
4662
|
-
function
|
|
4663
|
-
|
|
4729
|
+
function remapImageWidthForColumns(value) {
|
|
4730
|
+
return value.replace(/\\textwidth\b/g, "\\columnwidth");
|
|
4731
|
+
}
|
|
4732
|
+
function imageOptionsLatex(block, constrainToColumn) {
|
|
4733
|
+
const entries = Object.entries(block.options).map(([key, value]) => {
|
|
4734
|
+
if (constrainToColumn && key === "width") {
|
|
4735
|
+
return [key, remapImageWidthForColumns(value)];
|
|
4736
|
+
}
|
|
4737
|
+
return [key, value];
|
|
4738
|
+
});
|
|
4664
4739
|
if (entries.length === 0) {
|
|
4665
4740
|
return "";
|
|
4666
4741
|
}
|
|
@@ -4671,7 +4746,7 @@ function imageBlockLatex(block) {
|
|
|
4671
4746
|
if (block.centered) {
|
|
4672
4747
|
lines.push(" \\centering");
|
|
4673
4748
|
}
|
|
4674
|
-
lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
|
|
4749
|
+
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
4675
4750
|
lines.push(...floatCaptionLabelLines(block));
|
|
4676
4751
|
lines.push("\\end{figure}");
|
|
4677
4752
|
return lines.join("\n");
|
|
@@ -4701,17 +4776,26 @@ ${block.closing}`;
|
|
|
4701
4776
|
function authorLatex(authors) {
|
|
4702
4777
|
return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
|
|
4703
4778
|
}
|
|
4779
|
+
function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
4780
|
+
if (!document2HasMaketitle(meta)) {
|
|
4781
|
+
return "";
|
|
4782
|
+
}
|
|
4783
|
+
const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
|
|
4784
|
+
if (meta.title.trim().length > 0) {
|
|
4785
|
+
parts.push(`\\title{${meta.title.trim()}}`);
|
|
4786
|
+
}
|
|
4787
|
+
if (meta.authors.trim().length > 0) {
|
|
4788
|
+
parts.push(`\\author{${authorLatex(meta.authors)}}`);
|
|
4789
|
+
}
|
|
4790
|
+
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
|
|
4791
|
+
return parts.join("\n");
|
|
4792
|
+
}
|
|
4704
4793
|
function articleFrontMatterLatex(meta) {
|
|
4705
|
-
const parts = [
|
|
4794
|
+
const parts = [];
|
|
4706
4795
|
if (document2HasMaketitle(meta)) {
|
|
4707
|
-
if (meta.title.trim().length > 0) {
|
|
4708
|
-
parts.push(`\\title{${meta.title.trim()}}`);
|
|
4709
|
-
}
|
|
4710
|
-
if (meta.authors.trim().length > 0) {
|
|
4711
|
-
parts.push(`\\author{${authorLatex(meta.authors)}}`);
|
|
4712
|
-
}
|
|
4713
|
-
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
|
|
4714
4796
|
parts.push("\\maketitle");
|
|
4797
|
+
} else {
|
|
4798
|
+
parts.push(butexBasmalaDisplayLatex());
|
|
4715
4799
|
}
|
|
4716
4800
|
if (document2HasAbstract(meta)) {
|
|
4717
4801
|
parts.push(`\\begin{abstract}
|
|
@@ -4722,18 +4806,22 @@ ${meta.abstract.trim()}
|
|
|
4722
4806
|
}
|
|
4723
4807
|
function document2Latex(document2, options = {}) {
|
|
4724
4808
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
4809
|
+
const twocolumn = options.twocolumn === true;
|
|
4725
4810
|
const front = articleFrontMatterLatex(meta);
|
|
4726
4811
|
const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
|
|
4727
4812
|
const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
|
|
4728
4813
|
const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
|
|
4729
4814
|
const wrapDocument = options.wrapDocument !== false;
|
|
4730
4815
|
if (!wrapDocument) {
|
|
4731
|
-
|
|
4816
|
+
const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
|
|
4817
|
+
return metaPreamble.length > 0 ? `${metaPreamble}
|
|
4818
|
+
|
|
4819
|
+
${body}` : body;
|
|
4732
4820
|
}
|
|
4733
4821
|
const preamble = getArabicXeLatexPreamble({
|
|
4734
4822
|
digitsMapping: options.digitsMapping ?? "arabicdigits",
|
|
4735
|
-
twocolumn
|
|
4736
|
-
});
|
|
4823
|
+
twocolumn
|
|
4824
|
+
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
4737
4825
|
return `${preamble}
|
|
4738
4826
|
\\begin{document}
|
|
4739
4827
|
|
|
@@ -4976,7 +5064,7 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
4976
5064
|
function articleChromePreview(document2, uiLocale, previewOptions) {
|
|
4977
5065
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
4978
5066
|
const blocks = [
|
|
4979
|
-
{ kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex:
|
|
5067
|
+
{ kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex: butexBasmalaDisplayTex() }
|
|
4980
5068
|
];
|
|
4981
5069
|
if (document2HasMaketitle(meta)) {
|
|
4982
5070
|
blocks.push({
|
|
@@ -5015,6 +5103,9 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5015
5103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5016
5104
|
0 && (module.exports = {
|
|
5017
5105
|
BUTEX_BASMALA,
|
|
5106
|
+
BUTEX_BASMALA_LINE1,
|
|
5107
|
+
BUTEX_BASMALA_LINE2,
|
|
5108
|
+
BUTEX_BASMALA_SALAWAT,
|
|
5018
5109
|
BUTEX_CLOSING_HAMDALA,
|
|
5019
5110
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
5020
5111
|
DEFAULT_HIJRI_DATE,
|
|
@@ -5032,8 +5123,12 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5032
5123
|
arabicXeLatexPreambleFont,
|
|
5033
5124
|
arabicXeLatexPreamblePkg,
|
|
5034
5125
|
bibliographyEntryLatex,
|
|
5126
|
+
butexBasmalaDisplayLatex,
|
|
5127
|
+
butexBasmalaDisplayTex,
|
|
5128
|
+
butexBasmalaTitlingPreamble,
|
|
5035
5129
|
butexDiwaniDisplayLatex,
|
|
5036
5130
|
butexDiwaniDisplayTex,
|
|
5131
|
+
butexInColumnMaketitleHook,
|
|
5037
5132
|
citeTokenLatex,
|
|
5038
5133
|
cloneDocument2Meta,
|
|
5039
5134
|
cloneDocument2Node,
|