diff --git a/README.md b/README.md index 8e404ff..743a8d3 100644 --- a/README.md +++ b/README.md @@ -1,279 +1,283 @@ -# Day Planner (OG) -[![GitHub tag (Latest by date)](https://img.shields.io/github/v/tag/ebullient/obsidian-day-planner-og)](https://github.com/ebullient/obsidian-day-planner-og/releases) ![GitHub all releases](https://img.shields.io/github/downloads/ebullient/obsidian-day-planner-og/total?color=success) - -The Day Planner plugin is your pomodoro-like assistant for managing daily tasks in Obsidian. -Set specific blocks of time for various activities, and the plugin keeps track, offering you real-time updates, impending block-end notifications, and a visual gauge of your day's progress. -Not only does it help in planning, but it also actively marks off the blocks as the day progresses and highlights the current block, keeping you on track. - -This plugin is a fork of the early Obsidian Day Planner plugin written by [James Lynch](https://github.com/lynchjames). -The [Day Planner Plugin](https://github.com/ivan-lednev/obsidian-day-planner) has evolved with new features like drag-and-drop task creation and a weekly view. -This "OG" version holds onto the essence of the original. -In the interest of stability, I have disabled the Mermaid Gantt chart feature. -Reach out if you're interested in this feature, and we can work towards reintegrating it. - -## This plugin will change your notes - -The Day Planner plugin manages pomodoro timers from a task list in a Markdown note. - -> When day planner is associated with a note and "Complete past planner items" is enabled, Day planner will update the contents of that note. - -This may cause issues if you have the plugin (and that setting) enabled on multiple active devices with sync functionality (of any kind). To avoid this issue, I usually have Day Planner active only one device (e.g. my Desktop). That one device updates the time, and the sync utility handles forwarding and merging the updates to other devices. - -**Please try the plugin in a test vault first, and, most importantly, make sure you have your notes backed up in cloud storage or Git.** - -## Features - -- Generate a day planner for you each day or create a day planner in any note you choose. -- Status bar updates on progress with information on your current and next tasks. You can click on the status bar to access the note for today's day planner. -- Timeline view showing your tasks laid out on a vertical timeline. - -![Day Planner Demo Image](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/day-planner-note-preview.png) - -## Usage - -Once installed, the plugin will create a folder called Day Planners in the root of your vault. A note for today will automatically be created with the file name format `Day Planners/Day Planner-YYYYMMDD.md`. - -You can choose to use the [Command Mode](#day-planner-mode) instead to add a Day Planner for the current day to any note. - -### Day Planner Note - -Within the note, create a checklist with time blocks and tasks, which will be automatically tracked as the day progresses. You can include headers and other content between tasks for better organization. - -Here’s an example of a Day Planner note: - -```markdown -## Day Planner - -This is my plan for the day broken into 3 main sections: -1. Morning Prep -2. Reading -3. Afternoon Review - -### Morning Prep - -This is where I get ready for work and do my usual prep. - -- [ ] 09:30 Setup for work -- [ ] 09:45 Review notes from yesterday -- [ ] 10:30 Create new notes for #article review -- [ ] 11:30 BREAK - -### Reading - -A section of the day dedicated to reading: - -1. Articles. -2. Book chapters assigned for the day. -3. Re-reading past notes. - -- [ ] 12:00 Reading - - [ ] Article 1 - - [ ] Article 2 - - [ ] Article notes review -- [ ] 12:25 BREAK -- [ ] 12:30 Reading -- [ ] 14:00 BREAK - -### Afternoon Review - -I use this time to review what I have done earlier in the day and complete any tasks to prepare for the next day. - -- [ ] 15:00 Review notes and update daily note [[20201103]] -- [ ] 15:45 Walk -- [ ] 16:30 Reading -- [ ] 17:20 Prep for tomorrow's meetings -- [ ] 18:00 END - -``` - -This is also provided as a file in [day-planner-example.md](https://github.com/ebullient/obsidian-day-planner-og/blob/main/examples/day-planner-example.md). - -### Day Planner Note structure - -- The `# Day Planner` heading marks the beginning of the Day Planner in a note. This heading can be `#`, `##`, `###` or `####`. - -- Tasks are defined as `- [ ] HH:mm Task text` - - The **HH:mm** syntax is crucial as it designates the specific block timings. **24 hour times should be used.** - - Nested checklist items or bullets are now also supported to capture sub-tasks of a timed task. Timed tasks must be at the top level of the checkbox list. - -- **`BREAK`** and **`END`** are essential keywords defining breaks and the conclusion of the day's tracking. You can customize these in the Day Planner's settings, to replace `BREAK` or `END` with phrases of your choice. - - - `END` serves two purposes: - - It provides an end to the last task of the day, so the duration alloted to that task is accurate. - - It marks the end of the Day Planner. If your note has content after the `END` keyword, it will not be updated by the plugin. - -### Task updating - -If the Day Planner is linked to a note, and "Complete past planner items" is enabled, the plugin will update the note as the day progresses: tasks in the past will be checked and marked as complete. - -Using the example above, at 14:30 the note would have automatically updated to: - -```markdown -## Day Planner - -This is my plan for the day broken into 3 main sections: -1. Morning Prep -2. Reading -3. Afternoon Review - -### Morning Prep - -This is where I get ready for work and do my usual prep. - -- [x] 09:30 Setup for work -- [x] 09:45 Review notes from yesterday -- [x] 10:30 Create new notes for #article review -- [x] 11:30 BREAK - -### Reading - -A section of the day dedicated to reading: - -1. Articles. -2. Book chapters assigned for the day. -3. Re-reading past notes. - -- [x] 12:00 Reading - - [ ] Article 1 - - [ ] Article 2 - - [ ] Article notes review -- [x] 12:25 BREAK -- [x] 12:30 Reading -- [ ] 14:00 BREAK - -### Afternoon Review - -I use this time to review what I have done earlier in the day and complete any tasks to prepare for the next day. - -- [ ] 15:00 Review notes and update daily note [[20201103]] -- [ ] 15:45 Walk -- [ ] 16:30 Reading -- [ ] 17:20 Prep for tomorrow's meetings -- [ ] 18:00 END -``` - -### Timeline View - -The `Show the Day Planner Timeline` command can be used to add a vertical timeline view display the tasks for today's Day Planner with a line showing the current time. - -![Day Planner Timeline](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/day-planner-timeline.png) - -### Status Bar - -The status bar in Obsidian will also show the current progress on the task or break with the time remaining. Clicking on the status bar item will take you to the Day Planner note. - -#### Task Status - -The status displayed when there is an active task: - -![Task Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/task-status.png) - -#### Break Status - -The status displayed during a break: - -![Break Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/break-status.png) - -#### End Status - -The status displayed when the end of the tasks is reached: - -![End Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/end-status.png) - -## Configuration - -### Day Planner Mode - -There are 3 modes to use the Day Planner plugin: - -1. **File mode** - - The plugin automatically generates day planner notes for each day within a Day Planners folder. - -2. **Command mode** - - Commands are used to - - insert a Day Planner within any note - - unlink the Day Planner from the active note (stop updating) - - link the Day Planner to a note (start updating) - - To monitor the Day Planner section of a note you need to link the Day Planner to it. - Open the note (active leaf), and run one of the following commands from the command palette: - - - "Day Planner: Link today's Day Planner to the current Note" - - "Day Planner: Add a Day Planner template for today to the current note" - - The Day Planner can be placed anywhere within a note as long as the format provided is used. - Only the Day Planner section of the note will be updated as time progresses. - -3. **Daily mode** - - The plugin automatically looks for the day planner in daily notes. The Daily notes plugin must be enabled. - -### Complete Past Planner Items - -You can choose whether the plugin will automatically mark planner items in the past as complete or allow you to tick them off yourself. - -### Status Bar - Circular Progress - -You can choose to display progress in the status bar with a circular pie chart progress bar to save horizontal space. - -![Circular Progress Bar](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/circular-progress.png) - -### Status Bar - Now and Next - -You can choose to display the time and start of the text for the current and next task. - -![Now and Next](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/now-and-next.png) - -### Task Notification - -You can choose to have an in-app notification display when a new task starts. - -### Timeline Zoom Level - -This is the zoom level to dispaly the timeline. The higher the number, the more vertical space each task will take up. - -## Commands - -Using the plugin in command mode, 2 commands are available to link and unlink a Day Planner. - -![Plugin Commands](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/commands.png) - -## Installation - -1. Go to **Community Plugins** in your [Obsidian](https://www.obsidian.md) settings and **disable** Safe Mode -2. Click on **Browse** and search for "day planner og" -3. Click install -4. Use the toggle on the community plugins tab to enable the plugin. - -### Preview with Beta Reviewers Auto-update Tester (BRAT) - -1. Install BRAT - 1. Open `Settings` -> `Community Plugins` - 2. Disable safe mode - 3. *Browse*, and search for "BRAT" - 4. Install the latest version of **Obsidian 42 - BRAT** -2. Open BRAT settings (`Settings` -> `Obsidian 42 - BRAT`) - 1. Scroll to the `Beta Plugin List` section - 2. `Add Beta Plugin` - 3. Specify this repository: `ebullient/obsidian-day-planner-og` -3. Enable the plugin (`Settings` -> `Community Plugins`) - -## Manual installation - -1. Download the [latest release](https://github.com/ebullient/obsidian-day-planner-og/releases/latest) -2. Extract the obsidian-day-planner-og folder from the zip to your vault's plugins folder: `/.obsidian/plugins/` -Note: On some machines the `.obsidian` folder may be hidden. On MacOS you should be able to press `Command+Shift+Dot` to show the folder in Finder. -3. Reload Obsidian -4. If prompted about Safe Mode, you can disable safe mode and enable the plugin. -5. Enable the plugin (`Settings` -> `Community Plugins`) - -## For developers - -Pull requests are both welcome and appreciated. πŸ˜€ - -If you would like to contribute to the development of this plugin, please follow the guidelines provided in [CONTRIBUTING.md](CONTRIBUTING.md). - +# Day Planner (OG) + +[![GitHub tag (Latest by date)](https://img.shields.io/github/v/tag/ebullient/obsidian-day-planner-og)](https://github.com/ebullient/obsidian-day-planner-og/releases) ![GitHub all releases](https://img.shields.io/github/downloads/ebullient/obsidian-day-planner-og/total?color=success) + +The Day Planner plugin is your pomodoro-like assistant for managing daily tasks in Obsidian. +Set specific blocks of time for various activities, and the plugin keeps track, offering you real-time updates, impending block-end notifications, and a visual gauge of your day's progress. +Not only does it help in planning, but it also actively marks off the blocks as the day progresses and highlights the current block, keeping you on track. + +This plugin is a fork of the early Obsidian Day Planner plugin written by [James Lynch](https://github.com/lynchjames). +The [Day Planner Plugin](https://github.com/ivan-lednev/obsidian-day-planner) has evolved with new features like drag-and-drop task creation and a weekly view. +This "OG" version holds onto the essence of the original. +In the interest of stability, I have disabled the Mermaid Gantt chart feature. +Reach out if you're interested in this feature, and we can work towards reintegrating it. + +## This plugin will change your notes + +The Day Planner plugin manages pomodoro timers from a task list in a Markdown note. + +> When day planner is associated with a note and "Complete past planner items" is enabled, Day planner will update the contents of that note. + +This may cause issues if you have the plugin (and that setting) enabled on multiple active devices with sync functionality (of any kind). To avoid this issue, I usually have Day Planner active only one device (e.g. my Desktop). That one device updates the time, and the sync utility handles forwarding and merging the updates to other devices. + +**Please try the plugin in a test vault first, and, most importantly, make sure you have your notes backed up in cloud storage or Git.** + +## Features + +- Generate a day planner for you each day or create a day planner in any note you choose. +- Status bar updates on progress with information on your current and next tasks. You can click on the status bar to access the note for today's day planner. +- Timeline view showing your tasks laid out on a vertical timeline. + +![Day Planner Demo Image](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/day-planner-note-preview.png) + +## Usage + +Once installed, the plugin will create a folder called Day Planners in the root of your vault. A note for today will automatically be created with the file name format `Day Planners/Day Planner-YYYYMMDD.md`. + +You can choose to use the [Command Mode](#day-planner-mode) instead to add a Day Planner for the current day to any note. + +### Day Planner Note + +Within the note, create a checklist with time blocks and tasks, which will be automatically tracked as the day progresses. You can include headers and other content between tasks for better organization. + +Here’s an example of a Day Planner note: + +```markdown +## Day Planner + +This is my plan for the day broken into 3 main sections: + +1. Morning Prep +2. Reading +3. Afternoon Review + +### Morning Prep + +This is where I get ready for work and do my usual prep. + +- [ ] 09:30 Setup for work +- [ ] 09:45 Review notes from yesterday +- [ ] 10:30 Create new notes for #article review +- [ ] 11:30 BREAK + +### Reading + +A section of the day dedicated to reading: + +1. Articles. +2. Book chapters assigned for the day. +3. Re-reading past notes. + +- [ ] 12:00 Reading + - [ ] Article 1 + - [ ] Article 2 + - [ ] Article notes review +- [ ] 12:25 BREAK +- [ ] 12:30 Reading +- [ ] 14:00 BREAK + +### Afternoon Review + +I use this time to review what I have done earlier in the day and complete any tasks to prepare for the next day. + +- [ ] 15:00 Review notes and update daily note [[20201103]] +- [ ] 15:45 Walk +- [ ] 16:30 Reading +- [ ] 17:20 Prep for tomorrow's meetings +- [ ] 18:00 END + +``` + +This is also provided as a file in [day-planner-example.md](https://github.com/ebullient/obsidian-day-planner-og/blob/main/examples/day-planner-example.md). + +### Day Planner Note structure + +- The `# Day Planner` heading marks the beginning of the Day Planner in a note. This heading can be `#`, `##`, `###` or `####`. + +- Tasks are defined as `- [ ] HH:mm Task text` + + The **HH:mm** syntax is crucial as it designates the specific block timings. **24 hour times should be used.** + + Nested checklist items or bullets are now also supported to capture sub-tasks of a timed task. Timed tasks must be at the top level of the checkbox list. + +- **`BREAK`** and **`END`** are essential keywords defining breaks and the conclusion of the day's tracking. You can customize these in the Day Planner's settings, to replace `BREAK` or `END` with phrases of your choice. + + `END` serves two purposes: + + - It provides an end to the last task of the day, so the duration alloted to that task is accurate. + - It marks the end of the Day Planner. If your note has content after the `END` keyword, it will not be updated by the plugin. + +### Task updating + +If the Day Planner is linked to a note, and "Complete past planner items" is enabled, the plugin will update the note as the day progresses: tasks in the past will be checked and marked as complete. + +Using the example above, at 14:30 the note would have automatically updated to: + +```markdown +## Day Planner + +This is my plan for the day broken into 3 main sections: + +1. Morning Prep +2. Reading +3. Afternoon Review + +### Morning Prep + +This is where I get ready for work and do my usual prep. + +- [x] 09:30 Setup for work +- [x] 09:45 Review notes from yesterday +- [x] 10:30 Create new notes for #article review +- [x] 11:30 BREAK + +### Reading + +A section of the day dedicated to reading: + +1. Articles. +2. Book chapters assigned for the day. +3. Re-reading past notes. + +- [x] 12:00 Reading + - [ ] Article 1 + - [ ] Article 2 + - [ ] Article notes review +- [x] 12:25 BREAK +- [x] 12:30 Reading +- [ ] 14:00 BREAK + +### Afternoon Review + +I use this time to review what I have done earlier in the day and complete any tasks to prepare for the next day. + +- [ ] 15:00 Review notes and update daily note [[20201103]] +- [ ] 15:45 Walk +- [ ] 16:30 Reading +- [ ] 17:20 Prep for tomorrow's meetings +- [ ] 18:00 END +``` + +### Timeline View + +The `Show the Day Planner Timeline` command can be used to add a vertical timeline view display the tasks for today's Day Planner with a line showing the current time. + +![Day Planner Timeline](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/day-planner-timeline.png) + +### Status Bar + +The status bar in Obsidian will also show the current progress on the task or break with the time remaining. Clicking on the status bar item will take you to the Day Planner note. + +#### Task Status + +The status displayed when there is an active task: + +![Task Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/task-status.png) + +#### Break Status + +The status displayed during a break: + +![Break Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/break-status.png) + +#### End Status + +The status displayed when the end of the tasks is reached: + +![End Status](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/end-status.png) + +## Configuration + +### Day Planner Mode + +There are 3 modes to use the Day Planner plugin: + +1. **File mode** + + The plugin automatically generates day planner notes for each day within a Day Planners folder. + +2. **Command mode** + + Commands are used to + + - insert a Day Planner within any note + - unlink the Day Planner from the active note (stop updating) + - link the Day Planner to a note (start updating) + + To monitor the Day Planner section of a note you need to link the Day Planner to it. + Open the note (active leaf), and run one of the following commands from the command palette: + + - "Day Planner: Link today's Day Planner to the current Note" + - "Day Planner: Add a Day Planner template for today to the current note" + + The Day Planner can be placed anywhere within a note as long as the format provided is used. + Only the Day Planner section of the note will be updated as time progresses. + +3. **Daily mode** + + The plugin automatically looks for the day planner in daily notes. The Daily notes plugin must be enabled. + +### Complete Past Planner Items + +You can choose whether the plugin will automatically mark planner items in the past as complete or allow you to tick them off yourself. + +### Status Bar - Circular Progress + +You can choose to display progress in the status bar with a circular pie chart progress bar to save horizontal space. + +![Circular Progress Bar](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/circular-progress.png) + +### Status Bar - Now and Next + +You can choose to display the time and start of the text for the current and next task. + +![Now and Next](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/now-and-next.png) + +### Task Notification + +You can choose to have an in-app notification display when a new task starts. + +### Timeline Zoom Level + +This is the zoom level to dispaly the timeline. The higher the number, the more vertical space each task will take up. + +## Commands + +Using the plugin in command mode, 2 commands are available to link and unlink a Day Planner. + +![Plugin Commands](https://raw.githubusercontent.com/ebullient/obsidian-day-planner-og/main/images/commands.png) + +## Installation + +1. Go to **Community Plugins** in your [Obsidian](https://www.obsidian.md) settings and **disable** Safe Mode +2. Click on **Browse** and search for "day planner og" +3. Click install +4. Use the toggle on the community plugins tab to enable the plugin. + +### Preview with Beta Reviewers Auto-update Tester (BRAT) + +1. Install BRAT + 1. Open `Settings` -> `Community Plugins` + 2. Disable safe mode + 3. *Browse*, and search for "BRAT" + 4. Install the latest version of **Obsidian 42 - BRAT** +2. Open BRAT settings (`Settings` -> `Obsidian 42 - BRAT`) + 1. Scroll to the `Beta Plugin List` section + 2. `Add Beta Plugin` + 3. Specify this repository: `ebullient/obsidian-day-planner-og` +3. Enable the plugin (`Settings` -> `Community Plugins`) + +## Manual installation + +1. Download the [latest release](https://github.com/ebullient/obsidian-day-planner-og/releases/latest) +2. Extract the obsidian-day-planner-og folder from the zip to your vault's plugins folder: `/.obsidian/plugins/` + *Note:* On some machines the `.obsidian` folder may be hidden. On MacOS you should be able to press `Command+Shift+Dot` to show the folder in Finder. +3. Reload Obsidian +4. If prompted about Safe Mode, you can disable safe mode and enable the plugin. +5. Enable the plugin (`Settings` -> `Community Plugins`) + +## For developers + +Pull requests are both welcome and appreciated. πŸ˜€ + +If you would like to contribute to the development of this plugin, please follow the guidelines provided in [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/src/parser.ts b/src/parser.ts index d782db8..554a690 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -24,10 +24,10 @@ export default class Parser { this.settings = settings; this.planItemFactory = new PlanItemFactory(settings); this.PLAN_START = `# ${this.settings.plannerLabel}`; - const startSafe = this.sanitize(settings.breakLabel); + const breakSafe = this.sanitize(settings.breakLabel); const endSafe = this.sanitize(settings.endLabel); - this.PLAN_BREAK = new RegExp(`(?<=^|\\s)${startSafe}(?=\\s|$)`); - this.PLAN_END = new RegExp(`(?<=^|\\s)${endSafe}(?=\\s|$)`); + this.PLAN_BREAK = new RegExp(`^${breakSafe}(?=\\b|$)`, "i"); + this.PLAN_END = new RegExp(`^${endSafe}(?=\\b|$)`, "i"); } sanitize(input: string): string { @@ -80,8 +80,10 @@ export default class Parser { // console.log(match); const value = match; const text = value.groups.text; + // console.log(text); const isBreak = this.matches(text, this.PLAN_BREAK); const isEnd = this.matches(text, this.PLAN_END); + const time = new Date(); time.setHours(Number.parseInt(value.groups.hours)); time.setMinutes(Number.parseInt(value.groups.minutes)); @@ -122,6 +124,6 @@ export default class Parser { } private matches(input: string, regex: RegExp): boolean { - return regex.test(input.trim().toUpperCase()); + return regex.test(input.trim()); } } diff --git a/tests/fixtures/test-keep.md b/tests/fixtures/test-keep.md index ce9c871..62d890d 100644 --- a/tests/fixtures/test-keep.md +++ b/tests/fixtures/test-keep.md @@ -3,7 +3,6 @@ - [x] 8:00 morning stuff - [-] 9:00 breakfast - [>] 10:00 meeting -- [ ] 11:00 β˜•οΈ Coffee Break +- [/] 11:00 β˜•οΈ Coffee Break : Reading - [ ] 12:10 reading -- [ ] 14:00 πŸ›‘ Finish - +- [ ] 14:00 πŸ›‘ Finish : Things diff --git a/tests/fixtures/test-ooo.md b/tests/fixtures/test-ooo.md index 5e04ff4..4ada76e 100644 --- a/tests/fixtures/test-ooo.md +++ b/tests/fixtures/test-ooo.md @@ -3,10 +3,12 @@ - [x] 8:00 morning stuff ### Middle + - [ ] 11:00 β˜•οΈ Coffee Break - [ ] 12:10 reading [Markdown](markdown-link) ### Other + - [-] 9:00 breakfast [[wikilink]] - [>] 10:00 meeting [[wikilink|alias]] - [ ] 14:00 πŸ›‘ Finish diff --git a/tests/fixtures/test.md b/tests/fixtures/test.md index cbbfd6b..efa1690 100644 --- a/tests/fixtures/test.md +++ b/tests/fixtures/test.md @@ -9,4 +9,3 @@ - [ ] 13:00 β˜•οΈ COFFEE BREAK - [ ] 13:10 meeting - [ ] 14:00 πŸ›‘ Finish - diff --git a/tests/parser.test.ts b/tests/parser.test.ts index ff15fcf..74a4285 100644 --- a/tests/parser.test.ts +++ b/tests/parser.test.ts @@ -5,8 +5,8 @@ import Moment from "moment"; Object.defineProperty(window, "moment", { value: Moment }); import { test, expect, describe } from "vitest"; -import * as fs from 'fs'; -import path from 'path'; +import * as fs from "node:fs"; +import path from "node:path"; import Parser from '../src/parser'; import { DayPlannerSettings } from '../src/settings'; @@ -30,8 +30,7 @@ describe('parser', () => { date.setSeconds(0); const updatedContent = parser.parseContent(fileContents, summary, date); - const updated = updatedContent.split('\n'); - console.log(updated); + const updated = updatedContent.split("\n"); expect(summary.empty).to.be.false; expect(summary.invalid).to.be.false; @@ -108,8 +107,7 @@ describe('parser', () => { date.setSeconds(0); const updatedContent = parser.parseContent(fileContents, summary, date); - const updated = updatedContent.split('\n'); - console.log(updated); + const updated = updatedContent.split("\n"); expect(summary.empty).to.be.false; expect(summary.invalid).to.be.false; @@ -129,46 +127,60 @@ describe('parser', () => { expect(updated[summary.items[8].line]).to.eql("- [ ] 14:00 END"); }); - test('should keep configured values', async () => { - const fileContents = fs.readFileSync(path.join(__dirname, 'fixtures/test-keep.md')).toString(); + test("should keep configured values", async () => { + const fileContents = fs + .readFileSync(path.join(__dirname, "fixtures/test-keep.md")) + .toString(); const settings = new DayPlannerSettings(); - settings.preserveValues = '->'; + settings.preserveValues = "->"; settings.markCurrent = true; settings.correctLabels = false; + settings.breakLabel = "β˜•οΈ Coffee Break"; + settings.endLabel = "πŸ›‘ Finish"; const parser = new Parser(settings); const summary = new PlanSummaryData([], true); const date = new Date(); - date.setHours(12) - date.setMinutes(25) + date.setHours(12); + date.setMinutes(25); date.setSeconds(0); const updatedContent = parser.parseContent(fileContents, summary, date); - const updated = updatedContent.split('\n'); - console.log(updated); + const updated = updatedContent.split("\n"); expect(summary.empty).to.be.false; expect(summary.invalid).to.be.false; expect(summary.items).to.have.lengthOf(6); - expect(summary.items[0].text).to.eql('morning stuff'); + expect(summary.items[0].text).to.eql("morning stuff"); expect(summary.items[0].line).to.eql(2); - expect(updated[summary.items[0].line]).to.eql("- [x] 08:00 morning stuff"); + expect(updated[summary.items[0].line]).to.eql( + "- [x] 08:00 morning stuff", + ); expect(updated[summary.items[1].line]).to.eql("- [-] 09:00 breakfast"); expect(updated[summary.items[2].line]).to.eql("- [>] 10:00 meeting"); - expect(updated[summary.items[3].line]).to.eql("- [x] 11:00 β˜•οΈ Coffee Break"); + expect(updated[summary.items[3].line]).to.eql( + "- [x] 11:00 β˜•οΈ Coffee Break : Reading", + ); expect(updated[summary.items[4].line]).to.eql("- [/] 12:10 reading"); - expect(updated[summary.items[5].line]).to.eql("- [ ] 14:00 πŸ›‘ Finish"); + expect(updated[summary.items[5].line]).to.eql( + "- [ ] 14:00 πŸ›‘ Finish : Things", + ); + + expect(summary.items[3].isBreak).to.be.true; + expect(summary.items[5].isEnd).to.be.true; }); - test('preserve out of order', async () => { - const fileContents = fs.readFileSync(path.join(__dirname, 'fixtures/test-ooo.md')).toString(); + test("preserve out of order", async () => { + const fileContents = fs + .readFileSync(path.join(__dirname, "fixtures/test-ooo.md")) + .toString(); const settings = new DayPlannerSettings(); - settings.preserveValues = '->'; + settings.preserveValues = "->"; settings.markCurrent = true; settings.correctLabels = false; @@ -176,8 +188,8 @@ describe('parser', () => { const summary = new PlanSummaryData([], true); const date = new Date(); - date.setHours(12) - date.setMinutes(25) + date.setHours(12); + date.setMinutes(25); date.setSeconds(0); const updatedContent = parser.parseContent(fileContents, summary, date); @@ -186,30 +198,41 @@ describe('parser', () => { - [x] 08:00 morning stuff ### Middle + - [x] 11:00 β˜•οΈ Coffee Break - [/] 12:10 reading [Markdown](markdown-link) ### Other + - [-] 09:00 breakfast [[wikilink]] - [>] 10:00 meeting [[wikilink|alias]] - [ ] 14:00 πŸ›‘ Finish `); - const updated = updatedContent.split('\n'); - console.log(updated); + const updated = updatedContent.split("\n"); expect(summary.empty).to.be.false; expect(summary.invalid).to.be.false; expect(summary.items).to.have.lengthOf(6); - expect(summary.items[0].text).to.eql('morning stuff'); + expect(summary.items[0].text).to.eql("morning stuff"); expect(summary.items[0].line).to.eql(2); - expect(updated[summary.items[0].line]).to.eql("- [x] 08:00 morning stuff"); - expect(updated[summary.items[1].line]).to.eql('- [-] 09:00 breakfast [[wikilink]]'); - expect(updated[summary.items[2].line]).to.eql('- [>] 10:00 meeting [[wikilink|alias]]'); - expect(updated[summary.items[3].line]).to.eql("- [x] 11:00 β˜•οΈ Coffee Break"); - expect(updated[summary.items[4].line]).to.eql('- [/] 12:10 reading [Markdown](markdown-link)'); + expect(updated[summary.items[0].line]).to.eql( + "- [x] 08:00 morning stuff", + ); + expect(updated[summary.items[1].line]).to.eql( + "- [-] 09:00 breakfast [[wikilink]]", + ); + expect(updated[summary.items[2].line]).to.eql( + "- [>] 10:00 meeting [[wikilink|alias]]", + ); + expect(updated[summary.items[3].line]).to.eql( + "- [x] 11:00 β˜•οΈ Coffee Break", + ); + expect(updated[summary.items[4].line]).to.eql( + "- [/] 12:10 reading [Markdown](markdown-link)", + ); expect(updated[summary.items[5].line]).to.eql("- [ ] 14:00 πŸ›‘ Finish"); }); }); diff --git a/tests/plan-data.test.ts b/tests/plan-data.test.ts index 8a58a96..6c7fcbf 100644 --- a/tests/plan-data.test.ts +++ b/tests/plan-data.test.ts @@ -13,7 +13,6 @@ describe('plan-data', () => { describe('PlanItemFactory', () => { const matchIndex = 1; const charIndex = 0; - const status = 'x'; const isBreak = false; const isEnd = false; const time = new Date('2021-04-11T11:10:00.507Z');