Compare commits

...

1 commit

Author SHA1 Message Date
5c7f8b048e add fragment option 2022-04-29 19:31:52 +02:00

View file

@ -29,6 +29,8 @@ Arguments:
Options:
-d --debug Print debug messages.
-f --fragment Output HTML fragment insted of full page.
-s --style <file,...> 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 <T> (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)