(source: string)
| 98 | } |
| 99 | |
| 100 | function stripMdxComments(source: string): SourceLine[] { |
| 101 | const lines = source.split(/\r?\n/); |
| 102 | const sourceLines: SourceLine[] = []; |
| 103 | let inCodeFence = false; |
| 104 | const mdxCommentState = { inComment: false }; |
| 105 | |
| 106 | for (let index = 0; index < lines.length; index++) { |
| 107 | const line = lines[index] ?? ""; |
| 108 | const isFenceBoundary = line.trimStart().startsWith("```"); |
| 109 | |
| 110 | if (isFenceBoundary) { |
| 111 | inCodeFence = !inCodeFence; |
| 112 | } |
| 113 | |
| 114 | sourceLines.push({ |
| 115 | text: inCodeFence ? line : stripMdxCommentSegments(line, mdxCommentState), |
| 116 | number: index + 1, |
| 117 | }); |
| 118 | } |
| 119 | |
| 120 | return sourceLines; |
| 121 | } |
| 122 | |
| 123 | function stripMdxCommentSegments(line: string, state: { inComment: boolean }): string { |
| 124 | let result = ""; |
no test coverage detected