Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions src/services/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ export class Parser {
: "";

const originalPrompt = match[2].trim();
let prompt = contextAware
? [...context, match[2].trim()].join(
`${this.settings.contextSeparator}`
)
: match[2].trim();

let promptContext = context.join(`${this.settings.contextSeparator}`)
let prompt = match[2].trim();

let medias: string[] = this.getImageLinks(prompt);
medias = medias.concat(this.getAudioLinks(prompt));
prompt = this.parseLine(prompt, vault);
Expand All @@ -172,7 +171,7 @@ export class Parser {
const tags: string[] = this.parseTags(match[4], globalTags);
const id: number = match[5] ? Number(match[5]) : -1;
const inserted: boolean = match[5] ? true : false;
const fields: any = { Prompt: prompt };
const fields: any = { Prompt: prompt, Context: promptContext };
if (this.settings.sourceSupport) {
fields["Source"] = note;
}
Expand Down Expand Up @@ -253,12 +252,10 @@ export class Parser {
}

const originalLine = match[2].trim();
// Add context
clozeText = contextAware
? [...context, clozeText.trim()].join(
`${this.settings.contextSeparator}`
)
: clozeText.trim();

let clozeContext = context.join(`${this.settings.contextSeparator}`)
clozeText = clozeText.trim();

let medias: string[] = this.getImageLinks(clozeText);
medias = medias.concat(this.getAudioLinks(clozeText));
clozeText = this.parseLine(clozeText, vault);
Expand All @@ -268,7 +265,7 @@ export class Parser {
const tags: string[] = this.parseTags(match[4], globalTags);
const id: number = match[5] ? Number(match[5]) : -1;
const inserted: boolean = match[5] ? true : false;
const fields: any = { Text: clozeText, Extra: "" };
const fields: any = { Text: clozeText, Extra: "", Context: clozeContext };
if (this.settings.sourceSupport) {
fields["Source"] = note;
}
Expand Down Expand Up @@ -325,11 +322,10 @@ export class Parser {
: "";

const originalQuestion = match[2].trim();
let question = contextAware
? [...context, match[2].trim()].join(
`${this.settings.contextSeparator}`
)
: match[2].trim();

let questionContext = context.join(`${this.settings.contextSeparator}`)
let question = match[2].trim();

let answer = match[4].trim();
let medias: string[] = this.getImageLinks(question);
medias = medias.concat(this.getImageLinks(answer));
Expand All @@ -342,7 +338,7 @@ export class Parser {
const tags: string[] = this.parseTags(match[5], globalTags);
const id: number = match[6] ? Number(match[6]) : -1;
const inserted: boolean = match[6] ? true : false;
const fields: any = { Front: question, Back: answer };
const fields: any = { Front: question, Back: answer, Context: questionContext };
if (this.settings.sourceSupport) {
fields["Source"] = note;
}
Expand Down Expand Up @@ -394,11 +390,10 @@ export class Parser {
: "";

const originalQuestion = match[2].trim();
let question = contextAware
? [...context, match[2].trim()].join(
`${this.settings.contextSeparator}`
)
: match[2].trim();

let questionContext = context.join(`${this.settings.contextSeparator}`)
let question = match[2].trim();

let answer = match[5].trim();
let medias: string[] = this.getImageLinks(question);
medias = medias.concat(this.getImageLinks(answer));
Expand All @@ -414,7 +409,7 @@ export class Parser {
const tags: string[] = this.parseTags(match[4], globalTags);
const id: number = match[6] ? Number(match[6]) : -1;
const inserted: boolean = match[6] ? true : false;
const fields: any = { Front: question, Back: answer };
const fields: any = { Front: question, Back: answer, Context: questionContext };
if (this.settings.sourceSupport) {
fields["Source"] = note;
}
Expand Down