Skip to content

Commit 66fa0fd

Browse files
authored
Add stub rendering formats (#29)
## Summary - support additional render formats pdf, docx, pptx and xlsx - provide placeholder renderers - update CLI help text - test rendering of each new format ## Testing - `pnpm test` ------ https://chatgpt.com/codex/tasks/task_e_685d3acdca74832b9846b50983aecf9f
2 parents ce80f34 + 5148c2b commit 66fa0fd

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

cli/src/osf.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const commands: CliCommand[] = [
3131
},
3232
{
3333
name: 'render',
34-
description: 'Render OSF to HTML output',
35-
usage: 'osf render <file> [--format <html>] [--output <file>]',
34+
description: 'Render OSF to various output formats',
35+
usage:
36+
'osf render <file> [--format <html|pdf|docx|pptx|xlsx>] [--output <file>]',
3637
args: ['file'],
3738
},
3839
{
@@ -71,6 +72,7 @@ function showHelp(): void {
7172
console.log('\nExamples:');
7273
console.log(' osf parse document.osf');
7374
console.log(' osf render slides.osf --format html');
75+
console.log(' osf render slides.osf --format pdf');
7476
console.log(' osf export data.osf --target md --output output.md');
7577
}
7678

@@ -223,6 +225,31 @@ function renderHtml(doc: OSFDocument): string {
223225
return parts.join('\n');
224226
}
225227

228+
// Basic stubs for additional formats
229+
function renderPdf(doc: OSFDocument): string {
230+
void doc; // placeholder usage
231+
// TODO: real PDF rendering
232+
return 'PDF rendering not implemented.';
233+
}
234+
235+
function renderDocx(doc: OSFDocument): string {
236+
void doc;
237+
// TODO: real DOCX rendering
238+
return 'DOCX rendering not implemented.';
239+
}
240+
241+
function renderPptx(doc: OSFDocument): string {
242+
void doc;
243+
// TODO: real PPTX rendering
244+
return 'PPTX rendering not implemented.';
245+
}
246+
247+
function renderXlsx(doc: OSFDocument): string {
248+
void doc;
249+
// TODO: real XLSX rendering
250+
return 'XLSX rendering not implemented.';
251+
}
252+
226253
function exportMarkdown(doc: OSFDocument): string {
227254
const out: string[] = [];
228255

@@ -466,8 +493,22 @@ function main(): void {
466493
case 'html':
467494
output = renderHtml(doc);
468495
break;
496+
case 'pdf':
497+
output = renderPdf(doc);
498+
break;
499+
case 'docx':
500+
output = renderDocx(doc);
501+
break;
502+
case 'pptx':
503+
output = renderPptx(doc);
504+
break;
505+
case 'xlsx':
506+
output = renderXlsx(doc);
507+
break;
469508
default:
470-
throw new Error(`Unknown format: ${format}. Supported: html`);
509+
throw new Error(
510+
`Unknown format: ${format}. Supported: html, pdf, docx, pptx, xlsx`
511+
);
471512
}
472513

473514
if (outputFile) {

cli/tests/cli.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,38 @@ describe('OSF CLI', () => {
170170
expect(result).toContain('<table>');
171171
});
172172

173+
it('should render OSF to PDF', () => {
174+
const result = execSync(`node "${CLI_PATH}" render "${testFile}" --format pdf`, {
175+
encoding: 'utf8',
176+
});
177+
178+
expect(result).toContain('PDF rendering not implemented.');
179+
});
180+
181+
it('should render OSF to DOCX', () => {
182+
const result = execSync(`node "${CLI_PATH}" render "${testFile}" --format docx`, {
183+
encoding: 'utf8',
184+
});
185+
186+
expect(result).toContain('DOCX rendering not implemented.');
187+
});
188+
189+
it('should render OSF to PPTX', () => {
190+
const result = execSync(`node "${CLI_PATH}" render "${testFile}" --format pptx`, {
191+
encoding: 'utf8',
192+
});
193+
194+
expect(result).toContain('PPTX rendering not implemented.');
195+
});
196+
197+
it('should render OSF to XLSX', () => {
198+
const result = execSync(`node "${CLI_PATH}" render "${testFile}" --format xlsx`, {
199+
encoding: 'utf8',
200+
});
201+
202+
expect(result).toContain('XLSX rendering not implemented.');
203+
});
204+
173205
it('should render OSF to HTML file', () => {
174206
execSync(`node "${CLI_PATH}" render "${testFile}" --output "${outputFile}"`, {
175207
encoding: 'utf8',

0 commit comments

Comments
 (0)