Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CLAUDE.md

Large diffs are not rendered by default.

31 changes: 8 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ reach for.
| [`create`](docs/commands/markfluence_create.md) | make new pages from files that have no `page_id` yet. Checks every file first, and creates nothing if any would fail |
| [`update`](docs/commands/markfluence_update.md) | republish files that already have a `page_id`. Skips a file that has not changed |
| [`check`](docs/commands/markfluence_check.md) | validate files with no network and no credentials — dead links, broken images, bad frontmatter |
| [`fix`](docs/commands/markfluence_fix.md) | reconcile a file's frontmatter *from* its live page, when the two have drifted |

**Getting things out of Confluence:**

Expand Down Expand Up @@ -227,7 +226,8 @@ everything else:

And [`schema`](docs/commands/markfluence_schema.md) prints the `--json` schema.

Every command takes `--json`; `create`, `update` and `fix` take `--dry-run`.
Every command takes `--json`. `create`, `update`, `export`, `attachment-upload`
and `attachment-download` take `--dry-run`.

### Common workflows

Expand Down Expand Up @@ -281,26 +281,11 @@ markfluence check docs/*.md docs/**/*.md
markfluence update docs/*.md docs/**/*.md
```

Pick up changes somebody made in Confluence. This is the one command that
writes *to* your files *from* Confluence — every other one goes the other way:

```sh
# what disagrees? nothing is written
markfluence fix docs/*.md --dry-run

# reconcile page_id, space, parent, page_width, labels and a missing title
markfluence fix docs/*.md
```

`fix` never creates, updates or moves pages — it is read-only on the server.
Note the asymmetry it settles: `update` leaves a field alone when your file does
not mention it, while `fix` fills that field in from the page. It is how you
adopt a page somebody labeled in the UI, or one you published by hand and want
a file for.

One thing it does *not* do: a `title` you have already set is left alone, so a
page renamed in Confluence does not rename your frontmatter. Only a missing or
blank `title` is filled in.
Pick up changes somebody made in Confluence. Every command that writes goes one
way — your files to the page — so this direction is a read plus an edit: `info`
shows a page's labels and width, `read` prints it as markdown, and `export`
writes the whole thing to disk, frontmatter included. Nothing rewrites an
existing file's frontmatter from a page.

### What the output looks like

Expand Down Expand Up @@ -424,7 +409,7 @@ from it — without reading it out of this repository:

```console
$ markfluence schema | jq -r '.properties.command.enum | join(" ")'
info read update create fix children find search attachment-list attachment-upload attachment-download export
info read update create check children find search attachment-list attachment-upload attachment-download export

$ markfluence update docs/*.md --json > out.json
$ markfluence schema > schema.json
Expand Down
312 changes: 312 additions & 0 deletions _plans/040_remove-fix.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion cmd/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ func processFile(filename string, roots *project.Cache, indexes *linkindex.Cache
// project that has chosen the manifest. A *warning*, never an error, and
// that is the whole point -- agreement between the two locations is legal,
// so this has to be sayable without becoming a wall somebody hits halfway
// through a migration. `fix` moving the keys is the remedy.
// through a migration. The remedy is manual -- move the keys into the entry
// by hand -- and deliberately so: nothing writes an existing file's
// frontmatter for you now that `fix` is gone (#151), and `fix` never
// actually moved them into the manifest anyway, it refused the file.
if pagemeta.HasManifest(root) && meta.InFile() {
r.warnings = append(r.warnings, fmt.Sprintf(
"this file carries markfluence frontmatter in a project that keeps page "+
Expand Down
12 changes: 7 additions & 5 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ func checkPageID(c *client.ConfluenceClient, pageID string) error {
// is free to create against. page is nil when the id resolves to nothing.
func pageIDFailureFor(c *client.ConfluenceClient, pageID string, page *client.Page) error {
if page == nil {
// Wording mirrors fix's locatePage, which reports the same condition; only
// the remedy differs, since removing the id here means "create a new page".
// pageref owns the wording so update reports the same condition the same
// way; only the remedy differs, since removing the id here means
// "create a new page".
return &pageIDFailure{
pageID: pageID,
message: pageref.NotFoundMessage(pageID, "remove it to create a new page, or correct it"),
Expand Down Expand Up @@ -1122,9 +1123,10 @@ func overrideNeedsSingleFile(cliTitle string, nFiles int) bool {
}

// writeBackFrontmatter sets every field create persists, then normalizes the
// block's field order. Normalizing here rather than leaving it to fix costs
// nothing: persist already rewrites all five fields, so there is no untouched
// line left for a surgical edit to protect.
// block's field order. Normalizing here costs nothing: persist already rewrites
// all five fields, so there is no untouched line left for a surgical edit to
// protect. It is also the only place left that reorders a block -- no verb
// reconciles a file from its page any more (#151).
func writeBackFrontmatter(content string, r record, pageID, parentValue, parentComment string) (string, error) {
fields := []struct{ key, value, comment string }{
{"title", r.title, ""},
Expand Down
Loading