mdast2docx 0.0.0-beta.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/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-KRMGJ4HN.mjs";import{i as a,k as m,l as I}from"./chunk-O6BHSWEF.mjs";var O=async(r,P,y,l="blob")=>{let p=1,s={},d=await Promise.all((Array.isArray(r)?r:[{ast:r}]).map(async({ast:o,props:n})=>{let{definitions:t,footnoteDefinitions:e}=I(o.children);return await Promise.all(Object.entries(e).map(async([,c])=>{c.id=p,s[p]=await i({type:"root",children:c.children},t,{}),p++})),{ast:o,props:{...y,...n},definitions:t,footnoteDefinitions:e}})),u=await Promise.all(d.map(({ast:o,props:n,definitions:t,footnoteDefinitions:e})=>i(o,t,e,n))),D=new a({...P,footnotes:s,sections:u});return m.pack(D,l)};export{O as toDocx};
@@ -0,0 +1,30 @@
1
+ import type { Root } from "mdast";
2
+ import type { Definitions, FootnoteDefinitions, IMdastToDocxSectionProps } from "./utils";
3
+ import { Paragraph } from "@mayank1513/docx";
4
+ import type { ISectionOptions } from "@mayank1513/docx";
5
+ /**
6
+ * Defines properties for a document section, omitting the "children" property from ISectionOptions.
7
+ */
8
+ export type ISectionProps = Omit<ISectionOptions, "children"> & IMdastToDocxSectionProps;
9
+ /**
10
+ * Converts an MDAST tree to a DOCX document section.
11
+ * @param node - The root MDAST node
12
+ * @param definitions - Definitions mapping
13
+ * @param footnoteDefinitions - Footnote definitions mapping
14
+ * @param props - Section properties (optional)
15
+ * @returns A DOCX section representation
16
+ */
17
+ export declare const toSection: (node: Root, definitions: Definitions, footnoteDefinitions: FootnoteDefinitions, props?: ISectionProps) => Promise<{
18
+ children: Paragraph[];
19
+ headers?: {
20
+ readonly default?: import("@mayank1513/docx").Header;
21
+ readonly first?: import("@mayank1513/docx").Header;
22
+ readonly even?: import("@mayank1513/docx").Header;
23
+ };
24
+ footers?: {
25
+ readonly default?: import("@mayank1513/docx").Footer;
26
+ readonly first?: import("@mayank1513/docx").Footer;
27
+ readonly even?: import("@mayank1513/docx").Footer;
28
+ };
29
+ properties?: import("@mayank1513/docx").ISectionPropertiesOptions;
30
+ }>;