diff --git a/src/parse.ts b/src/parse.ts index 984cc28..5aa0f2b 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -66,8 +66,8 @@ function notesText(): string { ); } -function parseAliases(): Map { - const questLogAliases: RegExpExecArray[] = notesText() +function parseAliases(notes: string): Map { + const questLogAliases: RegExpExecArray[] = notes .split("\n") .map((s) => /^keeping-tabs: ?([A-Za-z0-9\- ]+)=(.*)/g.exec(s)) .filter((r) => r !== null) as RegExpExecArray[]; @@ -76,8 +76,8 @@ function parseAliases(): Map { return new Map(values); } -function parseCollections(): Map { - const questLogEntries = notesText() +function parseCollections(notes: string): Map { + const questLogEntries = notes .split("\n") .map((s) => /^keeping-tabs-collection: ?'([^']*)'=(.*)\s*/g.exec(s)) .filter((r) => r !== null && r.length > 1) as RegExpMatchArray[]; @@ -89,8 +89,8 @@ function parseCollections(): Map { return new Map(values); } -function parseCoinmasters(): Map { - const questLogEntries: RegExpExecArray[] = notesText() +function parseCoinmasters(notes: string): Map { + const questLogEntries: RegExpExecArray[] = notes .split("\n") .map((s) => /^keeping-tabs-coinmaster: ?([0-9]+)=([0-9]+)/g.exec(s)) .filter((r) => r !== null) as RegExpExecArray[]; @@ -120,9 +120,10 @@ export function parseNotes(): { collections: Map; coinmasters: Map; } { + const notes = notesText(); return { - aliases: parseAliases(), - collections: parseCollections(), - coinmasters: parseCoinmasters(), + aliases: parseAliases(notes), + collections: parseCollections(notes), + coinmasters: parseCoinmasters(notes), }; }