-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 19 additions & 16 deletions
35
renderer/src/components/EditorPage/Reference/OBS/ObsTsvToChapterLevel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
// filter current chapter data from whole TSV JSON and generate array of notes of md content | ||
// based on reference of tsv | ||
import * as logger from '../../../../logger'; | ||
|
||
export default async function ObsTsvToChapterLevelMd(tsvJSON, chapter) { | ||
return new Promise((resolve) => { | ||
logger.debug('in ObsTsvToChapterLevel.js : in promise'); | ||
const filteredData = tsvJSON.filter((data) => data.Reference.split(':')[0].toString() === chapter.toString()); | ||
const chapterTsvData = []; | ||
const notesObj = {}; | ||
filteredData.forEach((tsvObj) => { | ||
let mdstring = ''; | ||
mdstring += `# ${ tsvObj.Quote }\n\n${ tsvObj.Note }\n`; | ||
if (tsvObj.Reference.split(':')[1] in notesObj) { | ||
notesObj[tsvObj.Reference.split(':')[1]].OccurrenceNote += mdstring; | ||
} else { | ||
notesObj[tsvObj.Reference.split(':')[1]] = { OccurrenceNote: mdstring }; | ||
const chapterTsvData = []; | ||
const notesObj = {}; | ||
filteredData.forEach((tsvObj) => { | ||
let mdstring = ''; | ||
mdstring += `# ${ tsvObj.Quote }\n\n${ tsvObj.Note }\n`; | ||
if (tsvObj.Reference.split(':')[1] in notesObj) { | ||
notesObj[tsvObj.Reference.split(':')[1]].OccurrenceNote += mdstring; | ||
} else { | ||
notesObj[tsvObj.Reference.split(':')[1]] = { OccurrenceNote: mdstring }; | ||
} | ||
}); | ||
Object.values(notesObj).forEach((value) => { | ||
chapterTsvData.push(value); | ||
}); | ||
if (chapterTsvData?.length > 0) { | ||
logger.debug('in ObsTsvToChapterLevel.js : finished tsv md array resolved'); | ||
resolve(chapterTsvData); | ||
} | ||
}); | ||
Object.values(notesObj).forEach((value) => { | ||
chapterTsvData.push(value); | ||
}); | ||
if (chapterTsvData?.length > 0) { | ||
resolve(chapterTsvData); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters