import * as fs from "fs" ; import { join , parse } from "path" ; import toHtml from "@cocalc/frontend/jupyter/nbviewer/export" ; const { readFile , writeFile } = fs . promises ; export default async function ipynbToHtml ( path ) { const content = ( await readFile ( path ) ) . toString ( ) ; const html = toHtml ( { content , style : { margin : "30px 30px 0 0" } } ) ; const outfile = htmlPath ( path ) ; await writeFile ( outfile , html ) ; return outfile ; } export function htmlPath ( path ) { const { dir , name } = parse ( path ) ; return join ( dir , name + ".html" ) ; }