@@ -41,12 +41,14 @@ npm install omniscript-parser
4141// Parse OSF to AST
4242const osfCode = \`
4343@meta { title: "My Document"; }
44- @doc { content: "# Hello World"; }
44+ @doc {
45+ # Hello World
46+ }
4547\`;
4648
4749const ast = parse(osfCode);
4850console.log(ast);
49- // Output: { version: "1.0", blocks: [...] }
51+ // Output: { blocks: [...] }
5052
5153// Serialize AST back to OSF
5254const osfOutput = serialize(ast);
@@ -56,15 +58,15 @@ console.log(osfOutput);`}
5658 < h3 className = "text-2xl font-bold mb-4" > API</ h3 >
5759
5860 < div className = "mb-6 border-2 border-blue-500 p-6" >
59- < h4 className = "font-bold text-xl mb-3" > parse(osfCode: string): OSFDocument</ h4 >
61+ < h4 className = "font-bold text-xl mb-3" > parse(osfCode: string, options?: ParseOptions ): OSFDocument</ h4 >
6062 < p className = "text-gray-300 mb-4" >
6163 Parses OSF text into an Abstract Syntax Tree (AST).
6264 </ p >
6365 < p className = "text-sm text-gray-400" >
64- < strong > Parameters:</ strong > osfCode - String containing OSF content
66+ < strong > Parameters:</ strong > osfCode - String containing OSF content; options - Include resolution settings
6567 </ p >
6668 < p className = "text-sm text-gray-400" >
67- < strong > Returns:</ strong > OSFDocument object with version and blocks array
69+ < strong > Returns:</ strong > OSFDocument object with blocks array ( and includes when present)
6870 </ p >
6971 < p className = "text-sm text-gray-400" >
7072 < strong > Throws:</ strong > Error if syntax is invalid
@@ -89,26 +91,24 @@ console.log(osfOutput);`}
8991{ `interface OSFDocument {
9092 version?: string;
9193 blocks: OSFBlock[];
94+ includes?: IncludeDirective[];
9295}
9396
94- type OSFBlock =
95- | MetaBlock
96- | DocBlock
97- | SlideBlock
98- | SheetBlock
99- | ChartBlock
100- | DiagramBlock
101- | OSFCodeBlock;
97+ type OSFValue = string | number | boolean | OSFValue[] | { [key: string]: OSFValue };
98+
99+ type OSFBlock =
100+ | MetaBlock
101+ | DocBlock
102+ | SlideBlock
103+ | SheetBlock
104+ | ChartBlock
105+ | DiagramBlock
106+ | OSFCodeBlock
107+ | TableBlock;
102108
103109interface MetaBlock {
104110 type: 'meta';
105- title?: string;
106- author?: string;
107- date?: string;
108- version?: string;
109- theme?: string;
110- tags?: string[];
111- description?: string;
111+ props: Record<string, OSFValue>;
112112}
113113
114114interface ChartBlock {
@@ -117,6 +117,21 @@ interface ChartBlock {
117117 title: string;
118118 data: ChartDataSeries[];
119119 options?: ChartOptions;
120+ }
121+
122+ interface TableBlock {
123+ type: 'table';
124+ caption?: string;
125+ style?: 'bordered' | 'striped' | 'minimal';
126+ alignment?: ('left' | 'center' | 'right')[];
127+ headers: string[];
128+ rows: { cells: { text: string }[] }[];
129+ }
130+
131+ interface IncludeDirective {
132+ type: 'include';
133+ path: string;
134+ resolved?: OSFDocument;
120135}` }
121136 </ pre >
122137 </ section >
@@ -191,6 +206,8 @@ fs.writeFileSync('output.xlsx', result.buffer);`}
191206 orientation?: 'portrait' | 'landscape';
192207 fontSize?: number;
193208 fontFamily?: string;
209+ timeoutMs?: number; // PDF rendering timeout (ms)
210+ puppeteerArgs?: string[]; // Custom Puppeteer launch args
194211}` }
195212 </ pre >
196213
0 commit comments