/* eslint-disable no-unused-vars */ import tinydate from 'tinydate'; import DOMPurify from 'dompurify'; import * as dom from '../util/dom'; import cssVars from '../util/polyfill/css-vars'; import { callHook } from '../init/lifecycle'; import { getAndActive, sticky } from '../event/sidebar'; import { getPath, isAbsolutePath } from '../router/util'; import { isMobile, inBrowser } from '../util/env'; import { isPrimitive } from '../util/core'; import { scrollActiveSidebar } from '../event/scroll'; import { Compiler } from './compiler'; import * as tpl from './tpl'; import { prerenderEmbed } from './embed'; function executeScript() { const script = dom .findAll('.markdown-section>script') .filter(s => !/template/.test(s.type))[0]; if (!script) { return false; } const code = script.innerText.trim(); if (!code) { return false; } new Function(code)(); } function formatUpdated(html, updated, fn) { updated = typeof fn === 'function' ? fn(updated) : typeof fn === 'string' ? tinydate(fn)(new Date(updated)) : updated; return html.replace(/{docsify-updated}/g, updated); } function renderMain(html) { if (!html) { html = '

404 - Not found

'; } this._renderTo('.markdown-section', html); // Render sidebar with the TOC !this.config.loadSidebar && this._renderSidebar(); // Execute markdown