Skip to content

Commit 72ac6c5

Browse files
committed
feat: added reference for markdown problems - enhance term handling and improve markdown parsing; remove unused module template files
1 parent 1dc3c76 commit 72ac6c5

10 files changed

Lines changed: 39 additions & 143 deletions

File tree

src/Quizzer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,16 @@ class Quizzer {
489489
}
490490

491491
const isOfflineMessage = Settings?.online ? "" : `|${chalk.hex(CONSTANTS.CUTEYELLOW).inverse(' offline ')}`
492+
// console.log(term_selected);
493+
// console.trace()
494+
if (term_selected?.reference_page ?? false) {
495+
if ((term_selected?.reference_line ?? false) && term_selected.reference_line > 0) {
496+
console.log(`${term_selected?.reference_page}#${term_selected?.reference_line}`);
497+
} else {
498+
console.log(`${term_selected?.reference_page}`);
499+
500+
}
501+
}
492502
console.log(`${chalk.hex(CONSTANTS.CUTEBLUE).inverse(` ${term_selected.term} `)}|${chalk.hex(CONSTANTS.PUNCHPINK).inverse(` ${term_selected.category} `)}${isOfflineMessage}`);
493503

494504
if (term_selected?.attachment ?? false) {
@@ -512,7 +522,6 @@ class Quizzer {
512522
// Check for escape methods
513523

514524
if (user_requests_calc(user_res)) {
515-
const { exec } = require('child_process');
516525
openEditorPlatformAgnostic('node')
517526
// Make the user lose one point for using the calculator.
518527
return false;

src/constants.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,18 @@ const getRandomBool = (chances = 0.5) => {
125125
}
126126

127127
function populateTerms(termJson) {
128-
return termJson.map(obj => new Term(obj?.term ?? "", obj?.example ?? "", obj?.description ?? "", obj?.prompt ?? "", obj?.references ?? "", obj?.category ?? "", obj?.attachment));
128+
return termJson.map(obj => new Term(obj?.term ?? "", obj?.example ?? "",
129+
obj?.description ?? "", obj?.prompt ?? "",
130+
{
131+
references: obj?.references ?? "",
132+
category: obj?.category ?? "", attachment: obj?.attachment,
133+
reference_line: obj?.reference_line ?? -1,
134+
reference_page: obj?.reference_page ?? "",
135+
module_name: obj?.module_name ?? "",
136+
priority: obj?.priority ?? 5,
137+
auto_newline: obj?.auto_newline ?? true
138+
139+
}));
129140
}
130141

131142
const terms = populateTerms(termJson);

src/md_terms_parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function parseMarkdownIntoDeck(filePath, { module_name = 'Markdown Terms Parser'
142142
if (category === "") {
143143
category = module_name;
144144
}
145-
145+
console.log(`Parsing terms from ${filePath}#23 in category: ${category}`);
146146
for (const entry of parsedData.entries) {
147147
const term = new Term(
148148
entry.header,
@@ -155,6 +155,7 @@ function parseMarkdownIntoDeck(filePath, { module_name = 'Markdown Terms Parser'
155155
module_name: module_name,
156156
category: category
157157
});
158+
// console.log("created new terms", term);
158159
termsList.push(term);
159160
}
160161

src/structures.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class Term {
3838
this.reference_line = reference_line;
3939
this.module_name = module_name;
4040

41+
// if(term=="definition2"){
42+
// console.log("Term is definition2, this is a bug, please report it.");
43+
// console.trace();
44+
// console.log("Term: ", this);
45+
// }
46+
4147
}
4248

4349
/**
@@ -95,8 +101,8 @@ class TermStorage {
95101
* @param {List[TermStorage]} decks The decks required for the Storages
96102
* @param {boolean} is_active If the deck is active or not; by default is false
97103
*/
98-
constructor(terms = [], deck_name = "",
99-
{ decks = [], is_active = false, module_name="" } = {}) {
104+
constructor(terms = [], deck_name = "",
105+
{ decks = [], is_active = false, module_name = "" } = {}) {
100106
this.terms = terms;
101107
this.deck_name = deck_name;
102108
this.is_active = is_active;
@@ -223,8 +229,13 @@ class TermStorage {
223229
const newterm = new Term(
224230
obj?.term ?? "", obj?.example ?? "", obj?.description ?? "", obj?.prompt ?? "",
225231
{
226-
references: obj?.references ?? "", attachment: obj?.attachment,
227-
priority: this.priority
232+
references: obj?.references ?? "",
233+
category: obj?.category ?? "", attachment: obj?.attachment,
234+
reference_line: obj?.reference_line ?? -1,
235+
reference_page: obj?.reference_page ?? "",
236+
module_name: obj?.module_name ?? "",
237+
priority: this.priority ?? 5,
238+
auto_newline: obj?.auto_newline ?? true
228239
}
229240
)
230241
newterm.pushCategory(this.deck_name ?? "");
-1.78 MB
Binary file not shown.

src/terms_data/module_template/index.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/terms_data/module_template/note_1.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/terms_data/module_template/note_2.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/terms_data/module_template/note_3.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/terms_data/module_template/readme.md

Whitespace-only changes.

0 commit comments

Comments
 (0)