( app: App, sourcePath: string, entry: TaskDependency | string )
| 128 | } |
| 129 | |
| 130 | export function resolveDependencyEntry( |
| 131 | app: App, |
| 132 | sourcePath: string, |
| 133 | entry: TaskDependency | string |
| 134 | ): DependencyResolution | null { |
| 135 | const rawUid = extractDependencyUid(entry); |
| 136 | if (!rawUid) { |
| 137 | return null; |
| 138 | } |
| 139 | |
| 140 | const target = parseLinkToPath(rawUid); |
| 141 | |
| 142 | if (!target) { |
| 143 | return null; |
| 144 | } |
| 145 | |
| 146 | // Try multiple candidate targets to tolerate .md suffix and parsed linktext variants |
| 147 | const candidates = new Set<string>(); |
| 148 | candidates.add(target); |
| 149 | if (target.endsWith(".md")) { |
| 150 | candidates.add(target.replace(/\.md$/i, "")); |
| 151 | } |
| 152 | const parsed = parseLinktext(target); |
| 153 | if (parsed.path && parsed.path !== target) { |
| 154 | candidates.add(parsed.path); |
| 155 | } |
| 156 | |
| 157 | for (const candidate of candidates) { |
| 158 | const resolved = app.metadataCache.getFirstLinkpathDest(candidate, sourcePath); |
| 159 | if (resolved instanceof TFile) { |
| 160 | return { path: resolved.path, file: resolved }; |
| 161 | } |
| 162 | const fallback = app.vault.getAbstractFileByPath(candidate); |
| 163 | if (fallback instanceof TFile) { |
| 164 | return { path: fallback.path, file: fallback }; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | return null; |
| 169 | } |
| 170 | |
| 171 | export function formatDependencyLink(app: App, sourcePath: string, targetPath: string, useMarkdownLinks?: boolean): string { |
| 172 | const target = app.vault.getAbstractFileByPath(targetPath); |
no test coverage detected