|
1 | | -const { transform } = require('@technote-space/doctoc') |
| 1 | +const { generateToc : generateTocUtils } = require('@davidwells/md-utils') |
2 | 2 | const { removeLeadingAndTrailingLineBreaks, escapeRegexString } = require('./regex') |
3 | 3 | const { findMinIndent } = require('./text') |
4 | 4 | const { readFile } = require('./fs') |
@@ -75,8 +75,11 @@ async function generateToc({ |
75 | 75 | // separator: '<span>|</span>', |
76 | 76 | // footer: 'end', |
77 | 77 | } |
78 | | - const t = await transform(contents, tocOptions) |
79 | | - let outputText = t.wrappedToc || '' |
| 78 | + |
| 79 | + const tocObject = generateTocUtils(contents) |
| 80 | + |
| 81 | + // let outputText = t.wrappedToc || '' |
| 82 | + let outputText = tocObject.text || '' |
80 | 83 |
|
81 | 84 | if (debugFileMatch) { |
82 | 85 | console.log('before firsth1 removal', outputText) |
@@ -247,7 +250,9 @@ async function generateToc({ |
247 | 250 | // console.log('single', single) |
248 | 251 | const subItems = outputText.match(findSubToc) |
249 | 252 | if (subItems) { |
250 | | - const items = subItems[0].replace(single, '').split('\n') |
| 253 | + const items = subItems[0] |
| 254 | + .replace(single, '') |
| 255 | + .split('\n') |
251 | 256 | .filter(Boolean) |
252 | 257 | // console.log('items', items) |
253 | 258 | const finalItems = items // .slice(1, items.length) |
@@ -277,7 +282,6 @@ ${outputText |
277 | 282 |
|
278 | 283 | </details>` |
279 | 284 | } |
280 | | - |
281 | 285 | return outputText.replace(removeLeadingAndTrailingLineBreaks, '') |
282 | 286 | } |
283 | 287 |
|
|
0 commit comments