Skip to content

Commit

Permalink
fix(docs): fix fix-markdown logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ZL-Asica committed Nov 20, 2024
1 parent a20b67c commit 6a1a76b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions fix-markdown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,31 @@ function fixMarkdown(filePath) {
const newContent = lines.slice(6);
const newLines = [];

let skipCurrentLine = false;
let skipProcessing = false;

for (let line of newContent) {
if (skipProcessing) {
newLines.push(line);
continue;
}

if (line.startsWith('## Index') || line.startsWith('### Functions')) {
skipCurrentLine = true;
continue;
} else if (line.startsWith('## Modules')) {
line = line.replace('## Modules', '# Documentation');
skipCurrentLine = false;
} else if (line.startsWith('# Function:')) {
line = line.replace('# Function:', '#');
skipCurrentLine = false;
} else {
skipCurrentLine = false;
}

if (!skipCurrentLine) {
line = line
.replaceAll(/README.md/g, '')
.replaceAll(/<([A-Za-z]+)>/g, '&lt;$1&gt;');
} else if (line.startsWith('## Example')) {
skipProcessing = true;
newLines.push(line);
continue;
}

line = line
.replaceAll(/README.md/g, '')
.replaceAll(/<([A-Za-z]+)>/g, '&lt;$1&gt;');

newLines.push(line);
}

const fixedContent = newLines.join('\n');
Expand Down

0 comments on commit 6a1a76b

Please sign in to comment.