( files: ImportFile[], )
| 136 | } |
| 137 | |
| 138 | export function parseObsidianMarkdownFiles( |
| 139 | files: ImportFile[], |
| 140 | ): NoteImportParseResult { |
| 141 | const notes: NoteImportCandidate[] = [] |
| 142 | const warnings: NoteImportParseResult['warnings'] = [] |
| 143 | |
| 144 | files.forEach((file) => { |
| 145 | const filePath = getImportPath(file) |
| 146 | if (!isSupportedMarkdownFile(filePath)) { |
| 147 | if (filePath.toLowerCase().endsWith('.excalidraw.md')) { |
| 148 | warnings.push({ |
| 149 | code: 'obsidian.excalidrawSkipped', |
| 150 | source: filePath, |
| 151 | }) |
| 152 | } |
| 153 | return |
| 154 | } |
| 155 | |
| 156 | const parsed = parseFrontmatter(file.content) |
| 157 | |
| 158 | if (parsed.invalid) { |
| 159 | warnings.push({ |
| 160 | code: 'obsidian.invalidFrontmatter', |
| 161 | source: filePath, |
| 162 | }) |
| 163 | } |
| 164 | |
| 165 | if (!parsed.content.trim()) { |
| 166 | warnings.push({ |
| 167 | code: 'obsidian.emptyMarkdown', |
| 168 | source: filePath, |
| 169 | }) |
| 170 | return |
| 171 | } |
| 172 | |
| 173 | if (parsed.ignoredKeys.length) { |
| 174 | warnings.push({ |
| 175 | code: 'obsidian.frontmatterIgnored', |
| 176 | details: { |
| 177 | fields: parsed.ignoredKeys.join(', '), |
| 178 | }, |
| 179 | source: filePath, |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | if (hasAttachmentReferences(parsed.content)) { |
| 184 | warnings.push({ |
| 185 | code: 'obsidian.attachmentsKept', |
| 186 | source: filePath, |
| 187 | }) |
| 188 | } |
| 189 | |
| 190 | if (hasWikiLinks(parsed.content)) { |
| 191 | warnings.push({ |
| 192 | code: 'obsidian.wikiLinksKept', |
| 193 | source: filePath, |
| 194 | }) |
| 195 | } |
no test coverage detected