import * as DiffParser from './diff-parser';import { FileListRenderer } from './file-list-renderer';import LineByLineRenderer, { LineByLineRendererConfig, defaultLineByLineRendererConfig } from './line-by-line-renderer';import SideBySideRenderer, { SideBySideRendererConfig, defaultSideBySideRendererConfig } from './side-by-side-renderer';import { DiffFile, OutputFormatType } from './types';import HoganJsUtils, { HoganJsUtilsConfig } from './hoganjs-utils';export interface Diff2HtmlConfigextends DiffParser.DiffParserConfig,LineByLineRendererConfig,SideBySideRendererConfig,HoganJsUtilsConfig {outputFormat?: OutputFormatType;drawFileList?: boolean;}export const defaultDiff2HtmlConfig = {...defaultLineByLineRendererConfig,...defaultSideBySideRendererConfig,outputFormat: OutputFormatType.LINE_BY_LINE,drawFileList: true,};export function parse(diffInput: string, configuration: Diff2HtmlConfig = {}): DiffFile[] {return DiffParser.parse(diffInput, { ...defaultDiff2HtmlConfig, ...configuration });}export function html(diffInput: string | DiffFile[], configuration: Diff2HtmlConfig = {}): string {const config = { ...defaultDiff2HtmlConfig, ...configuration };const diffJson = typeof diffInput === 'string' ? DiffParser.parse(diffInput, config) : diffInput;const hoganUtils = new HoganJsUtils(config);const { colorScheme } = config;const fileListRendererConfig = { colorScheme };const fileList = config.drawFileList ? new FileListRenderer(hoganUtils, fileListRendererConfig).render(diffJson) : '';const diffOutput =config.outputFormat === 'side-by-side'? new SideBySideRenderer(hoganUtils, config).render(diffJson): new LineByLineRenderer(hoganUtils, config).render(diffJson);return fileList + diffOutput;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。