Skip to content

Commit

Permalink
fix: bring back support for Toggle headings
Browse files Browse the repository at this point in the history
  • Loading branch information
aalemayhu committed Oct 30, 2024
1 parent 1a8c8bf commit 313bbec
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/parser/DeckParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class DeckParser {
}

findIndentedToggleLists(dom: cheerio.Root): cheerio.Element[] {
const selector = '.page-body';
const selector = '.page-body > details';
return dom(selector).toArray();
}

Expand Down Expand Up @@ -570,9 +570,7 @@ export class DeckParser {
private extractToggleLists(dom: cheerio.Root) {
const foundToggleLists = this.findToggleLists(dom);

return foundToggleLists.length > 0
? foundToggleLists
: this.findIndentedToggleLists(dom);
return [...foundToggleLists, ...this.findIndentedToggleLists(dom)];
}

private extractCards(dom: cheerio.Root, toggleList: cheerio.Element[]) {
Expand All @@ -597,7 +595,11 @@ export class DeckParser {
dom('details').addClass(parentClass);
dom('summary').addClass(parentClass);
const summary = parentUL.find('summary').first();
const toggle = parentUL.find('details').first();
let toggle = parentUL.find('details').first();

if (!toggle?.html()) {
toggle = parentUL.find('.indented');
}

if (summary && summary.text()) {
const validSummary = (() =>
Expand Down

0 comments on commit 313bbec

Please sign in to comment.