(source: string)
| 51 | }); |
| 52 | |
| 53 | function extractTabsBlocks(source: string): TabsBlock[] { |
| 54 | const lines = stripMdxComments(source); |
| 55 | const blocks: TabsBlock[] = []; |
| 56 | |
| 57 | for (let index = 0; index < lines.length; index++) { |
| 58 | const line = lines[index]; |
| 59 | |
| 60 | if (!line || !/<Tabs\b/.test(line.text)) { |
| 61 | continue; |
| 62 | } |
| 63 | |
| 64 | const tabs: TabBlock[] = []; |
| 65 | let currentTab: TabBlock | undefined; |
| 66 | |
| 67 | for (index += 1; index < lines.length; index++) { |
| 68 | const blockLine = lines[index]; |
| 69 | |
| 70 | if (!blockLine || /<\/Tabs>/.test(blockLine.text)) { |
| 71 | break; |
| 72 | } |
| 73 | |
| 74 | const tabValue = getTabValue(blockLine.text); |
| 75 | |
| 76 | if (tabValue) { |
| 77 | currentTab = { value: tabValue, line: blockLine.number, codeFences: [] }; |
| 78 | tabs.push(currentTab); |
| 79 | continue; |
| 80 | } |
| 81 | |
| 82 | if (/<\/Tab>/.test(blockLine.text)) { |
| 83 | currentTab = undefined; |
| 84 | continue; |
| 85 | } |
| 86 | |
| 87 | if (currentTab && blockLine.text.trimStart().startsWith("```")) { |
| 88 | const codeFence = readCodeFence(lines, index, blockLine.number); |
| 89 | currentTab.codeFences.push(codeFence); |
| 90 | index += codeFence.lineCount + 1; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | blocks.push({ startLine: line.number, tabs }); |
| 95 | } |
| 96 | |
| 97 | return blocks; |
| 98 | } |
| 99 | |
| 100 | function stripMdxComments(source: string): SourceLine[] { |
| 101 | const lines = source.split(/\r?\n/); |
no test coverage detected