Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## changes

- conditionally removes timestamps in render-task-markdown based on the task decoration toggle (showTimestampInTaskBlock)
- to do this, also edited removeTimestampFromStart function and looseTimestampAtStartOfLineRegExp const
- looseTimestampAtStartOfLineRegExp edited to get timestamp even if there are task/list markers in front of them
- removeTimestampFromStart brought into the render thing based on showTimestampInTaskBlock

# original README

- 🗳️ [Add '👍' reactions under the issues important to you.](https://github.com/ivan-lednev/obsidian-day-planner/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) This helps me prioritize my work
- 🪲 [Report bugs and suggest features](https://github.com/ivan-lednev/obsidian-day-planner/issues)
- ❓ [Ask questions](https://github.com/ivan-lednev/obsidian-day-planner/discussions/new?category=q-a)
Expand Down
3 changes: 2 additions & 1 deletion src/regexp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export const headingRegExp = /^(#+)\s/;
export const obsidianBlockIdRegExp = /\s\^[a-z1-9-]+$/i;

export const looseTimestampAtStartOfLineRegExp = new RegExp(
`^(?<start>${time})(?:${durationSeparator}(?<end>${time}))?`,
`^(?<taskmarker>\\s*[-+*]\\s*\\[[ x]\\]\\s*)?(?<start>${time})(?:${durationSeparator}(?<end>${time}))?`,
"im",
);

export const strictTimestampAnywhereInLineRegExp = new RegExp(
`(?<start>${strictTime})(?:${durationSeparator}(?<end>${strictTime}))?`,
"im",
Expand Down
15 changes: 12 additions & 3 deletions src/ui/actions/render-task-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import type { DayPlannerSettings } from "../../settings";
import type { LocalTask } from "../../task-types";
import type { RenderMarkdown } from "../../types";
import { deleteProps } from "../../util/properties";
import { getFirstLine, getRenderKey } from "../../util/task-utils";
import {
getFirstLine,
getRenderKey,
removeTimestampFromStart,
} from "../../util/task-utils";
import { normalizeNewlines } from "../../util/util";

import { createMemo } from "./memoize-props";
Expand Down Expand Up @@ -45,11 +49,16 @@ export function renderTaskMarkdown(
const displayedText = normalizeNewlines(
deleteProps(getDisplayedText(task)),
);
const onlyFirstLineIfNeeded = settings.showSubtasksInTaskBlocks

let finalText = settings.showSubtasksInTaskBlocks
? displayedText
: getFirstLine(displayedText);

onDestroy.push(renderMarkdown(el, onlyFirstLineIfNeeded));
if (!settings.showTimestampInTaskBlock) {
finalText = removeTimestampFromStart(finalText);
}

onDestroy.push(renderMarkdown(el, finalText));

if (!task.lines) {
return;
Expand Down
5 changes: 4 additions & 1 deletion src/util/task-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ export function removeListTokens(text: string) {
}

export function removeTimestampFromStart(text: string) {
return text.replace(looseTimestampAtStartOfLineRegExp, "");
return text.replace(
looseTimestampAtStartOfLineRegExp,
(_, taskmarker) => taskmarker ?? "",
);
}

export function isTimeEqual(a: LocalTask, b: LocalTask) {
Expand Down