/* 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 { getAndActive, sticky } from '../event/sidebar'; import { getPath, isAbsolutePath } from '../router/util'; import { isMobile, inBrowser } from '../util/env'; import { isPrimitive, merge } from '../util/core'; import { scrollActiveSidebar } from '../event/scroll'; import { Compiler } from './compiler'; import * as tpl from './tpl'; import { prerenderEmbed } from './embed'; let vueGlobalData; 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) { const docsifyConfig = this.config; const markdownElm = dom.find('.markdown-section'); const vueVersion = 'Vue' in window && window.Vue.version && Number(window.Vue.version.charAt(0)); const isMountedVue = elm => { const isVue2 = Boolean(elm.__vue__ && elm.__vue__._isVue); const isVue3 = Boolean(elm._vnode && elm._vnode.__v_skip); return isVue2 || isVue3; }; if (!html) { html = '