Skip to content

Implement an export subcommand (page + attachments to the filesystem) #37

Description

@willkg

Add an export subcommand that writes a Confluence page and its attachments to a directory, mirroring pchuri/confluence-cli's export. This builds on read (page → markdown/storage) by also downloading attachments and laying everything out on disk so the exported markdown's image links resolve locally.

Command

markfluence export ARG [flags]

ARG is a numeric page id or a Confluence page URL (same resolver as read).

Flags (mirroring confluence-cli)

  • --dest <dir> — output directory (default .).
  • --file <name> — content filename (default derived from title/id, e.g. <slug>.md).
  • --attachments-dir <name> — attachments subdirectory (default e.g. attachments/).
  • --format markdown|storage — content format (default markdown), reusing read's conversion. (confluence-cli also has html/text; markfluence has neither yet — out of scope unless we add them.)
  • --pattern <glob> — only export attachments matching the glob.
  • --referenced-only — only download attachments actually referenced in the body.
  • --skip-attachments — write the content file only.

Filesystem output

<dest>/
  <file>.md                # page content (markdown by default), with frontmatter
  <attachments-dir>/       # downloaded attachment files
    ...

New capability: downloading attachments

markfluence today lists (ListAttachments) and uploads attachments but never downloads their bytes. Export needs a client method to fetch an attachment's binary (v1 .../download or the attachment _links.download), plus listing/pagination.

The image-link reconciliation (the crux)

read's markdown emits the flattened attachment filename (assets/x.pngassets_x.png) as the image src. For an export to be self-contained, the downloaded files and the markdown srcs must line up — e.g. download each attachment into <attachments-dir>/ and rewrite image srcs to <attachments-dir>/<filename>. This also closes the local-image round-trip gap noted during the read work (reading a page couldn't recover image bytes/paths).

Open questions

  • Default content filename: slugified title, page id, or require --file?
  • Attachment name collisions (Confluence allows multiple attachments; flattened names could clash) — how to disambiguate.
  • --referenced-only scope: only ac:image/ri:attachment references, or also links to attachments?
  • Should export also emit enough for a later create/update (frontmatter with page_id), so an exported tree round-trips back? (It would, via the markdown frontmatter.)
  • Multi-page export (a page + its descendants) — out of scope for v1, or a --recursive/depth flag later?

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions