UNPKG

@cocalc/project

Version:
54 lines (52 loc) 2.18 kB
"use strict"; /* Some React-based nbconvert functionality. Note that this doesn't actually use upstream nbconvert itself at all! - html: using react; very fast and uses no command line calls; html depends on cdn. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.htmlPath = void 0; const fs = __importStar(require("fs")); const path_1 = require("path"); const export_1 = __importDefault(require("@cocalc/frontend/jupyter/nbviewer/export")); const { readFile, writeFile } = fs.promises; async function ipynbToHtml(path) { const content = (await readFile(path)).toString(); const html = (0, export_1.default)({ content, style: { margin: "30px 30px 0 0" } }); const outfile = htmlPath(path); await writeFile(outfile, html); return outfile; } exports.default = ipynbToHtml; function htmlPath(path) { const { dir, name } = (0, path_1.parse)(path); return (0, path_1.join)(dir, name + ".html"); } exports.htmlPath = htmlPath; //# sourceMappingURL=ipynb-to-html.js.map