@drghaliasri/butex 5.3.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 +16 -7
- package/dist/document2.d.ts +16 -7
- package/dist/document2.js +66 -17
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +64 -17
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +64 -17
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +64 -17
- 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,21 +496,30 @@ declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block:
|
|
|
496
496
|
|
|
497
497
|
type ButexUiLocale = 'ar' | 'en';
|
|
498
498
|
|
|
499
|
-
declare const BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \
|
|
500
|
-
declare const
|
|
501
|
-
|
|
502
|
-
|
|
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";
|
|
503
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";
|
|
504
505
|
/** Display-math body using BuTeX Diwani (for MathJax preview islands). */
|
|
505
506
|
declare function butexDiwaniDisplayTex(text: string): string;
|
|
506
507
|
/** Full display equation for XeLaTeX export. */
|
|
507
508
|
declare function butexDiwaniDisplayLatex(text: string): string;
|
|
508
|
-
/**
|
|
509
|
+
/** Three-line Diwani body for MathJax basmala islands. */
|
|
509
510
|
declare function butexBasmalaDisplayTex(): string;
|
|
510
511
|
/** Standalone display equation when there is no \\maketitle (title-less docs). */
|
|
511
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;
|
|
512
519
|
/** Titling hooks so the basmala stays attached to the visible title. */
|
|
513
|
-
declare function butexBasmalaTitlingPreamble(
|
|
520
|
+
declare function butexBasmalaTitlingPreamble(options?: {
|
|
521
|
+
twocolumn?: boolean;
|
|
522
|
+
}): string;
|
|
514
523
|
declare const HIJRI_YEAR_MIN = 1400;
|
|
515
524
|
declare const HIJRI_YEAR_MAX = 1500;
|
|
516
525
|
declare const HIJRI_MONTH_IDS: HijriMonthId[];
|
|
@@ -675,4 +684,4 @@ type Document2PreviewOptions = {
|
|
|
675
684
|
};
|
|
676
685
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
677
686
|
|
|
678
|
-
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_BASMALA_LINE1, 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, 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,21 +496,30 @@ declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block:
|
|
|
496
496
|
|
|
497
497
|
type ButexUiLocale = 'ar' | 'en';
|
|
498
498
|
|
|
499
|
-
declare const BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \
|
|
500
|
-
declare const
|
|
501
|
-
|
|
502
|
-
|
|
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";
|
|
503
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";
|
|
504
505
|
/** Display-math body using BuTeX Diwani (for MathJax preview islands). */
|
|
505
506
|
declare function butexDiwaniDisplayTex(text: string): string;
|
|
506
507
|
/** Full display equation for XeLaTeX export. */
|
|
507
508
|
declare function butexDiwaniDisplayLatex(text: string): string;
|
|
508
|
-
/**
|
|
509
|
+
/** Three-line Diwani body for MathJax basmala islands. */
|
|
509
510
|
declare function butexBasmalaDisplayTex(): string;
|
|
510
511
|
/** Standalone display equation when there is no \\maketitle (title-less docs). */
|
|
511
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;
|
|
512
519
|
/** Titling hooks so the basmala stays attached to the visible title. */
|
|
513
|
-
declare function butexBasmalaTitlingPreamble(
|
|
520
|
+
declare function butexBasmalaTitlingPreamble(options?: {
|
|
521
|
+
twocolumn?: boolean;
|
|
522
|
+
}): string;
|
|
514
523
|
declare const HIJRI_YEAR_MIN = 1400;
|
|
515
524
|
declare const HIJRI_YEAR_MAX = 1500;
|
|
516
525
|
declare const HIJRI_MONTH_IDS: HijriMonthId[];
|
|
@@ -675,4 +684,4 @@ type Document2PreviewOptions = {
|
|
|
675
684
|
};
|
|
676
685
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
677
686
|
|
|
678
|
-
export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_BASMALA_LINE1, 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, 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
|
@@ -22,6 +22,7 @@ var document2_exports = {};
|
|
|
22
22
|
__export(document2_exports, {
|
|
23
23
|
BUTEX_BASMALA: () => BUTEX_BASMALA,
|
|
24
24
|
BUTEX_BASMALA_LINE1: () => BUTEX_BASMALA_LINE1,
|
|
25
|
+
BUTEX_BASMALA_LINE2: () => BUTEX_BASMALA_LINE2,
|
|
25
26
|
BUTEX_BASMALA_SALAWAT: () => BUTEX_BASMALA_SALAWAT,
|
|
26
27
|
BUTEX_CLOSING_HAMDALA: () => BUTEX_CLOSING_HAMDALA,
|
|
27
28
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH: () => DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
@@ -45,6 +46,7 @@ __export(document2_exports, {
|
|
|
45
46
|
butexBasmalaTitlingPreamble: () => butexBasmalaTitlingPreamble,
|
|
46
47
|
butexDiwaniDisplayLatex: () => butexDiwaniDisplayLatex,
|
|
47
48
|
butexDiwaniDisplayTex: () => butexDiwaniDisplayTex,
|
|
49
|
+
butexInColumnMaketitleHook: () => butexInColumnMaketitleHook,
|
|
48
50
|
citeTokenLatex: () => citeTokenLatex,
|
|
49
51
|
cloneDocument2Meta: () => cloneDocument2Meta,
|
|
50
52
|
cloneDocument2Node: () => cloneDocument2Node,
|
|
@@ -171,9 +173,11 @@ function formatDigits(value, digitForm = "western") {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
// src/document2/articleMeta.ts
|
|
174
|
-
var BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \
|
|
175
|
-
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";
|
|
176
179
|
var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
|
|
180
|
+
${BUTEX_BASMALA_LINE2}
|
|
177
181
|
${BUTEX_BASMALA_SALAWAT}`;
|
|
178
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";
|
|
179
183
|
function escapeButexTextArg(text) {
|
|
@@ -187,26 +191,60 @@ function butexDiwaniDisplayLatex(text) {
|
|
|
187
191
|
${butexDiwaniDisplayTex(text)}
|
|
188
192
|
\\]`;
|
|
189
193
|
}
|
|
194
|
+
var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
|
|
190
195
|
function butexBasmalaDisplayTex() {
|
|
191
|
-
return
|
|
196
|
+
return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
|
|
192
197
|
}
|
|
193
198
|
function butexBasmalaDisplayLatex() {
|
|
194
199
|
return `\\[
|
|
195
200
|
${butexBasmalaDisplayTex()}
|
|
196
201
|
\\]`;
|
|
197
202
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
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 = [
|
|
200
232
|
"\\usepackage{titling}",
|
|
201
233
|
"\\pretitle{%",
|
|
202
234
|
" \\begin{center}",
|
|
203
|
-
|
|
204
|
-
|
|
235
|
+
...BASMALA_LINES.map((line, index) => {
|
|
236
|
+
const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
|
|
237
|
+
return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
|
|
238
|
+
}),
|
|
205
239
|
" \\par\\vspace{1.5em}",
|
|
206
240
|
" \\LARGE",
|
|
207
241
|
"}",
|
|
208
242
|
"\\posttitle{\\par\\end{center}}"
|
|
209
|
-
]
|
|
243
|
+
];
|
|
244
|
+
if (options.twocolumn) {
|
|
245
|
+
lines.push(butexInColumnMaketitleHook());
|
|
246
|
+
}
|
|
247
|
+
return lines.join("\n");
|
|
210
248
|
}
|
|
211
249
|
var HIJRI_YEAR_MIN = 1400;
|
|
212
250
|
var HIJRI_YEAR_MAX = 1500;
|
|
@@ -4083,7 +4121,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
|
|
|
4083
4121
|
kind: "image",
|
|
4084
4122
|
command: "\\includegraphics",
|
|
4085
4123
|
value: src,
|
|
4086
|
-
options: { width: "0.8\\
|
|
4124
|
+
options: { width: "0.8\\columnwidth" },
|
|
4087
4125
|
...defaultFloatMeta()
|
|
4088
4126
|
};
|
|
4089
4127
|
return insertDocument2BlockAfter(document2, afterBlockId, block);
|
|
@@ -4688,8 +4726,16 @@ function tableBlockLatex(block) {
|
|
|
4688
4726
|
lines.push("\\end{table}");
|
|
4689
4727
|
return lines.join("\n");
|
|
4690
4728
|
}
|
|
4691
|
-
function
|
|
4692
|
-
|
|
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
|
+
});
|
|
4693
4739
|
if (entries.length === 0) {
|
|
4694
4740
|
return "";
|
|
4695
4741
|
}
|
|
@@ -4700,7 +4746,7 @@ function imageBlockLatex(block) {
|
|
|
4700
4746
|
if (block.centered) {
|
|
4701
4747
|
lines.push(" \\centering");
|
|
4702
4748
|
}
|
|
4703
|
-
lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
|
|
4749
|
+
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
4704
4750
|
lines.push(...floatCaptionLabelLines(block));
|
|
4705
4751
|
lines.push("\\end{figure}");
|
|
4706
4752
|
return lines.join("\n");
|
|
@@ -4730,11 +4776,11 @@ ${block.closing}`;
|
|
|
4730
4776
|
function authorLatex(authors) {
|
|
4731
4777
|
return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
|
|
4732
4778
|
}
|
|
4733
|
-
function articleMaketitlePreamble(meta) {
|
|
4779
|
+
function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
4734
4780
|
if (!document2HasMaketitle(meta)) {
|
|
4735
4781
|
return "";
|
|
4736
4782
|
}
|
|
4737
|
-
const parts = [butexBasmalaTitlingPreamble()];
|
|
4783
|
+
const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
|
|
4738
4784
|
if (meta.title.trim().length > 0) {
|
|
4739
4785
|
parts.push(`\\title{${meta.title.trim()}}`);
|
|
4740
4786
|
}
|
|
@@ -4760,21 +4806,22 @@ ${meta.abstract.trim()}
|
|
|
4760
4806
|
}
|
|
4761
4807
|
function document2Latex(document2, options = {}) {
|
|
4762
4808
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
4809
|
+
const twocolumn = options.twocolumn === true;
|
|
4763
4810
|
const front = articleFrontMatterLatex(meta);
|
|
4764
4811
|
const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
|
|
4765
4812
|
const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
|
|
4766
4813
|
const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
|
|
4767
4814
|
const wrapDocument = options.wrapDocument !== false;
|
|
4768
4815
|
if (!wrapDocument) {
|
|
4769
|
-
const metaPreamble = articleMaketitlePreamble(meta);
|
|
4816
|
+
const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
|
|
4770
4817
|
return metaPreamble.length > 0 ? `${metaPreamble}
|
|
4771
4818
|
|
|
4772
4819
|
${body}` : body;
|
|
4773
4820
|
}
|
|
4774
4821
|
const preamble = getArabicXeLatexPreamble({
|
|
4775
4822
|
digitsMapping: options.digitsMapping ?? "arabicdigits",
|
|
4776
|
-
twocolumn
|
|
4777
|
-
}) + "\n" + articleMaketitlePreamble(meta);
|
|
4823
|
+
twocolumn
|
|
4824
|
+
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
4778
4825
|
return `${preamble}
|
|
4779
4826
|
\\begin{document}
|
|
4780
4827
|
|
|
@@ -5057,6 +5104,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5057
5104
|
0 && (module.exports = {
|
|
5058
5105
|
BUTEX_BASMALA,
|
|
5059
5106
|
BUTEX_BASMALA_LINE1,
|
|
5107
|
+
BUTEX_BASMALA_LINE2,
|
|
5060
5108
|
BUTEX_BASMALA_SALAWAT,
|
|
5061
5109
|
BUTEX_CLOSING_HAMDALA,
|
|
5062
5110
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
@@ -5080,6 +5128,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5080
5128
|
butexBasmalaTitlingPreamble,
|
|
5081
5129
|
butexDiwaniDisplayLatex,
|
|
5082
5130
|
butexDiwaniDisplayTex,
|
|
5131
|
+
butexInColumnMaketitleHook,
|
|
5083
5132
|
citeTokenLatex,
|
|
5084
5133
|
cloneDocument2Meta,
|
|
5085
5134
|
cloneDocument2Node,
|