Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV]: Option to send developer logging to file instead of console.log #1042

Draft
wants to merge 118 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
0b5f775
Initial fix, added much debug output
ronzulu Dec 29, 2023
1887bbc
Removed debug code
ronzulu Dec 30, 2023
1ea94ea
Reverted some variable name changes etc
ronzulu Dec 30, 2023
00b53b9
Fixed incorrect condition identified by https://github.com/karimodm
ronzulu Jan 1, 2024
4ada044
Merge remote-tracking branch 'upstream/master' into bug-424-auto-revi…
ronzulu Jan 2, 2024
b17c300
Updated change log, npx prettier
ronzulu Jan 2, 2024
0a5847a
Updated code and language files
ronzulu Jan 12, 2024
92b6cef
pnpm format & lint
ronzulu Jan 12, 2024
3dec603
Partial implementation
ronzulu Jan 14, 2024
36b8531
Merge remote-tracking branch 'upstream/master' into bug-424-auto-revi…
ronzulu Jan 15, 2024
3134bba
Merge branch 'bug-670-label-customisation'
ronzulu Jan 15, 2024
027f82a
Progressed implementation
ronzulu Jan 17, 2024
235c9cf
Alternative to needing the "Advanced" tab
ronzulu Jan 18, 2024
96e6d2a
Perhaps half way towards implementation; doesn't build yet
ronzulu Feb 19, 2024
14cc9c8
Implemented 70%; doesn't build
ronzulu Feb 21, 2024
4c14127
Progress
ronzulu Feb 21, 2024
614c4f2
Progress
ronzulu Feb 22, 2024
f40967f
Progress
ronzulu Feb 22, 2024
2db8cf0
11 of the 19 existing test suites pass
ronzulu Feb 23, 2024
10d55a0
12 of the 19 existing test suites pass
ronzulu Feb 23, 2024
1242a29
14 of the 19 existing test suites pass
ronzulu Feb 24, 2024
a54ffaf
Progress
ronzulu Feb 24, 2024
335ba58
15 of the 19 existing test suites pass
ronzulu Feb 24, 2024
8977647
All nineteen existing test suites pass
ronzulu Feb 25, 2024
4be2553
Minor fixes
ronzulu Feb 28, 2024
381d119
More refactoring; doesn't build
ronzulu Feb 28, 2024
778985e
Progress, doesn't build
ronzulu Feb 29, 2024
4b8540c
Builds and all existing unit tests pass
ronzulu Feb 29, 2024
f181a7b
Progress
ronzulu Mar 3, 2024
b6bd619
Merge remote-tracking branch 'upstream/master'
ronzulu Mar 10, 2024
6aff45a
Merge remote-tracking branch 'upstream/master' into feat-878-support-…
ronzulu Mar 11, 2024
5f85b46
Merge remote-tracking branch 'upstream/master'; due to conflicts fair…
ronzulu Mar 11, 2024
37f7085
Merge remote-tracking branch 'upstream/master' into feat-878-support-…
ronzulu Mar 11, 2024
a914204
Merge remote-tracking branch 'upstream/master'
ronzulu Mar 11, 2024
ccf0b67
Continued fixing post #495 integration
ronzulu Mar 12, 2024
3a86db9
Added some test cases for OsrCore
ronzulu Mar 13, 2024
447fcc1
Added unit test support code
ronzulu Mar 16, 2024
3bf2034
Added more test files
ronzulu Mar 20, 2024
dab4e1e
Merge remote-tracking branch 'upstream/master'
ronzulu Mar 22, 2024
41f0a78
Merge remote-tracking branch 'upstream/master'
ronzulu Mar 28, 2024
61c52f9
Added test case, fixed code issues
ronzulu May 2, 2024
abfe2b3
Updated tests
ronzulu May 8, 2024
f104cee
Small refactor
ronzulu May 8, 2024
ca85290
!!GitHub_Desktop<feat-878-support-multiple-schedule-methods>
ronzulu May 8, 2024
ce1640c
Fixes post merge stash
ronzulu May 8, 2024
8d7d9c1
Added tests
ronzulu May 9, 2024
8e1c20b
More refactoring
ronzulu May 20, 2024
a2fa8d1
Improved test coverage
ronzulu May 21, 2024
d2d9c5e
Improved unit test code coverage
ronzulu May 22, 2024
4e80ed5
Use obsidians funtion to extractFrontmatter
4Source May 23, 2024
d825c31
Fix line pos shift
4Source May 23, 2024
d71c7ae
Merge branch 'st3v3nmw:master' into bug_967
4Source May 24, 2024
8d79dcd
Stop using obsidian function because of UnitTest
4Source May 24, 2024
0b4ac9e
Add UnitTest for Frontmatter and Horizontal line
4Source May 24, 2024
0d27150
Fix linting
4Source May 24, 2024
6487b49
Starting testing of plugin within Obsidian
ronzulu Jun 1, 2024
2a571c7
Bug fixes
ronzulu Jun 1, 2024
27fbc55
add translation: zh-cn
artefaritaKuniklo Jun 4, 2024
07d8a2d
FEAT-990 Mobile landscape mode and functional size sliders
annappropriate Jun 16, 2024
d162d56
Merge remote-tracking branch 'upstream/master' into feat-839-split-op…
ronzulu Jun 20, 2024
81a9494
Fixed broken test cases
ronzulu Jun 22, 2024
b4e6a4c
Added test case for global coverage
ronzulu Jun 22, 2024
6503dc9
fix #1000 sidebar indent
Newdea Jun 22, 2024
3e8ee76
Merge remote-tracking branch 'upstream/master' into feat-878-support-…
ronzulu Jun 23, 2024
9adfecc
A few merge fixes
ronzulu Jun 23, 2024
9d1c298
Version ready for beta testing
ronzulu Jun 25, 2024
66ec28b
Format and lint
ronzulu Jun 25, 2024
aeef00e
Updated actions/checkout@v3 to node 20
ronzulu Jun 25, 2024
e75c4b6
Lets make lint happy!
ronzulu Jun 25, 2024
05c0806
Previously the pnpm format added a blank line in a test markdown file…
ronzulu Jun 25, 2024
237209f
Slightly reduced jest code coverage threshold to writing a number of …
ronzulu Jun 26, 2024
ec9b4af
Merge remote-tracking branch 'upstream/master'
ronzulu Jun 27, 2024
0f7e21a
Create manifest-beta.json
ronzulu Jun 27, 2024
247104e
Node version 20
ronzulu Jun 27, 2024
e2727b8
Release
ronzulu Jun 27, 2024
51ae4e8
Update
ronzulu Jun 28, 2024
cc51c7d
Update
ronzulu Jul 1, 2024
2a6fc62
Update
ronzulu Jul 1, 2024
20ee92d
Update
ronzulu Jul 1, 2024
0b54b70
Update
ronzulu Jul 1, 2024
00e6c47
Update
ronzulu Jul 1, 2024
28963a8
Update
ronzulu Jul 1, 2024
57a4656
Squashed commit of the following:
ronzulu Jul 1, 2024
f3f6819
Merged #335
ronzulu Jul 1, 2024
ed061a1
Merge remote-tracking branch 'osrr/fix/sidebarIndent'
ronzulu Jul 3, 2024
8ceb3da
Update
ronzulu Jul 3, 2024
712ec01
Update
ronzulu Jul 3, 2024
2497bb6
Merge remote-tracking branch 'artefaritaKuniklo/master' https://githu…
ronzulu Jul 3, 2024
6296a75
Merge remote-tracking branch 'annappropriate/feat-990-mobile-css-full…
ronzulu Jul 3, 2024
15f5fb7
Update
ronzulu Jul 3, 2024
8d3310f
Merge branch 'feat-878-support-multiple-schedule-methods' https://git…
ronzulu Jul 4, 2024
e1d7066
Fixed bug where note frontmatter interval/ease set to null (app speci…
ronzulu Jul 4, 2024
4371e4a
Merge branch 'feat-878-support-multiple-schedule-methods' (post bug fix)
ronzulu Jul 4, 2024
c533ea7
Merge remote-tracking branch '4source/bug_967'
ronzulu Jul 4, 2024
ef42f50
Squashed commit of the following:
ronzulu Jul 4, 2024
c424225
Update changelog.md
ronzulu Jul 4, 2024
0f50c66
Fixed some note review queue bugs (previously introduced in branch #878)
ronzulu Jul 9, 2024
ed2c831
Merge branch 'feat-878-support-multiple-schedule-methods'
ronzulu Jul 9, 2024
22e8ca1
(1) Squashed commit of the following: https://github.com/st3v3nmw/obs…
ronzulu Jul 10, 2024
c3bc74b
Minor fix
ronzulu Jul 10, 2024
438365b
[FIX] Folder ignore sorts all folder starting with string
ronzulu Jul 16, 2024
938bd97
Fixed bug preventing card stats being shown (previously introduced in…
ronzulu Jul 16, 2024
a770393
[FIX] Not scroll back to top after review
ronzulu Jul 16, 2024
f6bb04f
Version number
ronzulu Jul 16, 2024
965c394
Added missing css
ronzulu Jul 19, 2024
82b94e0
Squashed commit of the following: https://github.com/st3v3nmw/obsidia…
ronzulu Jul 19, 2024
d056c0d
Updated messages for non-English languages
ronzulu Jul 19, 2024
c0119b1
Format & lint
ronzulu Jul 19, 2024
0bc337e
Merge branch 'feat-839-split-options-into-tabs' (format & lint)
ronzulu Jul 19, 2024
70b06c3
changelog update
ronzulu Jul 19, 2024
d56c41f
changelog.md
ronzulu Jul 19, 2024
cdb8abe
Merge branch 'feat-839-split-options-into-tabs' (change log)
ronzulu Jul 19, 2024
fd2e75d
Implementation
ronzulu Aug 5, 2024
26934d1
Added new text to non-English resources
ronzulu Aug 5, 2024
36ca05d
Format & lint
ronzulu Aug 5, 2024
56ac26a
Update error handling for sync()
ronzulu Aug 6, 2024
eabdc3c
path.dirname not present on some mobiles
ronzulu Aug 6, 2024
dd14089
Minor
ronzulu Aug 6, 2024
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
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Fix/sidebarIndent https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1001
- FEAT-990 Mobile landscape mode + fully functional resize sliders https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/998
- Feat 878 Refactor code to support diff methods of storing the scheduling info, and diff SR algorithms https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1006
- [FIX] Cards missing when horizontal rule present in document https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/970

#### [1.12.4](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.3...1.12.4)

Expand Down
4 changes: 2 additions & 2 deletions src/NoteQuestionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class NoteQuestionParser {
noteText: string;
frontmatterText: string;

// This is the note text, but with the frontmatter blanked out (see extractFrontmatter for reasoning)
// This is the note text, but with the frontmatter blanked out (see splitNoteIntoFrontmatterAndContent for reasoning)
contentText: string;
noteLines: string[];

Expand Down Expand Up @@ -139,7 +139,7 @@ export class NoteQuestionParser {
}

private parseQuestions(): ParsedQuestionInfo[] {
// We pass contentText which has the frontmatter blanked out; see extractFrontmatter for reasoning
// We pass contentText which has the frontmatter blanked out; see splitNoteIntoFrontmatterAndContent for reasoning
const settings: SRSettings = this.settings;
const result: ParsedQuestionInfo[] = parseEx(
this.contentText,
Expand Down
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ParsedQuestionInfo {
/**
* Returns flashcards found in `text`
*
* It is best that the text does not contain frontmatter, see extractFrontmatter for reasoning
* It is best that the text does not contain frontmatter, see splitNoteIntoFrontmatterAndContent for reasoning
*
* Multi-line question with blank lines user workaround:
* As of 3/04/2024 there is no support for including blank lines within multi-line questions
Expand Down
70 changes: 34 additions & 36 deletions src/util/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from "moment";
import { Moment } from "moment";
import { PREFERRED_DATE_FORMAT, YAML_FRONT_MATTER_REGEX } from "src/constants";
import { PREFERRED_DATE_FORMAT } from "src/constants";

type Hex = number;

Expand Down Expand Up @@ -105,45 +105,43 @@ export function convertToStringOrEmpty(v: any): string {
return result;
}

//
// This returns [frontmatter, content]
//
// The returned content has the same number of lines as the supplied str string, but with the
// frontmatter lines (if present) blanked out.
//
// 1. We don't want the parser to see the frontmatter, as it would deem it to be part of a multi-line question
// if one started on the line immediately after the "---" closing marker.
//
// 2. The lines are blanked out rather than deleted so that line numbers are not affected
// e.g. for calls to getQuestionContext(cardLine: number)
//
/**
* The returned content has the same number of lines as the supplied string, but with the frontmatter lines (if present) blanked out.
*
* 1. We don't want the parser to see the frontmatter, as it would deem it to be part of a multi-line question if one started on the line immediately after the "---" closing marker.
*
* 2. The lines are blanked out rather than deleted so that line numbers are not affected e.g. for calls to getQuestionContext(cardLine: number)
*
* @param str The file content as string
* @returns [frontmatter, content]
*/
export function splitNoteIntoFrontmatterAndContent(str: string): [string, string] {
let frontmatter: string = "";
let content: string = "";
let frontmatterEndLineNum: number = null;
if (YAML_FRONT_MATTER_REGEX.test) {
const lines: string[] = splitTextIntoLineArray(str);

// The end "---" marker must be on the third line (index 2) or later
for (let i = 2; i < lines.length; i++) {
if (lines[i] == "---") {
frontmatterEndLineNum = i;
break;
}
const lines = splitTextIntoLineArray(str);
let lineIndex = 0;
let hasFrontmatter = false;
do {
// Starts file with '---'
if (lineIndex === 0 && lines[lineIndex] === "---") {
hasFrontmatter = true;
}

if (frontmatterEndLineNum) {
const frontmatterStartLineNum: number = 0;
const frontmatterLines: string[] = [];
for (let i = frontmatterStartLineNum; i <= frontmatterEndLineNum; i++) {
frontmatterLines.push(lines[i]);
lines[i] = "";
}
frontmatter = frontmatterLines.join("\n");
content = lines.join("\n");
// Line is end of front matter
else if (hasFrontmatter && lines[lineIndex] === "---") {
hasFrontmatter = false;
lineIndex++;
}
if (hasFrontmatter) {
lineIndex++;
}
} while (hasFrontmatter && lineIndex < lines.length);
// No end of Frontmatter found
if (hasFrontmatter) {
lineIndex = 0;
}
if (frontmatter.length == 0) content = str;

const frontmatter: string = lines.slice(0, lineIndex).join("\n");
const emptyLines: string[] = lineIndex > 0 ? Array(lineIndex).join(".").split(".") : [];
const content: string = emptyLines.concat(lines.slice(lineIndex)).join("\n");

return [frontmatter, content];
}

Expand Down
170 changes: 170 additions & 0 deletions tests/unit/util/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,176 @@ ${content}`;
${content}`;
expect(c).toEqual(expectedContent);
});

test("With frontmatter and content (Horizontal line)", () => {
const frontmatter: string = `---
sr-due: 2024-01-17
sr-interval: 16
sr-ease: 278
tags:
- flashcards/aws
- flashcards/datascience
---`;
const frontmatterBlankedOut: string = `






`;
const content: string = `#flashcards/science/chemistry


---
# Questions
---


Chemistry Question from file underelephant 4A::goodby

<!--SR:!2023-11-02,17,290-->

Chemistry Question from file underdog 4B::goodby

<!--SR:!2023-12-18,57,310-->

---

Chemistry Question from file underdog 4C::goodby

<!--SR:!2023-10-25,3,210-->

This single {{question}} turns into {{3 separate}} {{cards}}

<!--SR:!2023-10-20,1,241!2023-10-25,3,254!2023-10-23,1,221-->

---`;

const text: string = `${frontmatter}
${content}`;
const expectedContent: string = `${frontmatterBlankedOut}
${content}`;

const [f, c] = splitNoteIntoFrontmatterAndContent(text);
expect(f).toEqual(frontmatter);
expect(c).toEqual(expectedContent);
});

test("With frontmatter and content (Horizontal line newLine)", () => {
const frontmatter: string = `---
sr-due: 2024-01-17
sr-interval: 16
sr-ease: 278
tags:
- flashcards/aws
- flashcards/datascience
---`;
const frontmatterBlankedOut: string = `






`;
const content: string = `#flashcards/science/chemistry


---
# Questions
---


Chemistry Question from file underelephant 4A::goodby

<!--SR:!2023-11-02,17,290-->

Chemistry Question from file underdog 4B::goodby

<!--SR:!2023-12-18,57,310-->

---

Chemistry Question from file underdog 4C::goodby

<!--SR:!2023-10-25,3,210-->

This single {{question}} turns into {{3 separate}} {{cards}}

<!--SR:!2023-10-20,1,241!2023-10-25,3,254!2023-10-23,1,221-->

---
`;

const text: string = `${frontmatter}
${content}`;
const expectedContent: string = `${frontmatterBlankedOut}
${content}`;

const [f, c] = splitNoteIntoFrontmatterAndContent(text);
expect(f).toEqual(frontmatter);
expect(c).toEqual(expectedContent);
});

test("With frontmatter and content (Horizontal line codeblock)", () => {
const frontmatter: string = `---
sr-due: 2024-01-17
sr-interval: 16
sr-ease: 278
tags:
- flashcards/aws
- flashcards/datascience
---`;
const frontmatterBlankedOut: string = `






`;
const content: string = [
"```",
"---",
"```",
"#flashcards/science/chemistry",
"# Questions",
" ",
"",
"Chemistry Question from file underelephant 4A::goodby",
"",
"<!--SR:!2023-11-02,17,290-->",
"",
"Chemistry Question from file underdog 4B::goodby",
"",
"<!--SR:!2023-12-18,57,310-->",
"```",
"---",
"```",
"",
"Chemistry Question from file underdog 4C::goodby",
"",
"<!--SR:!2023-10-25,3,210-->",
"",
"This single {{question}} turns into {{3 separate}} {{cards}}",
"",
"<!--SR:!2023-10-20,1,241!2023-10-25,3,254!2023-10-23,1,221-->",
"",
"```",
"---",
"```",
].join("\n");

const text: string = `${frontmatter}
${content}`;
const expectedContent: string = `${frontmatterBlankedOut}
${content}`;

const [f, c] = splitNoteIntoFrontmatterAndContent(text);
expect(f).toEqual(frontmatter);
expect(c).toEqual(expectedContent);
});
});

describe("findLineIndexOfSearchStringIgnoringWs", () => {
Expand Down