Skip to content

Fix #745: CLI empty title, metaTags, description#795

Open
gavriilfakih wants to merge 1 commit into
obsidianmd:mainfrom
gavriilfakih:fix-cli-documentelement-meta
Open

Fix #745: CLI empty title, metaTags, description#795
gavriilfakih wants to merge 1 commit into
obsidianmd:mainfrom
gavriilfakih:fix-cli-documentelement-meta

Conversation

@gavriilfakih
Copy link
Copy Markdown

@gavriilfakih gavriilfakih commented Apr 18, 2026

Summary

Closes #745. The CLI’s clip() passes doc.documentElement to Defuddle, but on linkedom the element root does not expose <head> meta tags, so every field sourced from meta (title, description, published, metaTags, {{meta:name:citation_*}}, {{meta:property:og:*}}) comes back empty.

Passing the full doc fixes it. This is already how src/utils/template-integration.test.ts instantiates Defuddle, so this change brings api.ts in line with the tests.

Repro

bash npm run build:cli node dist/cli.cjs https://example.com -t template.json ​

Before: empty title, empty content, empty meta lookups.
After: populated as expected.

Scope

clip() is only called from src/cli.ts. The browser extension goes through its own path (popup.ts / content.ts) and does not use this function, so this is CLI-only.

Tests

The 560 passing tests still pass. The 3 pre-existing timezone-related fixture failures (YouTube, edge-cases, minimal) are unrelated—they also fail on main without this change, and there's an open PR (#750) addressing them.

The CLI passed `doc.documentElement` to `new DefuddleClass(...)`. On
linkedom, the element root does not expose `<head>` meta tags, so
`defuddleResult.title`, `description`, `published`, `metaTags`, etc.
all come back empty—which is exactly what obsidianmd#745 reported.

Passing the full `doc` fixes it and aligns `api.ts` with the
equivalent call in `template-integration.test.ts`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: empty output and navigator error

1 participant