eb8dbf66a1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.7 KiB
2.7 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| extract_obsidian_wikilinks | function | py | obsidian | 1.0.0 | pure | def extract_obsidian_wikilinks(body: str) -> list | Extrae los targets de los wikilinks ... del cuerpo de una nota de Obsidian. Normaliza alias (nota -> nota), heading (nota#h -> nota) y block id (nota#^id -> nota). Incluye tambien los embeds !... como links (Obsidian los trata como tales). Deduplica preservando orden de aparicion. Pura, sin I/O. |
|
false |
|
|
Lista de strings con los nombres de nota target unicos, en orden de primera aparicion. Cada target esta normalizado (sin alias, sin heading/block anchor, sin espacios al borde). Los embeds de imagen/nota se incluyen igual que los links normales. Lista vacia si no hay wikilinks. | true |
|
python/functions/obsidian/extract_obsidian_wikilinks_test.py | python/functions/obsidian/extract_obsidian_wikilinks.py |
Ejemplo
body = (
"See [[Note A]] and [[Note B|the second]] plus [[Note A#Section]] "
"and [[Note C#^block123]]. Embed: ![[diagram.png]]. Repeat [[Note A]]."
)
extract_obsidian_wikilinks(body)
# ["Note A", "Note B", "Note C", "diagram.png"]
Cuando usarla
Usala para construir el grafo de enlaces de un vault (backlinks/forward-links),
detectar notas huerfanas o referenciadas, o validar enlaces rotos antes de un
refactor. Aplicala al body que devuelve parse_obsidian_frontmatter para
ignorar wikilinks que pudieran aparecer dentro de valores YAML del frontmatter.
Gotchas
- Los embeds
![[...]]se incluyen como links (decision intencional: Obsidian los cuenta en el grafo). Si necesitas separar links de embeds, filtra por la extension del target o por el!aparte — esta funcion no distingue. - Solo normaliza al nombre de nota: pierde deliberadamente el alias, el heading y el block id. Si necesitas el anchor completo, parsea el body tu mismo.
- No resuelve rutas relativas ni desambigua notas con el mismo nombre en carpetas distintas: devuelve el texto del link tal cual (sin la carpeta si el link no la incluye).
- No procesa Markdown links estandar
[texto](url)— solo wikilinks[[...]].