Skip to content

Add a preview subcommand to render a page locally as Confluence would show it #47

Description

@willkg

Summary

Add a preview subcommand that renders a page locally, approximating how it would look in Confluence, so authors can check layout and macros without publishing.

Today the only ways to see the result are to update/create and open the live page, or read the raw storage — neither shows a rendered approximation. --dry-run (#11) reports what actions would happen; preview would show what the page looks like.

What it would do

  1. Convert the markdown to Confluence storage format (reuse convert.MdToConfluence, same pipeline as update/create).
  2. Render that storage into a browser-viewable HTML approximation, interpreting the Confluence storage tags the converter emits, and either write it to a file or open it in a browser.

Storage tags to interpret

The converter already emits these (see internal/convert); preview needs to translate them into presentational HTML:

  • Layoutsac:layout, ac:layout-section (single/two/three column, sidebars), ac:layout-cell. This is the motivating case: multi-column layouts are invisible in raw markdown and easy to get wrong.
  • Macrosac:structured-macro for code blocks, <!-- confluence-toc --> TOC, GitHub-alert callouts/panels, expand, status, etc. (ac:parameter, ac:plain-text-body, ac:rich-text-body).
  • Imagesac:image + ri:attachment/ri:url (resolve ri:attachment against the local assets/ files so they render offline).
  • Links — internal doc links / anchors.

Unknown or unsupported tags should degrade gracefully (e.g. a labeled placeholder) rather than break the render.

Open questions / scope

  • Output: write an .html file, print to stdout, and/or open a browser? A --open flag?
  • Fidelity: how closely to mimic Confluence CSS — a lightweight stylesheet that captures layout columns, code blocks, and panels is probably enough to start; pixel-fidelity is a non-goal.
  • Source: preview a local markdown FILE (primary). Could also compose with read to preview a live page's storage (fetch → render) — worth considering but separable.
  • Macro coverage: start with layouts + code + callouts + images + TOC; expand as needed.

Related

  • Support --dry-run for update and create #11 (--dry-run) — complementary: dry-run previews actions, this previews appearance.
  • read subcommand — already fetches/round-trips storage; shares the storage-handling surface.

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