markmap-lib 0.11.6 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,19 +1,20 @@
1
- /*! markmap-lib v0.11.6 | MIT License */
1
+ /*! markmap-lib v0.12.0 | MIT License */
2
2
  import _extends from '@babel/runtime/helpers/esm/extends';
3
3
  import { persistCSS, persistJS, wrapFunction, Hook } from 'markmap-common';
4
4
  import { Remarkable } from 'remarkable';
5
5
  import remarkableKatex from 'remarkable-katex';
6
6
  import Prism from 'prismjs';
7
7
  import loadLanguages from 'prismjs/components/';
8
+ import yaml from 'js-yaml';
8
9
 
9
10
  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";
10
- const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.6.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.6"}`].map(src => ({
11
+ const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.7"}`].map(src => ({
11
12
  type: 'script',
12
13
  data: {
13
14
  src
14
15
  }
15
16
  }));
16
- function fillTemplate(data, assets, extra) {
17
+ function fillTemplate(root, assets, extra) {
17
18
  if (typeof extra === 'function') {
18
19
  extra = {
19
20
  getOptions: extra
@@ -31,7 +32,7 @@ function fillTemplate(data, assets, extra) {
31
32
  const context = {
32
33
  getMarkmap: () => window.markmap,
33
34
  getOptions: extra.getOptions,
34
- data
35
+ data: root
35
36
  };
36
37
  const jsList = [...persistJS(extra.baseJs), ...persistJS([...(scripts || []), {
37
38
  type: 'iife',
@@ -55,16 +56,23 @@ function fillTemplate(data, assets, extra) {
55
56
  return html;
56
57
  }
57
58
 
58
- const name$1 = 'katex';
59
- function transform$1(transformHooks) {
60
- transformHooks.parser.tap((md, features) => {
59
+ const name$2 = 'katex';
60
+ function transform$2(transformHooks) {
61
+ let enableFeature = () => {};
62
+
63
+ transformHooks.parser.tap(md => {
61
64
  md.use(remarkableKatex);
62
65
  md.renderer.rules.katex = wrapFunction(md.renderer.rules.katex, {
63
66
  after: () => {
64
- features[name$1] = true;
67
+ enableFeature();
65
68
  }
66
69
  });
67
70
  });
71
+ transformHooks.transform.tap((_, context) => {
72
+ enableFeature = () => {
73
+ context.features[name$2] = true;
74
+ };
75
+ });
68
76
  return {
69
77
  styles: [{
70
78
  type: 'stylesheet',
@@ -105,16 +113,18 @@ function transform$1(transformHooks) {
105
113
 
106
114
  var katex = /*#__PURE__*/Object.freeze({
107
115
  __proto__: null,
108
- name: name$1,
109
- transform: transform$1
116
+ name: name$2,
117
+ transform: transform$2
110
118
  });
111
119
 
112
- const name = 'prism';
113
- function transform(transformHooks) {
114
- transformHooks.parser.tap((md, features) => {
120
+ const name$1 = 'prism';
121
+ function transform$1(transformHooks) {
122
+ let enableFeature = () => {};
123
+
124
+ transformHooks.parser.tap(md => {
115
125
  md.set({
116
126
  highlight: (str, lang) => {
117
- features[name] = true;
127
+ enableFeature();
118
128
  let grammar = Prism.languages[lang];
119
129
 
120
130
  if (!grammar) {
@@ -130,11 +140,16 @@ function transform(transformHooks) {
130
140
  }
131
141
  });
132
142
  });
143
+ transformHooks.transform.tap((_, context) => {
144
+ enableFeature = () => {
145
+ context.features[name$1] = true;
146
+ };
147
+ });
133
148
  return {
134
149
  styles: [{
135
150
  type: 'stylesheet',
136
151
  data: {
137
- href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.23.0"}/themes/prism.css`
152
+ href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.25.0"}/themes/prism.css`
138
153
  }
139
154
  }]
140
155
  };
@@ -142,6 +157,43 @@ function transform(transformHooks) {
142
157
 
143
158
  var prism = /*#__PURE__*/Object.freeze({
144
159
  __proto__: null,
160
+ name: name$1,
161
+ transform: transform$1
162
+ });
163
+
164
+ const name = 'frontmatter';
165
+ function transform(transformHooks) {
166
+ transformHooks.transform.tap((md, context) => {
167
+ const origParse = md.parse;
168
+ md.parse = wrapFunction(origParse, {
169
+ before(ctx) {
170
+ const [content] = ctx.args;
171
+ if (!content.startsWith('---\n')) return;
172
+ const endOffset = content.indexOf('\n---\n');
173
+ if (endOffset < 0) return;
174
+ const raw = content.slice(4, endOffset);
175
+
176
+ try {
177
+ context.frontmatter = yaml.load(raw);
178
+ } catch (_unused) {
179
+ return;
180
+ }
181
+
182
+ const offset = endOffset + 5;
183
+ ctx.args[0] = content.slice(offset);
184
+ },
185
+
186
+ after() {
187
+ md.parse = origParse;
188
+ }
189
+
190
+ });
191
+ });
192
+ return {};
193
+ }
194
+
195
+ var frontmatter = /*#__PURE__*/Object.freeze({
196
+ __proto__: null,
145
197
  name: name,
146
198
  transform: transform
147
199
  });
@@ -149,17 +201,13 @@ transform: transform
149
201
  function createTransformHooks() {
150
202
  return {
151
203
  parser: new Hook(),
204
+ transform: new Hook(),
152
205
  htmltag: new Hook(),
153
-
154
- /**
155
- * Indicate that the last transformation is not complete for reasons like
156
- * lack of resources and is called when it is ready for a new transformation.
157
- */
158
206
  retransform: new Hook()
159
207
  };
160
208
  }
161
209
 
162
- const plugins = [katex, prism];
210
+ const plugins = [katex, prism, frontmatter];
163
211
 
164
212
  function cleanNode(node, depth = 0) {
165
213
  if (node.t === 'heading') {
@@ -214,12 +262,18 @@ function cleanNode(node, depth = 0) {
214
262
 
215
263
  class Transformer {
216
264
  constructor(plugins$1 = plugins) {
217
- this.plugins = void 0;
218
- this.hooks = void 0;
219
- this.md = void 0;
220
- this.assetsMap = void 0;
221
265
  this.plugins = plugins$1;
222
266
  this.hooks = createTransformHooks();
267
+ const assetsMap = {};
268
+
269
+ for (const {
270
+ name,
271
+ transform
272
+ } of plugins$1) {
273
+ assetsMap[name] = transform(this.hooks);
274
+ }
275
+
276
+ this.assetsMap = assetsMap;
223
277
  const md = new Remarkable({
224
278
  html: true,
225
279
  breaks: true,
@@ -232,16 +286,7 @@ class Transformer {
232
286
  }
233
287
  });
234
288
  this.md = md;
235
- const assetsMap = {};
236
-
237
- for (const {
238
- name,
239
- transform
240
- } of plugins$1) {
241
- assetsMap[name] = transform(this.hooks);
242
- }
243
-
244
- this.assetsMap = assetsMap;
289
+ this.hooks.parser.call(md);
245
290
  }
246
291
 
247
292
  buildTree(tokens) {
@@ -340,16 +385,17 @@ class Transformer {
340
385
  transform(content) {
341
386
  var _root$c;
342
387
 
343
- const features = {};
344
- this.hooks.parser.call(this.md, features);
345
- const tokens = this.md.parse(content || '', {});
388
+ const context = {
389
+ features: {}
390
+ };
391
+ this.hooks.transform.call(this.md, context);
392
+ const tokens = this.md.parse(content, {});
346
393
  let root = this.buildTree(tokens);
347
394
  cleanNode(root);
348
395
  if (((_root$c = root.c) == null ? void 0 : _root$c.length) === 1) root = root.c[0];
349
- return {
350
- root,
351
- features
352
- };
396
+ return _extends({}, context, {
397
+ root
398
+ });
353
399
  }
354
400
  /**
355
401
  * Get all assets from enabled plugins or filter them by plugin names as keys.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.11.6 | MIT License */
1
+ /*! markmap-lib v0.12.0 | MIT License */
2
2
  'use strict';
3
3
 
4
4
  var _extends = require('@babel/runtime/helpers/extends');
@@ -7,22 +7,24 @@ var remarkable = require('remarkable');
7
7
  var remarkableKatex = require('remarkable-katex');
8
8
  var Prism = require('prismjs');
9
9
  var loadLanguages = require('prismjs/components/');
10
+ var yaml = require('js-yaml');
10
11
 
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
12
13
 
13
14
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
14
15
  var remarkableKatex__default = /*#__PURE__*/_interopDefaultLegacy(remarkableKatex);
15
16
  var Prism__default = /*#__PURE__*/_interopDefaultLegacy(Prism);
16
17
  var loadLanguages__default = /*#__PURE__*/_interopDefaultLegacy(loadLanguages);
18
+ var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
17
19
 
18
20
  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";
19
- const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.6.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.6"}`].map(src => ({
21
+ const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.7"}`].map(src => ({
20
22
  type: 'script',
21
23
  data: {
22
24
  src
23
25
  }
24
26
  }));
25
- function fillTemplate(data, assets, extra) {
27
+ function fillTemplate(root, assets, extra) {
26
28
  if (typeof extra === 'function') {
27
29
  extra = {
28
30
  getOptions: extra
@@ -40,7 +42,7 @@ function fillTemplate(data, assets, extra) {
40
42
  const context = {
41
43
  getMarkmap: () => window.markmap,
42
44
  getOptions: extra.getOptions,
43
- data
45
+ data: root
44
46
  };
45
47
  const jsList = [...markmapCommon.persistJS(extra.baseJs), ...markmapCommon.persistJS([...(scripts || []), {
46
48
  type: 'iife',
@@ -64,16 +66,23 @@ function fillTemplate(data, assets, extra) {
64
66
  return html;
65
67
  }
66
68
 
67
- const name$1 = 'katex';
68
- function transform$1(transformHooks) {
69
- transformHooks.parser.tap((md, features) => {
69
+ const name$2 = 'katex';
70
+ function transform$2(transformHooks) {
71
+ let enableFeature = () => {};
72
+
73
+ transformHooks.parser.tap(md => {
70
74
  md.use(remarkableKatex__default);
71
75
  md.renderer.rules.katex = markmapCommon.wrapFunction(md.renderer.rules.katex, {
72
76
  after: () => {
73
- features[name$1] = true;
77
+ enableFeature();
74
78
  }
75
79
  });
76
80
  });
81
+ transformHooks.transform.tap((_, context) => {
82
+ enableFeature = () => {
83
+ context.features[name$2] = true;
84
+ };
85
+ });
77
86
  return {
78
87
  styles: [{
79
88
  type: 'stylesheet',
@@ -114,16 +123,18 @@ function transform$1(transformHooks) {
114
123
 
115
124
  var katex = /*#__PURE__*/Object.freeze({
116
125
  __proto__: null,
117
- name: name$1,
118
- transform: transform$1
126
+ name: name$2,
127
+ transform: transform$2
119
128
  });
120
129
 
121
- const name = 'prism';
122
- function transform(transformHooks) {
123
- transformHooks.parser.tap((md, features) => {
130
+ const name$1 = 'prism';
131
+ function transform$1(transformHooks) {
132
+ let enableFeature = () => {};
133
+
134
+ transformHooks.parser.tap(md => {
124
135
  md.set({
125
136
  highlight: (str, lang) => {
126
- features[name] = true;
137
+ enableFeature();
127
138
  let grammar = Prism__default.languages[lang];
128
139
 
129
140
  if (!grammar) {
@@ -139,11 +150,16 @@ function transform(transformHooks) {
139
150
  }
140
151
  });
141
152
  });
153
+ transformHooks.transform.tap((_, context) => {
154
+ enableFeature = () => {
155
+ context.features[name$1] = true;
156
+ };
157
+ });
142
158
  return {
143
159
  styles: [{
144
160
  type: 'stylesheet',
145
161
  data: {
146
- href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.23.0"}/themes/prism.css`
162
+ href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.25.0"}/themes/prism.css`
147
163
  }
148
164
  }]
149
165
  };
@@ -151,6 +167,43 @@ function transform(transformHooks) {
151
167
 
152
168
  var prism = /*#__PURE__*/Object.freeze({
153
169
  __proto__: null,
170
+ name: name$1,
171
+ transform: transform$1
172
+ });
173
+
174
+ const name = 'frontmatter';
175
+ function transform(transformHooks) {
176
+ transformHooks.transform.tap((md, context) => {
177
+ const origParse = md.parse;
178
+ md.parse = markmapCommon.wrapFunction(origParse, {
179
+ before(ctx) {
180
+ const [content] = ctx.args;
181
+ if (!content.startsWith('---\n')) return;
182
+ const endOffset = content.indexOf('\n---\n');
183
+ if (endOffset < 0) return;
184
+ const raw = content.slice(4, endOffset);
185
+
186
+ try {
187
+ context.frontmatter = yaml__default.load(raw);
188
+ } catch (_unused) {
189
+ return;
190
+ }
191
+
192
+ const offset = endOffset + 5;
193
+ ctx.args[0] = content.slice(offset);
194
+ },
195
+
196
+ after() {
197
+ md.parse = origParse;
198
+ }
199
+
200
+ });
201
+ });
202
+ return {};
203
+ }
204
+
205
+ var frontmatter = /*#__PURE__*/Object.freeze({
206
+ __proto__: null,
154
207
  name: name,
155
208
  transform: transform
156
209
  });
@@ -158,17 +211,13 @@ transform: transform
158
211
  function createTransformHooks() {
159
212
  return {
160
213
  parser: new markmapCommon.Hook(),
214
+ transform: new markmapCommon.Hook(),
161
215
  htmltag: new markmapCommon.Hook(),
162
-
163
- /**
164
- * Indicate that the last transformation is not complete for reasons like
165
- * lack of resources and is called when it is ready for a new transformation.
166
- */
167
216
  retransform: new markmapCommon.Hook()
168
217
  };
169
218
  }
170
219
 
171
- const plugins = [katex, prism];
220
+ const plugins = [katex, prism, frontmatter];
172
221
 
173
222
  function cleanNode(node, depth = 0) {
174
223
  if (node.t === 'heading') {
@@ -223,12 +272,18 @@ function cleanNode(node, depth = 0) {
223
272
 
224
273
  class Transformer {
225
274
  constructor(plugins$1 = plugins) {
226
- this.plugins = void 0;
227
- this.hooks = void 0;
228
- this.md = void 0;
229
- this.assetsMap = void 0;
230
275
  this.plugins = plugins$1;
231
276
  this.hooks = createTransformHooks();
277
+ const assetsMap = {};
278
+
279
+ for (const {
280
+ name,
281
+ transform
282
+ } of plugins$1) {
283
+ assetsMap[name] = transform(this.hooks);
284
+ }
285
+
286
+ this.assetsMap = assetsMap;
232
287
  const md = new remarkable.Remarkable({
233
288
  html: true,
234
289
  breaks: true,
@@ -241,16 +296,7 @@ class Transformer {
241
296
  }
242
297
  });
243
298
  this.md = md;
244
- const assetsMap = {};
245
-
246
- for (const {
247
- name,
248
- transform
249
- } of plugins$1) {
250
- assetsMap[name] = transform(this.hooks);
251
- }
252
-
253
- this.assetsMap = assetsMap;
299
+ this.hooks.parser.call(md);
254
300
  }
255
301
 
256
302
  buildTree(tokens) {
@@ -349,16 +395,17 @@ class Transformer {
349
395
  transform(content) {
350
396
  var _root$c;
351
397
 
352
- const features = {};
353
- this.hooks.parser.call(this.md, features);
354
- const tokens = this.md.parse(content || '', {});
398
+ const context = {
399
+ features: {}
400
+ };
401
+ this.hooks.transform.call(this.md, context);
402
+ const tokens = this.md.parse(content, {});
355
403
  let root = this.buildTree(tokens);
356
404
  cleanNode(root);
357
405
  if (((_root$c = root.c) == null ? void 0 : _root$c.length) === 1) root = root.c[0];
358
- return {
359
- root,
360
- features
361
- };
406
+ return _extends__default({}, context, {
407
+ root
408
+ });
362
409
  }
363
410
  /**
364
411
  * Get all assets from enabled plugins or filter them by plugin names as keys.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-lib",
3
- "version": "0.11.6",
3
+ "version": "0.12.0",
4
4
  "description": "Visualize your Markdown as mindmaps with Markmap",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -11,8 +11,7 @@
11
11
  "dev": "rollup -wc rollup.conf.js",
12
12
  "clean": "del-cli dist types",
13
13
  "build:types": "tsc",
14
- "build:js": "rollup -c rollup.conf.js",
15
- "lint": "eslint --ext .ts ."
14
+ "build:js": "rollup -c rollup.conf.js"
16
15
  },
17
16
  "publishConfig": {
18
17
  "access": "public",
@@ -35,15 +34,17 @@
35
34
  ],
36
35
  "repository": "git@github.com:gera2ld/markmap.git",
37
36
  "devDependencies": {
38
- "markmap-view": "^0.2.6"
37
+ "@types/remarkable": "^2.0.3",
38
+ "markmap-view": "^0.2.7"
39
39
  },
40
40
  "dependencies": {
41
- "@babel/runtime": "^7.12.5",
42
- "katex": "^0.12.0",
43
- "markmap-common": "^0.1.5",
44
- "prismjs": "^1.21.0",
45
- "remarkable": "^2.0.0",
46
- "remarkable-katex": "^1.1.6"
41
+ "@babel/runtime": "^7.16.3",
42
+ "js-yaml": "^4.1.0",
43
+ "katex": "^0.15.1",
44
+ "markmap-common": "^0.1.6",
45
+ "prismjs": "^1.25.0",
46
+ "remarkable": "^2.0.1",
47
+ "remarkable-katex": "^1.1.8"
47
48
  },
48
- "gitHead": "c1b04d45e3d7a9be432c2980ee105983abac7470"
49
+ "gitHead": "fbec667e1706813f9f60bea6a971f3820858ca40"
49
50
  }
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types';
2
- export * from './template';
3
- export * from './transform';
1
+ export * from './types';
2
+ export * from './template';
3
+ export * from './transform';
@@ -1,10 +1,2 @@
1
- import { IWrapContext, Hook } from 'markmap-common';
2
- export declare function createTransformHooks(): {
3
- parser: Hook<(md: any, features: any) => void>;
4
- htmltag: Hook<(ctx: IWrapContext<any>) => void>;
5
- /**
6
- * Indicate that the last transformation is not complete for reasons like
7
- * lack of resources and is called when it is ready for a new transformation.
8
- */
9
- retransform: Hook<() => void>;
10
- };
1
+ import { ITransformHooks } from '../types';
2
+ export declare function createTransformHooks(): ITransformHooks;
@@ -0,0 +1,3 @@
1
+ import { IAssets, ITransformHooks } from '../types';
2
+ export declare const name = "frontmatter";
3
+ export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -1,4 +1,5 @@
1
- import * as katex from './katex';
2
- import * as prism from './prism';
3
- export * from './base';
4
- export declare const plugins: (typeof katex | typeof prism)[];
1
+ import * as katex from './katex';
2
+ import * as prism from './prism';
3
+ import * as frontmatter from './frontmatter';
4
+ export * from './base';
5
+ export declare const plugins: (typeof katex | typeof prism | typeof frontmatter)[];
@@ -1,3 +1,3 @@
1
- import { IAssets, ITransformHooks } from '../types';
2
- export declare const name = "katex";
3
- export declare function transform(transformHooks: ITransformHooks): IAssets;
1
+ import { IAssets, ITransformHooks } from '../types';
2
+ export declare const name = "katex";
3
+ export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -1,3 +1,3 @@
1
- import { IAssets, ITransformHooks } from '../types';
2
- export declare const name = "katex";
3
- export declare function transform(transformHooks: ITransformHooks): IAssets;
1
+ import { IAssets, ITransformHooks } from '../types';
2
+ export declare const name = "katex";
3
+ export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -1,3 +1,3 @@
1
- import { IAssets, ITransformHooks } from '../types';
2
- export declare const name = "prism";
3
- export declare function transform(transformHooks: ITransformHooks): IAssets;
1
+ import { IAssets, ITransformHooks } from '../types';
2
+ export declare const name = "prism";
3
+ export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -1,3 +1,3 @@
1
- import { IAssets, ITransformHooks } from '../types';
2
- export declare const name = "prism";
3
- export declare function transform(transformHooks: ITransformHooks): IAssets;
1
+ import { IAssets, ITransformHooks } from '../types';
2
+ export declare const name = "prism";
3
+ export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -1,6 +1,6 @@
1
- import { JSItem, INode } from 'markmap-common';
2
- import { IAssets } from './types';
3
- export declare function fillTemplate(data: INode | undefined, assets: IAssets, extra?: {
4
- baseJs?: JSItem[];
5
- getOptions?: () => any;
6
- } | (() => any)): string;
1
+ import { JSItem, INode } from 'markmap-common';
2
+ import { IAssets } from './types';
3
+ export declare function fillTemplate(root: INode | undefined, assets: IAssets, extra?: {
4
+ baseJs?: JSItem[];
5
+ getOptions?: () => any;
6
+ } | (() => any)): string;
@@ -1,22 +1,22 @@
1
- import { Remarkable } from 'remarkable';
2
- import { INode } from 'markmap-common';
3
- import { ITransformResult, ITransformPlugin, IAssets, IAssetsMap, ITransformHooks, IFeatures } from './types';
4
- import { plugins as builtInPlugins } from './plugins';
5
- export { builtInPlugins };
6
- export declare class Transformer {
7
- plugins: ITransformPlugin[];
8
- hooks: ITransformHooks;
9
- md: Remarkable;
10
- assetsMap: IAssetsMap;
11
- constructor(plugins?: ITransformPlugin[]);
12
- buildTree(tokens: any): INode;
13
- transform(content: string): ITransformResult;
14
- /**
15
- * Get all assets from enabled plugins or filter them by plugin names as keys.
16
- */
17
- getAssets(keys?: string[]): IAssets;
18
- /**
19
- * Get used assets by features object returned by `transform`.
20
- */
21
- getUsedAssets(features: IFeatures): IAssets;
22
- }
1
+ import { Remarkable } from 'remarkable';
2
+ import { INode } from 'markmap-common';
3
+ import { ITransformResult, ITransformPlugin, IAssets, IAssetsMap, ITransformHooks, IFeatures } from './types';
4
+ import { plugins as builtInPlugins } from './plugins';
5
+ export { builtInPlugins };
6
+ export declare class Transformer {
7
+ plugins: ITransformPlugin[];
8
+ hooks: ITransformHooks;
9
+ md: Remarkable;
10
+ assetsMap: IAssetsMap;
11
+ constructor(plugins?: ITransformPlugin[]);
12
+ buildTree(tokens: Remarkable.Token[]): INode;
13
+ transform(content: string): ITransformResult;
14
+ /**
15
+ * Get all assets from enabled plugins or filter them by plugin names as keys.
16
+ */
17
+ getAssets(keys?: string[]): IAssets;
18
+ /**
19
+ * Get used assets by features object returned by `transform`.
20
+ */
21
+ getUsedAssets(features: IFeatures): IAssets;
22
+ }