diff --git a/packages/ipynb2html-cli/src/cli.ts b/packages/ipynb2html-cli/src/cli.ts index 3ffb2e1..acf681a 100644 --- a/packages/ipynb2html-cli/src/cli.ts +++ b/packages/ipynb2html-cli/src/cli.ts @@ -29,6 +29,8 @@ Arguments: Options: -d --debug Print debug messages. + -f --fragment Output HTML fragment insted of full page. + -s --style Comma separated stylesheet(s) to embed into the output HTML. The stylesheet may be a path to a CSS file, "@base" for the base ipynb2html style, or "@default" @@ -56,6 +58,7 @@ function arrify (obj: T | T[]): T[] { function parseCliArgs (argv: string[]) { const opts = minimist(argv, minimistOptions({ debug: { alias: 'd', type: 'boolean' }, + fragment: { alias: 'f', type: 'boolean' }, style: { alias: 's', type: 'string', default: '@default' }, version: { alias: 'V', type: 'boolean' }, help: { alias: 'h', type: 'boolean' }, @@ -90,6 +93,7 @@ function parseCliArgs (argv: string[]) { return { styles: arrify(opts.style).join(',').split(/,\s*/), debug: opts.debug as boolean, + fragment: opts.fragment as boolean, input: input === '-' ? 0 : input, // 0 = stdin output, } @@ -116,7 +120,7 @@ export default (argv: string[]): void => { const renderNotebook = ipynb2html.createRenderer(new Document()) const contents = renderNotebook(notebook).outerHTML - const html = renderPage({ contents, title, style }) + const html = opts.fragment ? contents : renderPage({ contents, title, style }) if (opts.output) { fs.writeFileSync(opts.output, html)