Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markmap-lib

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markmap-lib - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

dist/plugins/base.js

50

bin/cli.js
#!/usr/bin/env node
const { Command } = require('commander');
const COLOR_MAP = {

@@ -15,31 +13,21 @@ red: 31,

const program = new Command();
program
.version(require('../package.json').version)
.description('Create a markmap from a Markdown input file')
.arguments('<input>')
.option('-o, --output <output>', 'specify filename of the output HTML')
.option('--enable-mathjax', 'enable MathJax support')
.option('--enable-prism', 'enable PrismJS support')
.option('--no-open', 'do not open the output file after generation')
.option('-w, --watch', 'watch the input file and update output on the fly, note that this feature is for development only')
.action((input, cmd) => {
console.error(colored(`
DEPRECATED: The CLI feature of markmap-lib will be removed in v0.9.0,
console.error(colored(`
DEPRECATED: The CLI feature of markmap-lib is moved to markmap-cli since v0.9.0,
please consider using markmap-cli instead.
`, 'yellow'));
const options = {
open: cmd.open,
input,
output: cmd.output,
mathJax: cmd.enableMathjax,
prism: cmd.enablePrism,
};
if (cmd.watch) {
return require('../dist/dev-server').develop(options);
}
return require('..').createMarkmap(options);
});
program.parse(process.argv);
`, 'red'));
console.error(colored('Using npx:', 'yellow'));
console.error(`
npx markmap-cli note.md
`);
console.error(colored('Using yarn:', 'yellow'));
console.error(`
yarn global remove markmap-lib
yarn global add markmap-cli
markmap note.md
`);
console.error(colored('Using npm:', 'yellow'));
console.error(`
npm uninstall --global markmap-lib
npm install --global markmap-cli
markmap note.md
`);

@@ -1,5 +0,23 @@

/*! markmap-lib v0.8.1 | MIT License */
/*! markmap-lib v0.9.0 | MIT License */
(function (exports, d3) {
'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function count(node) {

@@ -589,13 +607,2 @@ var sum = 0,

}
function flatMap(arrayLike, callback) {
if (arrayLike.flatMap) return arrayLike.flatMap(callback);
const array = [];
for (let i = 0; i < arrayLike.length; i += 1) {
const result = callback(arrayLike[i], i, arrayLike);
if (Array.isArray(result)) array.push(...result);else array.push(result);
}
return array;
}
function addClass(className, ...rest) {

@@ -623,216 +630,2 @@ const classList = (className || '').split(' ').filter(Boolean);

function memoize(fn) {
const cache = {};
return function memoized(...args) {
const key = `${args[0]}`;
let data = cache[key];
if (!data) {
data = {
value: fn(...args)
};
cache[key] = data;
}
return data.value;
};
}
function createElement(tagName, props, attrs) {
const el = document.createElement(tagName);
if (props) {
Object.entries(props).forEach(([key, value]) => {
el[key] = value;
});
}
if (attrs) {
Object.entries(attrs).forEach(([key, value]) => {
el.setAttribute(key, value);
});
}
return el;
}
const memoizedPreloadJS = memoize(url => {
document.head.append(createElement('link', {
rel: 'preload',
as: 'script',
href: url
}));
});
function loadJSItem(item, context) {
if (item.type === 'script') {
return new Promise((resolve, reject) => {
document.head.append(createElement('script', Object.assign({}, item.data, {
onload: resolve,
onerror: reject
})));
});
} else if (item.type === 'iife') {
const {
fn,
getParams
} = item.data;
fn(...((getParams == null ? void 0 : getParams(context)) || []));
}
}
function loadCSSItem(item) {
if (item.type === 'style') {
document.head.append(createElement('style', {
textContent: item.data
}));
} else if (item.type === 'stylesheet') {
document.head.append(createElement('link', Object.assign({
rel: 'stylesheet'
}, item.data)));
}
}
async function loadJS(items, options) {
const needPreload = items.filter(item => item.type === 'script');
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
for (const item of items) {
await loadJSItem(item, options);
}
}
function loadCSS(items) {
for (const item of items) {
loadCSSItem(item);
}
}
async function initializePlugins(Markmap, plugins, options) {
options = Object.assign({}, options);
await Promise.all(plugins.map(plugin => {
loadCSS(plugin.styles);
return loadJS(plugin.scripts, options);
}));
for (const {
initialize
} of plugins) {
if (initialize) initialize(Markmap, options);
}
}
const styles = [];
const scripts = [{
type: 'iife',
data: {
fn: mathJax => {
mathJax.options = Object.assign({
skipHtmlTags: {
'[-]': ['code', 'pre']
}
}, mathJax.options);
mathJax.startup = Object.assign({
typeset: false
}, mathJax.startup);
window.MathJax = mathJax;
},
getParams: context => [Object.assign({}, context.mathJax)]
}
}, {
type: 'script',
data: {
src: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js'
}
}];
function initialize(Markmap, options) {
Markmap.transformHtml.tap((mm, nodes) => {
var _MathJax$typeset, _MathJax;
(_MathJax$typeset = (_MathJax = window.MathJax).typeset) == null ? void 0 : _MathJax$typeset.call(_MathJax, nodes);
});
}
const plugin = {
styles,
scripts,
initialize
};
const errors = {};
const styles$1 = [{
type: 'stylesheet',
data: {
href: 'https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css'
}
}];
const scripts$1 = [{
type: 'iife',
data: {
fn: () => {
window.Prism = {
manual: true
};
}
}
}, {
type: 'script',
data: {
src: 'https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js'
}
}, // components will be added by paths relative to path of autoloader
{
type: 'script',
data: {
src: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js'
}
}];
function initialize$1(Markmap, options) {
Markmap.transformHtml.tap((mm, nodes) => {
const {
Prism
} = window;
const langs = flatMap(nodes, node => arrayFrom(node.querySelectorAll('code[class*=language-]'))).map(code => {
const lang = code.className.match(/(?:^|\s)language-(\S+)|$/)[1];
if (Prism.languages[lang]) {
Prism.highlightElement(code);
} else if (!errors[lang]) {
return lang;
}
}).filter(Boolean);
loadLanguagesAndRender(mm, langs);
});
}
async function loadLanguagesAndRender(mm, langs) {
if (!langs.length) return;
const {
Prism
} = window;
try {
await new Promise((resolve, reject) => {
Prism.plugins.autoloader.loadLanguages(langs, resolve, reject);
});
} catch (err) {
errors[err] = true;
}
mm.setData();
mm.fit();
}
const plugin$1 = {
styles: styles$1,
scripts: scripts$1,
initialize: initialize$1
};
var plugins = /*#__PURE__*/Object.freeze({
__proto__: null,
mathJax: plugin,
prism: plugin$1
});
class Hook {

@@ -845,4 +638,14 @@ constructor() {

this.listeners.push(fn);
return () => this.revoke(fn);
}
revoke(fn) {
const i = this.listeners.indexOf(fn);
if (i >= 0) this.listeners.splice(i, 1);
}
revokeAll() {
this.listeners.splice(0);
}
call(...args) {

@@ -883,3 +686,3 @@ for (const fn of this.listeners) {

this.zoom = d3.zoom().on('zoom', this.handleZoom);
this.options = Object.assign({
this.options = _extends({
duration: 500,

@@ -916,3 +719,3 @@ nodeFont: '300 16px/20px sans-serif',

.${id}-g > path { fill: none; }
.${id}-fo > div { font: ${nodeFont}; white-space: nowrap; }
.${id}-fo > div { display: inline-block; font: ${nodeFont}; white-space: nowrap; }
.${id}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }

@@ -948,3 +751,3 @@ .${id}-fo del { text-decoration: line-through; }

} = d;
data.p = Object.assign({}, data.p, {
data.p = _extends({}, data.p, {
f: !((_data$p = data.p) == null ? void 0 : _data$p.f)

@@ -988,3 +791,3 @@ });

item.c = (_item$c = item.c) == null ? void 0 : _item$c.map(child => Object.assign({}, child));
item.c = (_item$c = item.c) == null ? void 0 : _item$c.map(child => _extends({}, child));
i += 1;

@@ -994,3 +797,3 @@ const el = document.createElement('div');

container.append(el);
item.p = Object.assign({}, item.p, {
item.p = _extends({}, item.p, {
// unique ID

@@ -1005,3 +808,3 @@ i,

const nodes = arrayFrom(container.childNodes);
this.constructor.transformHtml.call(this, nodes);
Markmap.transformHtml.call(this, nodes);
walkTree(node, (item, next, parent) => {

@@ -1027,3 +830,3 @@ var _parent$p;

setData(data, opts) {
if (!data) data = Object.assign({}, this.state.data);
if (!data) data = _extends({}, this.state.data);
this.state.data = data;

@@ -1098,7 +901,7 @@ this.initializeData(data);

return ((_d$data$p = d.data.p) == null ? void 0 : _d$data$p.f) ? color(d.data) : '#fff';
return ((_d$data$p = d.data.p) == null ? void 0 : _d$data$p.f) && d.data.c ? color(d.data) : '#fff';
});
const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.p.k).join(enter => {
const fo = enter.append('foreignObject').attr('class', `${id}-fo`).attr('x', paddingX).attr('y', 0).style('opacity', 0).attr('height', d => d.xSize);
fo.append('xhtml:div').select(function (d) {
fo.append('xhtml:div').select(function select(d) {
const node = d.data.p.el.cloneNode(true);

@@ -1197,23 +1000,6 @@ this.replaceWith(node);

}
async function loadPlugins(items, options) {
items = items.map(item => {
if (typeof item === 'string') {
const name = item;
item = plugins[name];
if (!item) {
console.warn(`[markmap] Unknown plugin: ${name}`);
}
}
return item;
}).filter(Boolean);
return initializePlugins(Markmap, items, options);
}
exports.Markmap = Markmap;
exports.loadPlugins = loadPlugins;
exports.markmap = markmap;
exports.plugins = plugins;
}(this.markmap = this.markmap || {}, d3));

@@ -1,2 +0,2 @@

/*! markmap-lib v0.8.1 | MIT License */
!function(t,e){"use strict";function n(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function r(t,e){var n,r,s,l,c,h=new o(t),d=+t.value&&(h.value=t.value),u=[h];for(null==e&&(e=i);n=u.pop();)if(d&&(n.value=+n.data.value),(s=e(n.data))&&(c=s.length))for(n.children=new Array(c),l=c-1;l>=0;--l)u.push(r=n.children[l]=new o(s[l])),r.parent=n,r.depth=n.depth+1;return h.eachBefore(a)}function i(t){return t.children}function s(t){t.data=t.data.data}function a(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function o(t){this.data=t,this.depth=this.height=0,this.parent=null}o.prototype=r.prototype={constructor:o,count:function(){return this.eachAfter(n)},each:function(t){var e,n,r,i,s=this,a=[s];do{for(e=a.reverse(),a=[];s=e.pop();)if(t(s),n=s.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this},eachAfter:function(t){for(var e,n,r,i=this,s=[i],a=[];i=s.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return r(this).eachBefore(s)}};const l=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function c(t){const e=Object.assign({},l,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function i(t){const e=a(function(){const t=s(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return h(this),d(this),this}}}(),t,t=>t.children);return e.update(),e.data}function s(){const t=n("nodeSize"),e=n("spacing");return class n extends r.prototype.constructor{constructor(t){super(t)}copy(){const t=a(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function a(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const a=n(e)||[];return s.children=0===a.length?null:a.map(t=>r(t,s)),s.children&&Object.assign(s,s.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),s)),s};return r(e,null)}return Object.assign(i,{nodeSize(t){return arguments.length?(e.nodeSize=t,i):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,i):e.spacing},children(t){return arguments.length?(e.children=t,i):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return a(s(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:a,y:o}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${s}${c.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${a}, y: ${o}${h}},`};return r("\n")(t)}}),i}c.version="2.1.1";const h=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;h(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;0!==r&&p(t,r,i);return[r+1,S(s,r,i)]},[0,null]),u(t),z(t),t),d=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>d(e,r,t.x)),t},u=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]},[0,0])},p=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,a=r.relX,o=i,l=i.relX,c=!0;for(;s&&o;){s.bottom>n.lowY&&(n=n.next);const r=a+s.prelim-(l+o.prelim)+s.xSize/2+o.xSize/2+s.spacing(o);(r>0||r<0&&c)&&(l+=r,f(i,r),g(t,e,n.index,r)),c=!1;const h=s.bottom,d=o.bottom;h<=d&&(s=x(s),s&&(a+=s.relX)),h>=d&&(o=m(o),o&&(l+=o.relX))}!s&&o?y(t,e,o,l):s&&!o&&v(t,e,s,a)},f=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},g=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},m=t=>t.hasChildren?t.firstChild:t.lThr,x=t=>t.hasChildren?t.lastChild:t.rThr,y=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,a=t.children[e];s.lThr=n;const o=r-n.relX-i.lExtRelX;s.relX+=o,s.prelim-=o,i.lExt=a.lExt,i.lExtRelX=a.lExtRelX},v=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,a=t.children[e-1];s.rThr=n;const o=r-n.relX-i.rExtRelX;s.relX+=o,s.prelim-=o,i.rExt=a.rExt,i.rExtRelX=a.rExtRelX},z=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},S=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},w=Math.random().toString(36).slice(2,8);let E=0;function b(){}function j(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function $(t){if(Array.from)return Array.from(t);const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function X(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}function k(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=$(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}function C(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach(([t,e])=>{r[t]=e}),n&&Object.entries(n).forEach(([t,e])=>{r.setAttribute(t,e)}),r}const O=function(t){const e={};return function(...n){const r=""+n[0];let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}(t=>{document.head.append(C("link",{rel:"preload",as:"script",href:t}))});function M(t,e){if("script"===t.type)return new Promise((e,n)=>{document.head.append(C("script",Object.assign({},t.data,{onload:e,onerror:n})))});if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function R(t){"style"===t.type?document.head.append(C("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(C("link",Object.assign({rel:"stylesheet"},t.data)))}async function A(t,e,n){n=Object.assign({},n),await Promise.all(e.map(t=>(function(t){for(const e of t)R(e)}(t.styles),async function(t,e){const n=t.filter(t=>"script"===t.type);n.length>1&&n.forEach(t=>O(t.data.src));for(const n of t)await M(n,e)}(t.scripts,n))));for(const{initialize:r}of e)r&&r(t,n)}const I={styles:[],scripts:[{type:"iife",data:{fn:t=>{t.options=Object.assign({skipHtmlTags:{"[-]":["code","pre"]}},t.options),t.startup=Object.assign({typeset:!1},t.startup),window.MathJax=t},getParams:t=>[Object.assign({},t.mathJax)]}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"}}],initialize:function(t,e){t.transformHtml.tap((t,e)=>{var n,r;null==(n=(r=window.MathJax).typeset)||n.call(r,e)})}},H={};const B={styles:[{type:"stylesheet",data:{href:"https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css"}}],scripts:[{type:"iife",data:{fn:()=>{window.Prism={manual:!0}}}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js"}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js"}}],initialize:function(t,e){t.transformHtml.tap((t,e)=>{const{Prism:n}=window;!async function(t,e){if(!e.length)return;const{Prism:n}=window;try{await new Promise((t,r)=>{n.plugins.autoloader.loadLanguages(e,t,r)})}catch(t){H[t]=!0}t.setData(),t.fit()}(t,function(t,e){if(t.flatMap)return t.flatMap(e);const n=[];for(let r=0;r<t.length;r+=1){const i=e(t[r],r,t);Array.isArray(i)?n.push(...i):n.push(i)}return n}(e,t=>$(t.querySelectorAll("code[class*=language-]"))).map(t=>{const e=t.className.match(/(?:^|\s)language-(\S+)|$/)[1];if(n.languages[e])n.highlightElement(t);else if(!H[e])return e}).filter(Boolean))})}};var N=Object.freeze({__proto__:null,mathJax:I,prism:B});function T(t){const e=t.data;return Math.max(6-2*e.d,1.5)}class P{constructor(t,n){var r;this.options=void 0,this.state=void 0,this.svg=void 0,this.styleNode=void 0,this.g=void 0,this.zoom=void 0,["handleZoom","handleClick"].forEach(t=>{this[t]=this[t].bind(this)}),this.svg=t.datum?t:e.select(t),this.styleNode=this.svg.append("style"),this.zoom=e.zoom().on("zoom",this.handleZoom),this.options=Object.assign({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:(r=e.scaleOrdinal(e.schemeCategory10),t=>r(t.p.i)),paddingX:8},n),this.state={id:this.options.id||(E+=1,`mm-${w}-${E}`)},this.g=this.svg.append("g").attr("class",this.state.id+"-g"),this.updateStyle(),this.svg.call(this.zoom)}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-fo > div { font: ${e}; white-space: nowrap; }\n.${n}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: bolder; }\n.${n}-fo pre { margin: 0; }\n.${n}-fo pre[class*=language-] { padding: 0; }\n.${n}-g > g { cursor: pointer; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",X(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(){const{transform:t}=e.event;this.g.attr("transform",t)}handleClick(t){var e;const{data:n}=t;n.p=Object.assign({},n.p,{f:!(null==(e=n.p)?void 0:e.f)}),this.renderData(t.data)}initializeData(t){let e=0;const{nodeFont:n,color:r,nodeMinHeight:i}=this.options,{id:s}=this.state,a=document.createElement("div"),o=s+"-container";a.className=X(a.className,s+"-fo",o);const l=document.createElement("style");l.textContent=`\n${this.getStyleContent()}\n.${o} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${n};\n}\n.${o} > div {\n display: inline-block;\n}\n`,document.body.append(l,a),j(t,(t,n)=>{var i;t.c=null==(i=t.c)?void 0:i.map(t=>Object.assign({},t)),e+=1;const s=document.createElement("div");s.innerHTML=t.v,a.append(s),t.p=Object.assign({},t.p,{i:e,el:s}),r(t),n()});const c=$(a.childNodes);this.constructor.transformHtml.call(this,c),j(t,(t,e,n)=>{var r;const s=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(s.width),Math.max(Math.ceil(s.height),i)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()}),a.remove(),l.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t||(t=Object.assign({},this.state.data)),this.state.data=t,this.initializeData(t),e&&this.setOptions(e),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:a,autoFit:o,color:l}=this.options,{id:h}=this.state,d=c().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]}).spacing((t,e)=>t.parent===e.parent?a:2*a),u=d.hierarchy(this.state.data);d(u),function(t,e){j(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(u,i);const p=u.descendants().reverse(),f=u.links(),g=e.linkHorizontal(),m=e.min(p,t=>t.x-t.xSize/2),x=e.max(p,t=>t.x+t.xSize/2),y=e.min(p,t=>t.y),v=e.max(p,t=>t.y+t.ySizeInner);Object.assign(this.state,{minX:m,maxX:x,minY:y,maxY:v}),o&&this.fit();const z=t&&p.find(e=>e.data===t)||u,S=null!=(n=z.data.p.x0)?n:z.x,w=null!=(r=z.data.p.y0)?r:z.y,E=this.g.selectAll(k("g")).data(p,t=>t.data.p.k),b=E.enter().append("g").attr("transform",t=>`translate(${w+z.ySizeInner-t.ySizeInner},${S+z.xSize/2-t.xSize})`).on("click",this.handleClick),$=this.transition(E.exit());$.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),$.select("foreignObject").style("opacity",0),$.attr("transform",t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`).remove();const X=E.merge(b);this.transition(X).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`);const C=X.selectAll(k("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-T(t)/2).attr("width",0).attr("height",T),t=>t,t=>t.remove());this.transition(C).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>l(t.data));const O=X.selectAll(k("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove());this.transition(O).attr("r",6).attr("stroke",t=>l(t.data)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)?l(t.data):"#fff"});const M=X.selectAll(k("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",h+"-fo").attr("x",s).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s));this.transition(M).style("opacity",1);const R=this.g.selectAll(k("path")).data(f,t=>t.target.data.p.k).join(t=>{const e=[w+z.ySizeInner,S+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))},t=>t,t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()});this.transition(R).attr("stroke",t=>l(t.target.data)).attr("stroke-width",t=>T(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return g({source:e,target:n})}),p.forEach(t=>{t.data.p.x0=t.x,t.data.p.y0=t.y})}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:a,minY:o,maxY:l}=this.state,c=l-o,h=a-s,d=Math.min(n/c*i,r/h*i,2),u=e.zoomIdentity.translate((n-c*d)/2-o*d,(r-h*d)/2-s*d).scale(d);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(b)}rescale(t){const n=this.svg.node(),{width:r,height:i}=n.getBoundingClientRect(),s=r/2,a=i/2,o=e.zoomTransform(n),l=o.translate((s-o.x)*(1-t)/o.k,(a-o.y)*(1-t)/o.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,l).end().catch(b)}static create(t,e,n){const r=new P(t,e);return n&&(r.setData(n),r.fit()),r}}P.transformHtml=new class{constructor(){this.listeners=[]}tap(t){this.listeners.push(t)}call(...t){for(const e of this.listeners)e(...t)}},t.Markmap=P,t.loadPlugins=async function(t,e){return t=t.map(t=>{if("string"==typeof t){const e=t;(t=N[e])||console.warn("[markmap] Unknown plugin: "+e)}return t}).filter(Boolean),A(P,t,e)},t.markmap=function(t,e,n){return P.create(t,n,e)},t.plugins=N}(this.markmap=this.markmap||{},d3);
/*! markmap-lib v0.9.0 | MIT License */
!function(t,e){"use strict";function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function i(t,e){var n,r,i,a,h,c=new l(t),d=+t.value&&(c.value=t.value),u=[c];for(null==e&&(e=s);n=u.pop();)if(d&&(n.value=+n.data.value),(i=e(n.data))&&(h=i.length))for(n.children=new Array(h),a=h-1;a>=0;--a)u.push(r=n.children[a]=new l(i[a])),r.parent=n,r.depth=n.depth+1;return c.eachBefore(o)}function s(t){return t.children}function a(t){t.data=t.data.data}function o(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function l(t){this.data=t,this.depth=this.height=0,this.parent=null}l.prototype=i.prototype={constructor:l,count:function(){return this.eachAfter(r)},each:function(t){var e,n,r,i,s=this,a=[s];do{for(e=a.reverse(),a=[];s=e.pop();)if(t(s),n=s.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this},eachAfter:function(t){for(var e,n,r,i=this,s=[i],a=[];i=s.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return i(this).eachBefore(a)}};const h=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function c(t){const e=Object.assign({},h,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function r(t){const e=a(function(){const t=s(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return d(this),u(this),this}}}(),t,t=>t.children);return e.update(),e.data}function s(){const t=n("nodeSize"),e=n("spacing");return class n extends i.prototype.constructor{constructor(t){super(t)}copy(){const t=a(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function a(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const a=n(e)||[];return s.children=0===a.length?null:a.map(t=>r(t,s)),s.children&&Object.assign(s,s.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),s)),s};return r(e,null)}return Object.assign(r,{nodeSize(t){return arguments.length?(e.nodeSize=t,r):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,r):e.spacing},children(t){return arguments.length?(e.children=t,r):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return a(s(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:a,y:o}=n,l=e(n),h=n.children||[],c=0===h.length?" ":`,${i}children: [${s}${h.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${a}, y: ${o}${c}},`};return r("\n")(t)}}),r}c.version="2.1.1";const d=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;d(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;0!==r&&f(t,r,i);return[r+1,E(s,r,i)]},[0,null]),p(t),S(t),t),u=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>u(e,r,t.x)),t},p=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]},[0,0])},f=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,a=r.relX,o=i,l=i.relX,h=!0;for(;s&&o;){s.bottom>n.lowY&&(n=n.next);const r=a+s.prelim-(l+o.prelim)+s.xSize/2+o.xSize/2+s.spacing(o);(r>0||r<0&&h)&&(l+=r,g(i,r),x(t,e,n.index,r)),h=!1;const c=s.bottom,d=o.bottom;c<=d&&(s=y(s),s&&(a+=s.relX)),c>=d&&(o=m(o),o&&(l+=o.relX))}!s&&o?v(t,e,o,l):s&&!o&&z(t,e,s,a)},g=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},x=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},m=t=>t.hasChildren?t.firstChild:t.lThr,y=t=>t.hasChildren?t.lastChild:t.rThr,v=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,a=t.children[e];s.lThr=n;const o=r-n.relX-i.lExtRelX;s.relX+=o,s.prelim-=o,i.lExt=a.lExt,i.lExtRelX=a.lExtRelX},z=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,a=t.children[e-1];s.rThr=n;const o=r-n.relX-i.rExtRelX;s.relX+=o,s.prelim-=o,i.rExt=a.rExt,i.rExtRelX=a.rExtRelX},S=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},E=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},$=Math.random().toString(36).slice(2,8);let X=0;function b(){}function w(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function k(t){if(Array.from)return Array.from(t);const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function C(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}function j(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=k(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}function O(t){const e=t.data;return Math.max(6-2*e.d,1.5)}class R{constructor(t,r){var i;this.options=void 0,this.state=void 0,this.svg=void 0,this.styleNode=void 0,this.g=void 0,this.zoom=void 0,["handleZoom","handleClick"].forEach(t=>{this[t]=this[t].bind(this)}),this.svg=t.datum?t:e.select(t),this.styleNode=this.svg.append("style"),this.zoom=e.zoom().on("zoom",this.handleZoom),this.options=n({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:(i=e.scaleOrdinal(e.schemeCategory10),t=>i(t.p.i)),paddingX:8},r),this.state={id:this.options.id||(X+=1,`mm-${$}-${X}`)},this.g=this.svg.append("g").attr("class",this.state.id+"-g"),this.updateStyle(),this.svg.call(this.zoom)}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-fo > div { display: inline-block; font: ${e}; white-space: nowrap; }\n.${n}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: bolder; }\n.${n}-fo pre { margin: 0; }\n.${n}-fo pre[class*=language-] { padding: 0; }\n.${n}-g > g { cursor: pointer; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",C(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(){const{transform:t}=e.event;this.g.attr("transform",t)}handleClick(t){var e;const{data:r}=t;r.p=n({},r.p,{f:!(null==(e=r.p)?void 0:e.f)}),this.renderData(t.data)}initializeData(t){let e=0;const{nodeFont:r,color:i,nodeMinHeight:s}=this.options,{id:a}=this.state,o=document.createElement("div"),l=a+"-container";o.className=C(o.className,a+"-fo",l);const h=document.createElement("style");h.textContent=`\n${this.getStyleContent()}\n.${l} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${r};\n}\n.${l} > div {\n display: inline-block;\n}\n`,document.body.append(h,o),w(t,(t,r)=>{var s;t.c=null==(s=t.c)?void 0:s.map(t=>n({},t)),e+=1;const a=document.createElement("div");a.innerHTML=t.v,o.append(a),t.p=n({},t.p,{i:e,el:a}),i(t),r()});const c=k(o.childNodes);R.transformHtml.call(this,c),w(t,(t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),s)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()}),o.remove(),h.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t||(t=n({},this.state.data)),this.state.data=t,this.initializeData(t),e&&this.setOptions(e),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:a,autoFit:o,color:l}=this.options,{id:h}=this.state,d=c().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]}).spacing((t,e)=>t.parent===e.parent?a:2*a),u=d.hierarchy(this.state.data);d(u),function(t,e){w(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(u,i);const p=u.descendants().reverse(),f=u.links(),g=e.linkHorizontal(),x=e.min(p,t=>t.x-t.xSize/2),m=e.max(p,t=>t.x+t.xSize/2),y=e.min(p,t=>t.y),v=e.max(p,t=>t.y+t.ySizeInner);Object.assign(this.state,{minX:x,maxX:m,minY:y,maxY:v}),o&&this.fit();const z=t&&p.find(e=>e.data===t)||u,S=null!=(n=z.data.p.x0)?n:z.x,E=null!=(r=z.data.p.y0)?r:z.y,$=this.g.selectAll(j("g")).data(p,t=>t.data.p.k),X=$.enter().append("g").attr("transform",t=>`translate(${E+z.ySizeInner-t.ySizeInner},${S+z.xSize/2-t.xSize})`).on("click",this.handleClick),b=this.transition($.exit());b.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),b.select("foreignObject").style("opacity",0),b.attr("transform",t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`).remove();const k=$.merge(X);this.transition(k).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`);const C=k.selectAll(j("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-O(t)/2).attr("width",0).attr("height",O),t=>t,t=>t.remove());this.transition(C).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>l(t.data));const R=k.selectAll(j("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove());this.transition(R).attr("r",6).attr("stroke",t=>l(t.data)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)&&t.data.c?l(t.data):"#fff"});const M=k.selectAll(j("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",h+"-fo").attr("x",s).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s));this.transition(M).style("opacity",1);const I=this.g.selectAll(j("path")).data(f,t=>t.target.data.p.k).join(t=>{const e=[E+z.ySizeInner,S+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))},t=>t,t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()});this.transition(I).attr("stroke",t=>l(t.target.data)).attr("stroke-width",t=>O(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return g({source:e,target:n})}),p.forEach(t=>{t.data.p.x0=t.x,t.data.p.y0=t.y})}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:a,minY:o,maxY:l}=this.state,h=l-o,c=a-s,d=Math.min(n/h*i,r/c*i,2),u=e.zoomIdentity.translate((n-h*d)/2-o*d,(r-c*d)/2-s*d).scale(d);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(b)}rescale(t){const n=this.svg.node(),{width:r,height:i}=n.getBoundingClientRect(),s=r/2,a=i/2,o=e.zoomTransform(n),l=o.translate((s-o.x)*(1-t)/o.k,(a-o.y)*(1-t)/o.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,l).end().catch(b)}static create(t,e,n){const r=new R(t,e);return n&&(r.setData(n),r.fit()),r}}R.transformHtml=new class{constructor(){this.listeners=[]}tap(t){return this.listeners.push(t),()=>this.revoke(t)}revoke(t){const e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}revokeAll(){this.listeners.splice(0)}call(...t){for(const e of this.listeners)e(...t)}},t.Markmap=R,t.markmap=function(t,e,n){return R.create(t,n,e)}}(this.markmap=this.markmap||{},d3);
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
var _exportNames = {
createMarkmap: true
};
exports.createMarkmap = createMarkmap;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _fs = require("fs");
var _open = _interopRequireDefault(require("open"));
var _transform = require("./transform");

@@ -18,25 +15,20 @@

var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _types[key];
});
async function createMarkmap(options = {}) {
const {
input,
open: openFile = true
} = options,
rest = (0, _objectWithoutPropertiesLoose2.default)(options, ["input", "open"]);
let {
content,
output
} = options;
if (input) {
content = await _fs.promises.readFile(input, 'utf8');
}
if (!output) {
output = input ? `${input.replace(/\.\w*$/, '')}.html` : 'markmap.html';
}
const root = (0, _transform.transform)(content || '');
const html = (0, _template.fillTemplate)(root, rest);
root,
features
} = (0, _transform.transform)(options.content || '');
const assets = (0, _transform.getUsedAssets)(features);
const html = (0, _template.fillTemplate)(root, assets);
const output = options.output || 'markmap.html';
await _fs.promises.writeFile(output, html, 'utf8');
if (openFile) (0, _open.default)(output);
return output;
}
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
exports.__esModule = true;
exports.prism = exports.mathJax = void 0;
var _exportNames = {
plugins: true
};
exports.plugins = void 0;
var _mathjax = require("./mathjax");
var katex = _interopRequireWildcard(require("./katex"));
exports.mathJax = _mathjax.plugin;
var prism = _interopRequireWildcard(require("./prism"));
var _prism = require("./prism");
var _base = require("./base");
exports.prism = _prism.plugin;
Object.keys(_base).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _base[key];
});
const plugins = [katex, prism];
exports.plugins = plugins;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.plugin = void 0;
exports.transform = transform;
exports.name = void 0;
var _util = require("../util");
var _prismjs = _interopRequireDefault(require("prismjs"));
const errors = {};
const styles = [{
type: 'stylesheet',
data: {
href: 'https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css'
}
}];
const scripts = [{
type: 'iife',
data: {
fn: () => {
window.Prism = {
manual: true
};
}
}
}, {
type: 'script',
data: {
src: 'https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js'
}
}, // components will be added by paths relative to path of autoloader
{
type: 'script',
data: {
src: 'https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js'
}
}];
var _components = _interopRequireDefault(require("prismjs/components/"));
function initialize(Markmap, options) {
Markmap.transformHtml.tap((mm, nodes) => {
const {
Prism
} = window;
const langs = (0, _util.flatMap)(nodes, node => (0, _util.arrayFrom)(node.querySelectorAll('code[class*=language-]'))).map(code => {
const lang = code.className.match(/(?:^|\s)language-(\S+)|$/)[1];
const name = 'prism';
exports.name = name;
if (Prism.languages[lang]) {
Prism.highlightElement(code);
} else if (!errors[lang]) {
return lang;
}
}).filter(Boolean);
loadLanguagesAndRender(mm, langs);
});
}
function transform(transformHooks) {
transformHooks.parser.tap((md, features) => {
md.set({
highlight: (str, lang) => {
features[name] = true;
let grammar = _prismjs.default.languages[lang];
async function loadLanguagesAndRender(mm, langs) {
if (!langs.length) return;
const {
Prism
} = window;
if (!grammar) {
(0, _components.default)([lang]);
grammar = _prismjs.default.languages[lang];
}
try {
await new Promise((resolve, reject) => {
Prism.plugins.autoloader.loadLanguages(langs, resolve, reject);
if (grammar) {
return _prismjs.default.highlight(str, grammar, lang);
}
return '';
}
});
} catch (err) {
errors[err] = true;
}
mm.setData();
mm.fit();
}
const plugin = {
styles,
scripts,
initialize
};
exports.plugin = plugin;
});
return {
styles: [{
type: 'stylesheet',
data: {
href: 'https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css'
}
}]
};
}

@@ -9,3 +9,3 @@ "use strict";

const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
const version = "0.8.1";
const version = "0.9.0";
const baseJs = ['https://cdn.jsdelivr.net/npm/d3@5', `https://cdn.jsdelivr.net/npm/markmap-lib@${version}/dist/browser/view.min.js`].map(src => ({

@@ -19,3 +19,8 @@ type: 'script',

function fillTemplate(data, opts) {
const jsList = [...(0, _util.persistJS)(baseJs), ...(0, _util.persistJS)([{
const {
scripts,
styles
} = opts;
const cssList = [...(styles ? (0, _util.persistCSS)(styles) : [])];
const jsList = [...(0, _util.persistJS)(baseJs), ...(scripts ? (0, _util.persistJS)(scripts) : []), ...(0, _util.persistJS)([{
type: 'iife',

@@ -50,4 +55,4 @@ data: {

})];
const html = template.replace('<!--CSS-->', '').replace('<!--JS-->', () => jsList.join(''));
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
return html;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.buildTree = buildTree;
exports.setPlugins = setPlugins;
exports.transform = transform;
exports.getAssets = getAssets;
exports.getUsedAssets = getUsedAssets;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _remarkable = require("remarkable");
var _util = require("./util");
var _plugins = require("./plugins");
const md = new _remarkable.Remarkable({
html: true
});
md.block.ruler.enable(['deflist']);
exports.builtInPlugins = _plugins.plugins;
function extractInline(token) {
const html = [];
const payload = {};
let style = {};
var _util = require("./util");
for (const child of token.children) {
if (child.type === 'text') {
html.push((0, _util.wrapStyle)((0, _util.escapeHtml)(child.content), style));
} else if (child.type === 'code') {
html.push((0, _util.wrapHtml)('code', (0, _util.wrapStyle)((0, _util.escapeHtml)(child.content), style)));
} else if (child.type === 'softbreak') {
html.push('<br/>');
} else if (child.type.endsWith('_open')) {
const type = child.type.slice(0, -5);
let md;
let assetsMap = {};
let plugins = [];
let transformHooks;
setPlugins(_plugins.plugins);
if (type === 'link') {
html.push((0, _util.htmlOpen)('a', {
href: child.href,
title: child.title,
target: '_blank',
rel: 'noopener noreferrer'
}));
} else {
style = Object.assign({}, style, {
[type]: true
});
}
} else if (child.type.endsWith('_close')) {
const type = child.type.slice(0, -6);
if (type === 'link') {
html.push((0, _util.htmlClose)('a'));
} else {
style = Object.assign({}, style, {
[type]: false
});
}
} else if (child.type === 'htmltag' && /^<!--([\s\S]*?)-->$/.test(child.content)) {
const comment = child.content.slice(4, -3).trim(); // <!-- fold -->
if (comment === 'fold') {
payload.f = true;
}
}
}
return [html.join(''), payload];
}
function cleanNode(node, depth = 0) {

@@ -77,3 +40,3 @@ if (node.t === 'heading') {

node.v = item.v;
node.p = Object.assign({}, node.p, item.p);
node.p = (0, _extends2.default)({}, node.p, item.p);
}

@@ -96,4 +59,4 @@

if (item.t === 'list_item') {
item.p = Object.assign({}, item.p, {
index: index
item.p = (0, _extends2.default)({}, item.p, {
index
});

@@ -118,3 +81,3 @@ index += 1;

function buildTree(tokens) {
function buildTree(md, tokens) {
// TODO deal with <dl><dt>

@@ -125,3 +88,4 @@ const root = {

v: '',
c: []
c: [],
p: {}
};

@@ -176,5 +140,14 @@ const stack = [root];

} else if (token.type === 'inline') {
const [text, payload] = extractInline(token);
const revoke = transformHooks.htmltag.tap(ctx => {
const comment = ctx.result.match(/^<!--([\s\S]*?)-->$/);
const data = comment == null ? void 0 : comment[1].trim();
if (data === 'fold') {
current.p.f = true;
ctx.result = '';
}
});
const text = md.renderer.render([token], md.options, {});
revoke();
current.v = `${current.v || ''}${text}`;
current.p = Object.assign({}, current.p, payload);
} else if (token.type === 'fence') {

@@ -184,3 +157,3 @@ current.c.push({

d: depth + 1,
v: `<pre><code class="language-${token.params}">${(0, _util.escapeHtml)(token.content)}</code></pre>`,
v: md.renderer.render([token], md.options, {}),
c: []

@@ -195,10 +168,61 @@ });

function setPlugins(newPlugins) {
plugins = newPlugins;
transformHooks = (0, _plugins.createTransformHooks)();
md = new _remarkable.Remarkable({
html: true
});
md.block.ruler.enable(['deflist']);
md.renderer.rules.htmltag = (0, _util.wrapFunction)(md.renderer.rules.htmltag, {
after: ctx => {
transformHooks.htmltag.call(ctx);
}
});
assetsMap = {};
for (const {
name,
transform
} of plugins) {
assetsMap[name] = transform(transformHooks);
}
}
function transform(content) {
var _root$c;
const features = {};
transformHooks.parser.call(md, features);
const tokens = md.parse(content || '', {});
let root = buildTree(tokens);
let root = buildTree(md, tokens);
cleanNode(root);
if (((_root$c = root.c) == null ? void 0 : _root$c.length) === 1) root = root.c[0];
return root;
return {
root,
features
};
}
function getAssets(keys) {
var _keys;
const styles = [];
const scripts = [];
(_keys = keys) != null ? _keys : keys = Object.keys(assetsMap);
for (const assets of keys.map(key => assetsMap[key])) {
if (assets) {
if (assets.styles) styles.push(...assets.styles);
if (assets.scripts) scripts.push(...assets.scripts);
}
}
return {
styles,
scripts
};
}
function getUsedAssets(features) {
return getAssets(Object.keys(features).filter(key => features[key]));
}

@@ -7,2 +7,6 @@ "use strict";

exports.IMarkmap = _view.IMarkmap;
exports.IMarkmap = _view.IMarkmap;
var _base = require("./plugins/base");
exports.ITransformHooks = _base.ITransformHooks;

@@ -11,2 +11,3 @@ "use strict";

exports.childSelector = childSelector;
exports.wrapFunction = wrapFunction;
const uniqId = Math.random().toString(36).slice(2, 8);

@@ -79,2 +80,27 @@ let globalIndex = 0;

};
}
function wrapFunction(fn, {
before,
after
}) {
return function wrapped(...args) {
const ctx = {
args
};
try {
if (before) before(ctx);
} catch (_unused) {// ignore
}
ctx.result = fn(...args);
try {
if (after) after(ctx);
} catch (_unused2) {// ignore
}
return ctx.result;
};
}

@@ -13,4 +13,14 @@ "use strict";

this.listeners.push(fn);
return () => this.revoke(fn);
}
revoke(fn) {
const i = this.listeners.indexOf(fn);
if (i >= 0) this.listeners.splice(i, 1);
}
revokeAll() {
this.listeners.splice(0);
}
call(...args) {

@@ -17,0 +27,0 @@ for (const fn of this.listeners) {

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -8,6 +10,7 @@ exports.buildCode = buildCode;

exports.loadCSS = loadCSS;
exports.initializePlugins = initializePlugins;
exports.persistJS = persistJS;
exports.persistCSS = persistCSS;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _html = require("./html");

@@ -69,3 +72,3 @@

return new Promise((resolve, reject) => {
document.head.append(createElement('script', Object.assign({}, item.data, {
document.head.append(createElement('script', (0, _extends2.default)({}, item.data, {
onload: resolve,

@@ -75,3 +78,5 @@ onerror: reject

});
} else if (item.type === 'iife') {
}
if (item.type === 'iife') {
const {

@@ -91,3 +96,3 @@ fn,

} else if (item.type === 'stylesheet') {
document.head.append(createElement('link', Object.assign({
document.head.append(createElement('link', (0, _extends2.default)({
rel: 'stylesheet'

@@ -113,16 +118,2 @@ }, item.data)));

async function initializePlugins(Markmap, plugins, options) {
options = Object.assign({}, options);
await Promise.all(plugins.map(plugin => {
loadCSS(plugin.styles);
return loadJS(plugin.scripts, options);
}));
for (const {
initialize
} of plugins) {
if (initialize) initialize(Markmap, options);
}
}
function persistJS(items, context) {

@@ -139,2 +130,4 @@ return items.map(item => {

}
return '';
});

@@ -146,3 +139,3 @@ }

if (item.type === 'stylesheet') {
return (0, _html.wrapHtml)('link', null, Object.assign({
return (0, _html.wrapHtml)('link', null, (0, _extends2.default)({
rel: 'stylesheet'

@@ -149,0 +142,0 @@ }, item.data));

@@ -5,7 +5,10 @@ "use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.markmap = markmap;
exports.loadPlugins = loadPlugins;
exports.plugins = exports.Markmap = void 0;
exports.Markmap = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var d3 = _interopRequireWildcard(require("d3"));

@@ -17,6 +20,2 @@

var plugins = _interopRequireWildcard(require("./plugins"));
exports.plugins = plugins;
var _hook = require("./util/hook");

@@ -51,3 +50,3 @@

this.zoom = d3.zoom().on('zoom', this.handleZoom);
this.options = Object.assign({
this.options = (0, _extends2.default)({
duration: 500,

@@ -84,3 +83,3 @@ nodeFont: '300 16px/20px sans-serif',

.${id}-g > path { fill: none; }
.${id}-fo > div { font: ${nodeFont}; white-space: nowrap; }
.${id}-fo > div { display: inline-block; font: ${nodeFont}; white-space: nowrap; }
.${id}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }

@@ -116,3 +115,3 @@ .${id}-fo del { text-decoration: line-through; }

} = d;
data.p = Object.assign({}, data.p, {
data.p = (0, _extends2.default)({}, data.p, {
f: !((_data$p = data.p) == null ? void 0 : _data$p.f)

@@ -156,3 +155,3 @@ });

item.c = (_item$c = item.c) == null ? void 0 : _item$c.map(child => Object.assign({}, child));
item.c = (_item$c = item.c) == null ? void 0 : _item$c.map(child => (0, _extends2.default)({}, child));
i += 1;

@@ -162,3 +161,3 @@ const el = document.createElement('div');

container.append(el);
item.p = Object.assign({}, item.p, {
item.p = (0, _extends2.default)({}, item.p, {
// unique ID

@@ -173,3 +172,3 @@ i,

const nodes = (0, _util.arrayFrom)(container.childNodes);
this.constructor.transformHtml.call(this, nodes);
Markmap.transformHtml.call(this, nodes);
(0, _util.walkTree)(node, (item, next, parent) => {

@@ -195,3 +194,3 @@ var _parent$p;

setData(data, opts) {
if (!data) data = Object.assign({}, this.state.data);
if (!data) data = (0, _extends2.default)({}, this.state.data);
this.state.data = data;

@@ -266,7 +265,7 @@ this.initializeData(data);

return ((_d$data$p = d.data.p) == null ? void 0 : _d$data$p.f) ? color(d.data) : '#fff';
return ((_d$data$p = d.data.p) == null ? void 0 : _d$data$p.f) && d.data.c ? color(d.data) : '#fff';
});
const foreignObject = nodeMerge.selectAll((0, _util.childSelector)('foreignObject')).data(d => [d], d => d.data.p.k).join(enter => {
const fo = enter.append('foreignObject').attr('class', `${id}-fo`).attr('x', paddingX).attr('y', 0).style('opacity', 0).attr('height', d => d.xSize);
fo.append('xhtml:div').select(function (d) {
fo.append('xhtml:div').select(function select(d) {
const node = d.data.p.el.cloneNode(true);

@@ -367,18 +366,2 @@ this.replaceWith(node);

return Markmap.create(svg, opts, data);
}
async function loadPlugins(items, options) {
items = items.map(item => {
if (typeof item === 'string') {
const name = item;
item = plugins[name];
if (!item) {
console.warn(`[markmap] Unknown plugin: ${name}`);
}
}
return item;
}).filter(Boolean);
return (0, _util.initializePlugins)(Markmap, items, options);
}
{
"name": "markmap-lib",
"version": "0.8.1",
"version": "0.9.0",
"description": "Visualize your Markdown as mindmaps with Markmap",
"author": "Gerald <i@gerald.top>",
"author": "Gerald <gera2ld@live.com>",
"license": "MIT",
"husky": {
"hooks": {
"pre-push": "npm run lint"
}
},
"bin": {

@@ -22,4 +17,5 @@ "markmap": "bin/cli.js"

"build:js": "gulp build",
"prebuild": "npm run clean",
"prebuild": "npm run ci && npm run clean",
"prepublishOnly": "npm run build",
"ci": "npm run lint",
"build": "tsc && npm run build:js",

@@ -29,3 +25,4 @@ "lint": "eslint --ext .ts ."

"publishConfig": {
"access": "public"
"access": "public",
"registry": "https://registry.npmjs.org/"
},

@@ -48,5 +45,2 @@ "main": "dist/index.js",

"devDependencies": {
"@gera2ld/plaid": "~2.0.2",
"@gera2ld/plaid-common-ts": "~2.0.2",
"@gera2ld/plaid-rollup": "~2.0.2",
"del": "^5.1.0",

@@ -56,4 +50,3 @@ "fancy-log": "^1.3.3",

"gulp-babel": "^8.0.0",
"gulp-replace": "^1.0.0",
"husky": "^4.2.5"
"gulp-replace": "^1.0.0"
},

@@ -63,10 +56,11 @@ "dependencies": {

"@types/d3": "^5.7.2",
"chokidar": "^3.4.2",
"commander": "^5.1.0",
"d3": "^5.16.0",
"d3-flextree": "^2.1.1",
"katex": "^0.12.0",
"koa": "^2.13.0",
"open": "^7.0.3",
"remarkable": "^2.0.0"
}
"prismjs": "^1.21.0",
"remarkable": "^2.0.0",
"remarkable-katex": "^1.1.6"
},
"gitHead": "88a9287c44f037890641a11bd67950655693900e"
}

@@ -9,3 +9,3 @@ # markmap-lib

This project is heavily inspired by [Markmap](https://github.com/dundalek/markmap).
This project is heavily inspired by [dundalek's markmap](https://github.com/dundalek/markmap).

@@ -24,50 +24,4 @@ [Try it out](https://markmap.js.org/repl).

You can also use with `npx` without installation:
See [markmap-cli](https://github.com/gera2ld/markmap/tree/master/packages/markmap-cli) for command-line usage.
```sh
$ npx markmap-lib
```
## Command-line Usage
```
Usage: markmap [options] <input>
Create a markmap from a Markdown input file
Options:
-V, --version output the version number
-o, --output <output> specify filename of the output HTML
--enable-mathjax enable MathJax support
--enable-prism enable PrismJS support
--no-open do not open the output file after generation
-w, --watch watch the input file and update output on the fly, note that this feature is for development only
-h, --help display help for command
```
### Creating a markmap
Suppose we have a Markdown file named `note.md`.
Run the following command to get an interactive mindmap:
```sh
$ markmap note.md
# without global installation
$ npx markmap-lib note.md
```
Then we get `note.html` in the same directory, and hopefully it will be open in your default browser.
### Watching changes
Enable watching mode by `-w`:
```sh
$ markmap -w note.md
```
A markmap will be created and opened in your browser, and will be updated as soon as changes are saved to the source file.
## API

@@ -108,50 +62,1 @@

```
### Plugins
- `mathJax` - MathJax
- `prism` - PrismJS
#### Command-line
To enable plugins in command line, just add the related option, for example:
```sh
$ markmap note.md --enable-mathjax --enable-prism
```
#### API
`loadPlugins` loads necessary CSS and JavaScript files.
```js
import { Markmap, loadPlugins } from 'markmap-lib/dist/view';
loadPlugins([
'mathJax',
'prism',
])
.then(() => {
Markmap.create('#markmap', null, data);
});
```
MathJax options can be changed in the second parameter:
```js
loadPlugins([
'mathJax',
'prism',
], {
mathJax: {
tex: {
inlineMath: [['$','$'], ['\\(','\\)']],
},
},
});
```
## Related
- Use with Vim / Neovim: [coc-markmap](https://github.com/gera2ld/coc-markmap)
- Use with GatsbyJS: [gatsby-remark-markmap](https://github.com/gera2ld/gatsby-remark-markmap)
import { IMarkmapCreateOptions } from './types';
export declare function createMarkmap(options?: IMarkmapCreateOptions): Promise<void>;
export * from './types';
export declare function createMarkmap(options?: IMarkmapCreateOptions): Promise<string>;

@@ -1,2 +0,4 @@

export { plugin as mathJax } from './mathjax';
export { plugin as prism } from './prism';
import * as katex from './katex';
import * as prism from './prism';
export * from './base';
export declare const plugins: (typeof katex | typeof prism)[];

@@ -1,2 +0,3 @@

import { IMarkmapPlugin } from '../types';
export declare const plugin: IMarkmapPlugin;
import { IAssets, ITransformHooks } from '../types';
export declare const name = "prism";
export declare function transform(transformHooks: ITransformHooks): IAssets;

@@ -1,2 +0,2 @@

import { IMarkmapCreateOptions } from './types';
export declare function fillTemplate(data: any, opts?: IMarkmapCreateOptions): string;
import { INode, IAssets } from './types';
export declare function fillTemplate(data: INode, opts: IAssets): string;

@@ -1,3 +0,8 @@

import { INode } from './types';
export declare function buildTree(tokens: any): INode;
export declare function transform(content: string): INode;
import { INode, ITransformResult, ITransformPlugin, IAssets } from './types';
import { plugins as builtInPlugins } from './plugins';
export { builtInPlugins };
export declare function buildTree(md: any, tokens: any): INode;
export declare function setPlugins(newPlugins: ITransformPlugin[]): void;
export declare function transform(content: string): ITransformResult;
export declare function getAssets(keys?: string[]): IAssets;
export declare function getUsedAssets(features: any): IAssets;
import { IMarkmap } from './view';
export { IMarkmap };
import { ITransformHooks } from './plugins/base';
export { IMarkmap, ITransformHooks };
export interface IHierarchy<T> {

@@ -27,27 +28,16 @@ /**

}
export interface IAssets {
styles?: CSSItem[];
scripts?: JSItem[];
}
export interface IMarkmapCreateOptions {
/**
* whether to open the generated markmap in browser
* Markdown content as string.
*/
open?: boolean;
/**
* Markdown content as string. It will be ignored if `input` is provided.
*/
content?: string;
/**
* Input file path of a Markdown file. If this is provided, `content` will be ignored.
* Output file path of the markmap HTML file.
* If not provided, the same basename as the Markdown input file will be used.
*/
input?: string;
/**
* Output file path of the markmap HTML file. If not provided, the same basename as the Markdown input file will be used.
*/
output?: string;
/**
* Enable MathJax support. If an object is passed, it will be merged into MathJax options.
*/
mathJax?: boolean | object;
/**
* Enable Prism support for code blocks.
*/
prism?: boolean;
}

@@ -79,2 +69,4 @@ export interface IMarkmapOptions {

src: string;
async?: boolean;
defer?: boolean;
};

@@ -94,7 +86,2 @@ };

};
export interface IMarkmapPlugin {
styles: CSSItem[];
scripts: JSItem[];
initialize?: (Markmap: IMarkmap, options: any) => void;
}
export interface IMarkmapFlexTreeItem {

@@ -114,1 +101,16 @@ parent: IMarkmapFlexTreeItem;

}
export interface IAssetsMap {
[key: string]: IAssets;
}
export interface ITransformResult {
root: INode;
features: any;
}
export interface ITransformPlugin {
name: string;
transform: (transformHooks: ITransformHooks) => IAssets;
}
export interface IWrapContext<T extends (...args: any[]) => any> {
args: Parameters<T>;
result?: ReturnType<T>;
}

@@ -0,1 +1,2 @@

import { IWrapContext } from '../types';
export declare function getId(): string;

@@ -8,1 +9,5 @@ export declare function noop(): void;

export declare function childSelector<T extends Element>(filter?: string | ((el: T) => boolean)): () => T[];
export declare function wrapFunction<T extends (...args: any[]) => any>(fn: T, { before, after }: {
before?: (ctx: IWrapContext<T>) => void;
after?: (ctx: IWrapContext<T>) => void;
}): T;
export declare class Hook<T extends (...args: any[]) => void> {
protected listeners: T[];
tap(fn: T): void;
tap(fn: T): () => void;
revoke(fn: T): void;
revokeAll(): void;
call(...args: Parameters<T>): void;
}

@@ -1,3 +0,2 @@

import { JSItem, CSSItem, IMarkmapPlugin } from '../types';
import { IMarkmap } from '../view';
import { JSItem, CSSItem } from '../types';
export declare function buildCode(fn: Function, ...args: any[]): string;

@@ -7,4 +6,3 @@ export declare function memoize<T extends (...args: any[]) => any>(fn: T): T;

export declare function loadCSS(items: CSSItem[]): void;
export declare function initializePlugins(Markmap: IMarkmap, plugins: IMarkmapPlugin[], options: any): Promise<void>;
export declare function persistJS(items: JSItem[], context?: any): string[];
export declare function persistCSS(items: CSSItem[]): string[];
import * as d3 from 'd3';
import { INode, IMarkmapOptions, IMarkmapState, IMarkmapFlexTreeItem } from './types';
import * as plugins from './plugins';
import { Hook } from './util/hook';
export { plugins };
declare type ID3SVGElement = d3.Selection<SVGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;

@@ -31,2 +29,2 @@ export declare class Markmap {

export declare function markmap(svg: string | SVGElement | ID3SVGElement, data?: INode, opts?: IMarkmapOptions): Markmap;
export declare function loadPlugins(items: any[], options: any): Promise<void>;
export {};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc