Skip to content

Commit

Permalink
Clean up loop logic (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Jul 8, 2024
1 parent 5379a2e commit e1132b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions atom_generator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ function generateAtom(path: string): string {
// process html
const html: string = Fs.readFileSync(path, { encoding: 'utf8' });

for (let endIdx = 0; endIdx >= 0; ) {
const startIdx = html.indexOf('<h3 ', endIdx);
endIdx = html.indexOf('<h3 ', (startIdx + 4));
for (let startIdx = html.indexOf('<h3 '); startIdx >= 0; ) {
const endIdx = html.indexOf('<h3 ', (startIdx + 4));
const postEndIdx = ((endIdx >= 0)
? endIdx
: html.indexOf('</div>', (startIdx + 4))); // don't include footer in the last post
const post = html.slice(startIdx, postEndIdx);
startIdx = endIdx;

// parse
const $ = Cheerio.load(post, undefined, false);
Expand Down

0 comments on commit e1132b5

Please sign in to comment.