/* eslint-disable no-func-assign */ /* eslint-disable no-unused-vars */ /* ----------------------------------------------------------------------------- | Copyright (c) Jupyter Development Team. | Distributed under the terms of the Modified BSD License. |----------------------------------------------------------------------------*/ /** * jupyter lab notebook output 渲染模块 * 本模块基于 @jupyterlab\rendermime\lib\renderers.js 二次开发 * 移除了部分功能,如:a 标签url处理,markdown 标题的自动生成对应链接等。 * 此外还去除了所需传参:resolver、linkHandler、translator * * 源码TS版:https://github.com/jupyterlab/jupyterlab/blob/master/packages/rendermime/src/renderers.ts * */ import { removeMath, replaceMath } from "./latex"; import { URLExt } from "@jupyterlab/coreutils"; import escape from "lodash.escape"; /** * Render HTML into a host node. * * @param options - The options for rendering. * * @returns A promise which resolves when rendering is complete. */ export function renderHTML(options) { // Unpack the options. let { host, source, trusted, sanitizer, shouldTypeset, latexTypesetter } = options; let originalSource = source; // Bail early if the source is empty. if (!source) { host.textContent = ""; return Promise.resolve(undefined); } // Sanitize the source if it is not trusted. This removes all // `