MCPcopy
hub / github.com/colinhacks/zod / stripMdxComments

Function stripMdxComments

packages/docs/content/api.test.ts:100–121  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

98}
99
100function 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
123function stripMdxCommentSegments(line: string, state: { inComment: boolean }): string {
124 let result = "";

Callers 1

extractTabsBlocksFunction · 0.85

Calls 2

stripMdxCommentSegmentsFunction · 0.85
startsWithMethod · 0.65

Tested by

no test coverage detected