markdown-magic 3.7.0 → 4.0.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.
@@ -1,461 +1,5 @@
1
- const { parseBlocks } = require('./block-parser')
2
- const { deepLog } = require('./utils/logs')
3
- const { getCodeLocation } = require('./utils')
4
- const { indentString, trimString } = require('./utils/text')
5
- const { OPEN_WORD, CLOSE_WORD, SYNTAX } = require('./defaults')
6
-
7
- /**
8
- * Configuration object for processing contents.
9
- * @typedef {Object} ProcessContentConfig
10
- * @property {string} srcPath - The source path.
11
- * @property {string} outputPath - The output path.
12
- * @property {string} [open=OPEN_WORD] - The opening delimiter.
13
- * @property {string} [close=CLOSE_WORD] - The closing delimiter.
14
- * @property {string} [syntax='md'] - The syntax type.
15
- * @property {Array<Function>} [transforms=[]] - The array of transform functions.
16
- * @property {Array<Function>} [beforeMiddleware=[]] - The array of middleware functions to be executed before processing.
17
- * @property {Array<Function>} [afterMiddleware=[]] - The array of middleware functions to be executed after processing.
18
- * @property {boolean} [debug=false] - Enable debug mode.
19
- * @property {boolean} [removeComments=false] - Remove comments from the processed contents.
20
- */
21
-
22
- /**
23
- * Pull comment blocks out of content and process them
24
- * @param {string} text
25
- * @param {ProcessContentConfig} config
26
- * @returns
27
- */
28
- async function processContents(text, config) {
29
- const opts = config || {}
30
-
31
- const {
32
- srcPath,
33
- outputPath,
34
- open = OPEN_WORD, // 'DOCS:START',
35
- close = CLOSE_WORD, // 'DOCS:END',
36
- syntax = SYNTAX, // 'md'
37
- transforms = [],
38
- beforeMiddleware = [],
39
- afterMiddleware = [],
40
- debug = false,
41
- removeComments = false
42
- } = opts
43
-
44
- /*
45
- console.log('Open word', open)
46
- console.log('Close word', close)
47
- console.log('syntax', syntax)
48
- // console.log('text', text)
49
- /** */
50
-
51
- let foundBlocks = {}
52
- try {
53
- foundBlocks = parseBlocks(text, {
54
- syntax,
55
- open,
56
- close,
57
- })
58
- } catch (e) {
59
- throw new Error(`${e.message}\nFix content in ${srcPath}\n`)
60
- }
61
-
62
- // if (debug) {
63
- // console.log(`foundBlocks ${srcPath}`)
64
- // deepLog(foundBlocks)
65
- // }
66
- /*
67
- deepLog(foundBlocks)
68
- process.exit(1)
69
- /** */
70
- const { COMMENT_OPEN_REGEX, COMMENT_CLOSE_REGEX } = foundBlocks
71
-
72
- const blocksWithTransforms = foundBlocks.blocks
73
- .filter((block) => block.type)
74
- .map((block, i) => {
75
- const transform = block.type
76
- delete block.type
77
- return Object.assign({ transform }, block)
78
- })
79
-
80
-
81
- const regexInfo = {
82
- blocks: foundBlocks.pattern,
83
- open: COMMENT_OPEN_REGEX,
84
- close: COMMENT_CLOSE_REGEX,
85
- }
86
- // console.log('blocksWithTransforms', blocksWithTransforms)
87
- // process.exit(1)
88
-
89
- const transformsToRun = sortTranforms(blocksWithTransforms, transforms)
90
- // .map((transform) => {
91
- // return {
92
- // ...transform,
93
- // srcPath
94
- // }
95
- // })
96
- // console.log('transformsToRun', transformsToRun)
97
-
98
- // if (!transformsToRun.length) {
99
- // process.exit(1)
100
- // }
101
- // console.log('transformsToRun', transformsToRun)
102
- let missingTransforms = []
103
- let updatedContents = await transformsToRun.reduce(async (contentPromise, originalMatch) => {
104
- const md = await contentPromise
105
- /* Apply Before middleware to all transforms */
106
- const match = await applyMiddleware(originalMatch, md, beforeMiddleware)
107
- const { block, content, open, close, transform, options, context } = match
108
- // console.log("MATCH", match)
109
- const closeTag = close.value
110
- const openTag = open.value
111
-
112
- /* Run transform plugins */
113
- let tempContent = content.value
114
- // console.log('transform', transform)
115
- const currentTransformFn = getTransform(transform, transforms)
116
- /* Run each transform */
117
- if (currentTransformFn) {
118
- // console.log('context', context)
119
- let returnedContent
120
- /* DISABLED legacy syntax */
121
- /* // Support for legacy syntax... maybe later
122
- if (context && context.isLegacy) {
123
- console.log(`CALL legacy ${transform}`, srcPath)
124
- // backward compat maybe
125
- // CODE(content, options, config)
126
- returnedContent = await currentTransformFn(content.value, options, {
127
- originalPath: srcPath
128
- })
129
- } else {
130
- returnedContent = await currentTransformFn(transformApi({
131
- srcPath,
132
- ...match,
133
- regex: regexInfo,
134
- originalContents: text,
135
- currentContents: md,
136
- }, config))
137
- }
138
- /** */
139
-
140
- returnedContent = await currentTransformFn(
141
- transformApi({
142
- srcPath,
143
- ...match,
144
- regex: regexInfo,
145
- originalContents: text,
146
- currentContents: md,
147
- }, config)
148
- )
149
-
150
- /* Run each transform */
151
- // console.log('config', config)
152
-
153
- // console.log('returnedContent', returnedContent)
154
- // process.exit(1)
155
-
156
-
157
- if (returnedContent) {
158
- tempContent = returnedContent
159
- }
160
- }
161
-
162
- /* Apply After middleware to all transforms */
163
- const afterContent = await applyMiddleware({
164
- ...match,
165
- ...{
166
- content: {
167
- ...match.content,
168
- value: tempContent
169
- }
170
- }
171
- }, md, afterMiddleware)
172
- /*
173
- console.log('afterContent', afterContent)
174
- process.exit(1)
175
- /** */
176
-
177
- if (debug) {
178
- // console.log('afterContent', afterContent)
179
- }
180
-
181
- if (!currentTransformFn) {
182
- missingTransforms.push(afterContent)
183
- // console.log(`Missing "${transform}" transform`)
184
- }
185
-
186
- const newContent = afterContent.content.value
187
- const formattedNewContent = (options.noTrim) ? newContent : trimString(newContent)
188
- // console.log('formattedNewContent', formattedNewContent)
189
- /* Remove any conflicting imported comments */
190
- const fix = removeConflictingComments(formattedNewContent, COMMENT_OPEN_REGEX, COMMENT_CLOSE_REGEX)
191
- /*
192
- console.log('fix')
193
- deepLog(fix)
194
- process.exit(1)
195
- /** */
196
- if (options.removeComments) {
197
- // console.log('removeComments', options.removeComments)
198
- }
199
- // const fix = stripAllComments(formattedNewContent, foundBlocks.COMMENT_OPEN_REGEX, COMMENT_CLOSE_REGEX)
200
-
201
- // console.log('COMMENT_CLOSE_REGEX', COMMENT_CLOSE_REGEX)
202
- // console.log('formattedNewContent', formattedNewContent)
203
- // console.log('fix', fix)
204
-
205
- let preserveIndent = 0
206
- if (match.content.indentation) {
207
- preserveIndent = match.content.indentation
208
- } else if (preserveIndent === 0) {
209
- preserveIndent = block.indentation.length
210
- }
211
- // console.log('preserveIndent', preserveIndent)
212
- let addTrailingNewline = ''
213
- if (context.isMultiline && !fix.endsWith('\n') && fix !== '' && closeTag.indexOf('\n') === -1) {
214
- addTrailingNewline = '\n'
215
- }
216
-
217
- let addLeadingNewline = ''
218
- if (context.isMultiline && !fix.startsWith('\n') && fix !== '' && openTag.indexOf('\n') === -1) {
219
- addLeadingNewline = '\n'
220
- }
221
-
222
- let fixWrapper = ''
223
- /* If block wasn't multiline but the contents ARE multiline fix the block */
224
- if (!context.isMultiline && fix.indexOf('\n') > -1) {
225
- fixWrapper = '\n'
226
- }
227
-
228
- // console.log("OPEN TAG", `"${openTag}"`)
229
- // console.log("CLOSE TAG", `"${closeTag}"`)
230
-
231
- const indent = addLeadingNewline + indentString(fix, preserveIndent) + addTrailingNewline
232
- const newCont = `${openTag}${fixWrapper}${indent}${fixWrapper}${closeTag}`
233
- /* Replace original contents */
234
- // Must use replacer function because strings get coerced to regex or something
235
- const newContents = md.replace(block.value, () => newCont)
236
- /*
237
- deepLog(newContents)
238
- process.exit(1)
239
- /** */
240
- return Promise.resolve(newContents)
241
- }, Promise.resolve(text))
242
-
243
- // console.log('updatedContents')
244
- // deepLog(updatedContents)
245
- // process.exit(1)
246
-
247
- // if (debug) {
248
- // console.log('Output Markdown')
249
- // console.log(updatedContents)
250
- // }
251
-
252
- /*
253
- if (missingTransforms.length) {
254
- console.log('missingTransforms', missingTransforms)
255
- let matchOne = missingTransforms[1]
256
- matchOne = missingTransforms[missingTransforms.length - 1]
257
- // console.log('matchOne', matchOne)
258
- const { block, transform, args } = matchOne
259
- const { openTag, closeTag, content, contentStart, contentEnd, start, end} = block
260
-
261
- // console.log('contentStart', contentStart)
262
- // console.log('contentEnd', contentEnd)
263
- // console.log('original text between', `"${getTextBetweenChars(md, contentStart, contentEnd)}"`)
264
- // console.log('original block between', `"${getTextBetweenChars(md, start, end)}"`)
265
- }
266
- /** */
267
-
268
- // console.log('detect slow srcPath', srcPath)
269
-
270
- const isNewPath = srcPath !== outputPath
271
-
272
- if (removeComments && !isNewPath) {
273
- throw new Error('"removeComments" can only be used if "outputPath" option is set. Otherwise this will break doc generation.')
274
- }
275
-
276
- /* Strip block comments from output files */
277
- const stripComments = isNewPath && removeComments
278
-
279
- // console.log('srcPath', srcPath)
280
- // console.log('outputPath', outputPath)
281
- // console.log('updatedContents', updatedContents)
282
- // console.log('text', text)
283
- // process.exit(1)
284
- const result = {
285
- /* Has markdown content changed? */
286
- isChanged: text !== updatedContents,
287
- isNewPath,
288
- stripComments,
289
- srcPath,
290
- outputPath,
291
- // config,
292
- transforms: transformsToRun,
293
- missingTransforms,
294
- originalContents: text,
295
- updatedContents,
296
- }
297
- /*
298
- console.log('result')
299
- deepLog(result)
300
- process.exit(1)
301
- /** */
302
- return result
303
- }
304
-
305
- function transformApi(stuff, opts) {
306
- const { transforms, srcPath, outputPath, ...rest } = opts
307
- return {
308
- transform: stuff.transform,
309
- content: stuff.content.value,
310
- options: stuff.options || {},
311
- srcPath: stuff.srcPath,
312
- outputPath: outputPath,
313
- /* Library settings */
314
- settings: {
315
- ...rest,
316
- regex: stuff.regex,
317
- },
318
- // blockContent: stuff.content.value,
319
- currentFileContent: stuff.currentContents,
320
- originalFileContent: stuff.originalContents,
321
- /* Methods */
322
- getCurrentContent: () => stuff.currentContents,
323
- getOriginalContent: () => stuff.originalContents,
324
- getOriginalBlock: () => stuff,
325
- getBlockDetails: (content) => {
326
- /* Re-parse current file for updated positions */
327
- return getDetails({
328
- contents: content || stuff.currentContents,
329
- openValue: stuff.open.value,
330
- srcPath: stuff.srcPath,
331
- index: stuff.index,
332
- opts: opts
333
- })
334
- },
335
- // getOriginalBlockDetails: () => {
336
- // return getDetails({
337
- // contents: stuff.originalContents,
338
- // openValue: stuff.open.value,
339
- // srcPath: stuff.srcPath,
340
- // index: stuff.index,
341
- // opts: opts
342
- // })
343
- // },
344
- }
345
- }
346
-
347
- function getDetails({
348
- contents,
349
- openValue,
350
- srcPath,
351
- index,
352
- opts
353
- }) {
354
- /* Re-parse current file for updated positions */
355
- const blockData = parseBlocks(contents, opts)
356
- // console.log('blockData', blockData)
357
-
358
- const matchingBlocks = blockData.blocks.filter((block) => {
359
- return block.open.value === openValue
360
- })
361
-
362
- if (!matchingBlocks.length) {
363
- return {}
364
- }
365
-
366
- let foundBlock = matchingBlocks[0]
367
- if (matchingBlocks.length > 1 && index) {
368
- foundBlock = matchingBlocks.filter((block) => {
369
- return block.index === index
370
- })[0]
371
- }
372
-
373
- if (srcPath) {
374
- const location = getCodeLocation(srcPath, foundBlock.block.lines[0])
375
- foundBlock.sourceLocation = location
376
- }
377
- return foundBlock
378
- }
379
-
380
- /**
381
- * Remove conflicting comments that might have been inserted from transforms
382
- * @param {*} content
383
- * @param {*} openPattern
384
- * @param {*} closePattern
385
- * @returns
386
- */
387
- function removeConflictingComments(content, openPattern, closePattern) {
388
- // console.log('openPattern', openPattern)
389
- // console.log('closePattern', closePattern)
390
- const removeOpen = content.replace(openPattern, '')
391
- // TODO this probably needs to be a loop for larger blocks
392
- closePattern.lastIndex = 0; // reset regex
393
- const hasClose = closePattern.exec(content)
394
- // console.log('closePattern', closePattern)
395
- // console.log('has', content)
396
- // console.log('hasClose', hasClose)
397
- if (!hasClose) {
398
- return removeOpen
399
- }
400
- const closeTag = `${hasClose[2]}${hasClose[3] || ''}`
401
- // console.log('closeTag', closeTag)
402
- return removeOpen
403
- .replace(closePattern, '')
404
- // .replaceAll(closeTag, '')
405
- /* Trailing new line */
406
- .replace(/\n$/, '')
407
- }
408
-
409
- function applyMiddleware(data, md, middlewares) {
410
- return middlewares.reduce(async (acc, curr) => {
411
- const realAcc = await acc
412
- // console.log(`Running "${curr.name}" Middleware on "${realAcc.transform}" block`)
413
- const updatedContent = await curr.transform(realAcc, md)
414
- // realAcc.block.content = updatedContent
415
- return Promise.resolve({
416
- ...realAcc,
417
- ...{
418
- content: {
419
- ...realAcc.content,
420
- value: updatedContent
421
- }
422
- }
423
- })
424
- }, Promise.resolve(data))
425
- }
426
-
427
- /**
428
- * Get Transform function
429
- * @param {string} name - transform name
430
- * @param {object} transforms - transform fns
431
- * @returns {function}
432
- */
433
- function getTransform(name, transforms = {}) {
434
- return transforms[name] || transforms[name.toLowerCase()]
435
- }
436
-
437
- function sortTranforms(foundTransForms, registeredTransforms) {
438
- // console.log('transforms', transforms)
439
- if (!foundTransForms) return []
440
- return foundTransForms.sort((a, b) => {
441
- // put table of contents (TOC) at end of tranforms
442
- if (a.transform === 'TOC' || a.transform === 'sectionToc') return 1
443
- if (b.transform === 'TOC' || b.transform === 'sectionToc') return -1
444
- return 0
445
- }).map((item) => {
446
- if (getTransform(item.transform, registeredTransforms)) {
447
- return item
448
- }
449
- return {
450
- ...item,
451
- context: {
452
- ...item.context,
453
- isMissing: true,
454
- }
455
- }
456
- })
457
- }
1
+ const { blockTransformer } = require('comment-block-transformer')
458
2
 
459
3
  module.exports = {
460
- processContents
4
+ processContents: blockTransformer
461
5
  }
@@ -2,7 +2,7 @@ const fs = require('fs')
2
2
  const path = require('path')
3
3
  const { remoteRequest } = require('../../utils/remoteRequest')
4
4
  const { isLocalPath } = require('../../utils/fs')
5
- const { deepLog } = require('../../utils/logs')
5
+ const { deepLog } = require('../../../src/utils/logs')
6
6
  const {
7
7
  getLineCount,
8
8
  getTextBetweenLines,
@@ -27,15 +27,15 @@ const RAW_URL_LIKE = /^([A-Za-z0-9_]+)\.([A-Za-z0-9_]*)\/(.*)/
27
27
  * @property {boolean} [trimDeadCode] - Remove multi-line comments that start with `//` from the code.
28
28
  * @example
29
29
  ```md
30
- <!-- doc-gen CODE src="./relative/path/to/code.js" -->
30
+ <!-- docs CODE src="./relative/path/to/code.js" -->
31
31
  This content will be dynamically replaced with code from the file
32
- <!-- end-doc-gen -->
32
+ <!-- /docs -->
33
33
  ```
34
-
34
+
35
35
  ```md
36
- <!-- doc-gen CODE src="./relative/path/to/code.js" lines="22-44" -->
36
+ <!-- docs CODE src="./relative/path/to/code.js" lines="22-44" -->
37
37
  This content will be dynamically replaced with code from the file lines 22 through 44
38
- <!-- end-doc-gen -->
38
+ <!-- /docs -->
39
39
  ```
40
40
  */
41
41
 
@@ -12,10 +12,10 @@ const path = require('path')
12
12
  * @property {string} [format="tree"] - Output format: "tree" or "list". Default is `"tree"`.
13
13
  * @example
14
14
  ```md
15
- <!-- doc-gen fileTree src="./src" maxDepth=2 -->
15
+ <!-- docs fileTree src="./src" maxDepth=2 -->
16
16
  file tree will be generated here
17
- <!-- end-doc-gen -->
18
- ```
17
+ <!-- /docs -->
18
+ ```
19
19
  */
20
20
 
21
21
  /**
@@ -21,12 +21,12 @@ const transforms = {
21
21
  *
22
22
  * **Example:**
23
23
  * ```md
24
- * <!-- doc-gen TOC -->
24
+ * <!-- docs TOC -->
25
25
  * toc will be generated here
26
- * <!-- end-doc-gen -->
26
+ * <!-- /docs -->
27
27
  * ```
28
28
  *
29
- * Default `matchWord` is `doc-gen`
29
+ * Default `matchWord` is `docs`
30
30
  *
31
31
  * ---
32
32
  * @param {string} content The current content of the comment block
@@ -48,18 +48,18 @@ const transforms = {
48
48
  *
49
49
  * **Example:**
50
50
  * ```md
51
- * <!-- doc-gen CODE src="./relative/path/to/code.js" -->
51
+ * <!-- docs CODE src="./relative/path/to/code.js" -->
52
52
  * This content will be dynamically replaced with code from the file
53
- * <!-- end-doc-gen -->
53
+ * <!-- /docs -->
54
54
  * ```
55
55
  *
56
56
  * ```md
57
- * <!-- doc-gen CODE src="./relative/path/to/code.js" lines=22-44 -->
57
+ * <!-- docs CODE src="./relative/path/to/code.js" lines=22-44 -->
58
58
  * This content will be dynamically replaced with code from the file lines 22 through 44
59
- * <!-- end-doc-gen -->
59
+ * <!-- /docs -->
60
60
  * ```
61
- *
62
- * Default `matchWord` is `doc-gen`
61
+ *
62
+ * Default `matchWord` is `docs`
63
63
  *
64
64
  * ---
65
65
  * @param {string} content The current content of the comment block
@@ -77,12 +77,12 @@ const transforms = {
77
77
  *
78
78
  * **Example:**
79
79
  * ```md
80
- * <!-- doc-gen FILE src=./path/to/file -->
80
+ * <!-- docs FILE src=./path/to/file -->
81
81
  * This content will be dynamically replaced from the local file
82
- * <!-- end-doc-gen -->
82
+ * <!-- /docs -->
83
83
  * ```
84
84
  *
85
- * Default `matchWord` is `doc-gen`
85
+ * Default `matchWord` is `docs`
86
86
  *
87
87
  * ---
88
88
  * @param {string} content The current content of the comment block
@@ -100,12 +100,12 @@ const transforms = {
100
100
  *
101
101
  * **Example:**
102
102
  * ```md
103
- * <!-- doc-gen REMOTE url=http://url-to-raw-md-file.md -->
103
+ * <!-- docs REMOTE url=http://url-to-raw-md-file.md -->
104
104
  * This content will be dynamically replaced from the remote url
105
- * <!-- end-doc-gen -->
105
+ * <!-- /docs -->
106
106
  * ```
107
107
  *
108
- * Default `matchWord` is `doc-gen`
108
+ * Default `matchWord` is `docs`
109
109
  *
110
110
  * ---
111
111
  * @param {string} content The current content of the comment block
@@ -128,9 +128,9 @@ const transforms = {
128
128
  *
129
129
  * **Example:**
130
130
  * ```md
131
- * <!-- doc-gen fileTree src="./src" maxDepth=2 -->
131
+ * <!-- docs fileTree src="./src" maxDepth=2 -->
132
132
  * file tree will be generated here
133
- * <!-- end-doc-gen -->
133
+ * <!-- /docs -->
134
134
  * ```
135
135
  *
136
136
  * **Example Output (tree format):**
@@ -172,7 +172,7 @@ const transforms = {
172
172
  * └── package.json (552 B)
173
173
  * ```
174
174
  *
175
- * Default `matchWord` is `doc-gen`
175
+ * Default `matchWord` is `docs`
176
176
  *
177
177
  * ---
178
178
  * @param {string} content The current content of the comment block
@@ -193,12 +193,12 @@ const transforms = {
193
193
  *
194
194
  * **Example:**
195
195
  * ```md
196
- * <!-- doc-gen install -->
196
+ * <!-- docs install -->
197
197
  * Installation instructions will be generated here
198
- * <!-- end-doc-gen -->
198
+ * <!-- /docs -->
199
199
  * ```
200
200
  *
201
- * Default `matchWord` is `doc-gen`
201
+ * Default `matchWord` is `docs`
202
202
  *
203
203
  * ---
204
204
  * @param {string} content The current content of the comment block
@@ -11,12 +11,12 @@ const path = require('path')
11
11
  *
12
12
  * **Example:**
13
13
  * ```md
14
- * <!-- doc-gen INSTALL packageName=my-package -->
14
+ * <!-- docs INSTALL packageName=my-package -->
15
15
  * Installation instructions will be generated here
16
- * <!-- end-doc-gen -->
16
+ * <!-- /docs -->
17
17
  * ```
18
18
  *
19
- * Default `matchWord` is `doc-gen`
19
+ * Default `matchWord` is `docs`
20
20
  *
21
21
  * ---
22
22
  * @param {string} content The current content of the comment block
@@ -5,15 +5,15 @@ const { readFile } = require('../utils/fs')
5
5
  const details = require('../utils/details')
6
6
 
7
7
  module.exports = async function sectionToc(api) {
8
- const { options, currentFileContent, originalFileContent, srcPath, getBlockDetails } = api
8
+ const { options, currentContent, originalContent, srcPath, getBlockDetails } = api
9
9
  const opts = options || {}
10
10
  let { collapseText, collapse } = opts
11
11
  /* Sub table of contents */
12
- const originalBlock = getBlockDetails(originalFileContent)
13
- const closestHeading = findClosestParentHeading(originalFileContent, originalBlock.block.start)
12
+ const originalBlock = getBlockDetails(originalContent)
13
+ const closestHeading = findClosestParentHeading(originalContent, originalBlock.block.start)
14
14
  // console.log('closestHeading', closestHeading)
15
15
 
16
- const subToc = await generateToc(currentFileContent, {
16
+ const subToc = await generateToc(currentContent, {
17
17
  ...opts,
18
18
  normalizeLevels: true,
19
19
  // Set sub table of contents
@@ -11,15 +11,15 @@ const sectionToc = require('./sectionToc')
11
11
  * @property {number} [maxDepth=4] - Maximum depth of headings to include in the table of contents. Default is `4`.
12
12
  * @example
13
13
  ```md
14
- <!-- doc-gen (TOC) -->
14
+ <!-- docs (TOC) -->
15
15
  toc will be generated here
16
- <!-- end-doc-gen -->
17
- ```
16
+ <!-- /docs -->
17
+ ```
18
18
  */
19
19
 
20
20
  module.exports = async function TOC(api) {
21
21
  // console.log("TOC API", api)
22
- const { currentFileContent, srcPath, getBlockDetails } = api
22
+ const { currentContent, srcPath, getBlockDetails } = api
23
23
  /** @type {ToCTransformOptions} */
24
24
  const options = api.options || {}
25
25
  // console.log("TOC OPTIONS", options)
@@ -34,7 +34,7 @@ module.exports = async function TOC(api) {
34
34
  }
35
35
 
36
36
  opts.firsth1 = (opts.firsth1 || opts.firstH1) ? true : false
37
- let contents = currentFileContent
37
+ let contents = currentContent
38
38
  // console.log('contents', contents)
39
39
 
40
40
  let collapseText = opts.collapseText
@@ -1,5 +1,6 @@
1
1
  const { getWordCount } = require('../utils/text')
2
2
 
3
- module.exports = function wordCount({ currentFileContent }) {
4
- return getWordCount(currentFileContent)
3
+ module.exports = function wordCount(api) {
4
+ const { currentContent } = api
5
+ return getWordCount(currentContent)
5
6
  }