Files
fn_registry/python/functions/obsidian/extract_obsidian_wikilinks.md
T
egutierrez eb8dbf66a1 feat(infra): auto-commit con 88 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 00:16:46 +02:00

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.
obsidian
wikilink
links
markdown
extract
note
graph
false
re
name desc
body Cuerpo Markdown de una nota de Obsidian (idealmente sin frontmatter). Puede contener wikilinks ... y embeds !... con alias (|), heading (#) o block id (#^).
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
links basicos y normalizacion
incluye embeds
dedup preserva orden
alias y heading combinados
whitespace se strippa
sin links
body vacio
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 [[...]].