| 1539 | |
| 1540 | |
| 1541 | def resolve_obsidian_note_path( |
| 1542 | config: dict[str, Any], |
| 1543 | *, |
| 1544 | title: str, |
| 1545 | subdir: str = "", |
| 1546 | filename: str = "", |
| 1547 | ) -> Path: |
| 1548 | output_mode, root_path = resolve_note_output_mode(config) |
| 1549 | papers_dir = str(config.get("papers_dir", "Research/Papers")).strip() or "Research/Papers" |
| 1550 | relative_dir = Path(papers_dir) if output_mode == "obsidian" else Path() |
| 1551 | if subdir: |
| 1552 | subdir_path = Path(subdir) |
| 1553 | if output_mode == "obsidian" and str(subdir_path).startswith(papers_dir): |
| 1554 | relative_dir = subdir_path |
| 1555 | else: |
| 1556 | relative_dir = relative_dir / subdir_path |
| 1557 | note_slug = slugify_filename(title) |
| 1558 | target_name = filename or f"{note_slug}.md" |
| 1559 | folder_name = Path(target_name).stem or note_slug |
| 1560 | folder_aliases = {folder_name, note_slug, slugify_filename(folder_name)} |
| 1561 | normalized_folder_aliases = {alias.lower() for alias in folder_aliases if alias} |
| 1562 | if relative_dir.name.lower() in normalized_folder_aliases: |
| 1563 | return root_path / relative_dir / target_name |
| 1564 | return root_path / relative_dir / folder_name / target_name |
| 1565 | |
| 1566 | |
| 1567 | def default_pdf_path(record: dict[str, Any], dest_dir: str | None = None) -> Path: |