~bigbes/confluence-md-utilities

f6c846a1 — Eugene Blikh a month ago
fix: preserve inline spacing in fmt and code-block round-trip

Three related round-trip/formatting bugs, each pinned by a regression test
that fails on the prior code:

- fmt dropped the significant space between two inline elements
  (</strong> <code>): a lone-space text node was always treated as
  indentation. Keep it mid-line; drop it only at a block boundary.
- fmt's line-wrapper dropped a word's trailing space before a tag
  (strings.Fields discards it) and broke inside <code>...</code>,
  injecting indent that xml2md collapses into a spurious in-span space.
  Rewrote wrapLine around an atom model with a per-atom spaceBefore flag
  and keeps an inline code span whole.
- verify.normalizeForVerify's reBareTextAfterHeading used \S for its
  "visible char" token; \S matches '<', so the capture swallowed a
  following <ac:structured-macro> and wrapped it in <p>...</p>, splitting
  a code macro from its body and breaking round-trip for a no-language
  fenced code block after a heading. Use [^\s<] instead.

Full RFC-0010 document now verifies as lossless.
442bf598 — Eugene Blikh 2 months ago
fix: round-trip fidelity for tables, page links, and nested lists

Four real-document failures surfaced via `mdcx verify`:

- Pipes inside `<code>` in GFM table cells were treated as column
  separators, splitting cells. `writeTableRow` now escapes `|` as `\|`
  per the GFM spec; the parser strips the backslash before inline
  parsing so the pipe survives inside the resulting code span.
- Two `<code>` elements separated by whitespace text were being merged
  because `isPrev/NextSiblingCode` skipped whitespace nodes. Adjacency
  is now strict.
- `<ac:link><ri:page …/></ac:link>` was dropped because goldmark cannot
  parse `<ac:link>` as raw inline HTML (the colon disqualifies it).
  Preserved via a `<span data-page-link …>` placeholder; the inverse is
  driven by a new `pageLinkDepth` counter in the renderer.
- Nested `<ol>` collapsed to a flat list and went loose because the
  fixed `2*(depth-1)` indent didn't satisfy CommonMark's column rule
  for ordered markers and a stray `\n` after each `<li>` made the list
  loose. Indent is now a per-level stack (3 for ol, 2 for ul/task) and
  list-item terminators use `ensureSingleNewline`.

Regression tests in converter/md2xml_test.go pin each fix; CLAUDE.md
documents the gotchas.
701c5ef2 — Eugene Blikh 2 months ago
feat: improve round-trip fidelity for panels, tables, and verify

- Preserve panel name (info/note/warning), macro-id, parameters, and
  body-bare layout via HTML comment markers so blockquotes round-trip
  back to the original ac:structured-macro form.
- Serialize tables with complex cell content (nested lists, structured
  macros, row-header th, page links) as raw XML inside the markdown so
  GFM table limits don't lossily flatten them.
- Distinguish ac:toc inside <p> from bare ac:toc, restoring the wrapper.
- Strip inline-comment-marker wrappers and decorative <span>s inside
  code spans where markdown can't represent them.
- Normalize self-closing tags to "<tag />" and unify &#34;/&#39; with
  &quot;/' so the pretty printer doesn't introduce cosmetic diffs.
- Apply verify normalization to both input and round-trip output, and
  add rules for trailing whitespace, <br/> before </li>, <p>-wrapped
  image runs, and bare text after headings.
66a3cf57 — Eugene Blikh 2 months ago
feat: split convert into md2xml and xml2md commands

Replace the single convert command with two directional commands:
md2xml for Markdown→Confluence XML and xml2md for the reverse.
Update completions and README accordingly.
b3d83904 — Eugene Blikh 2 months ago
feat: add pull --with-comments sidecar

`mdcx pull --with-comments` fetches inline + page comments via
`/rest/api/content/{id}/child/comment` (paginated, two-level reply
expansion) and writes them to `<output>.comments.json` alongside the
Markdown file. Inline comments correlate to the markdown's
`data-inline-comment="UUID"` spans through their `marker_ref` field.

Comment bodies are stored as raw Confluence storage XML; pushing
comments back is not implemented. Requires `--output`.
798bc95f — Eugene Blikh 2 months ago
feat: preview and confirm before push

`mdcx push` now prints the exact PUT request (URL, masked auth header,
title, version bump, body size delta, and a 20-line body excerpt) and
prompts for confirmation before sending. Add `--yes`/`-y` to skip the
prompt and `--dry-run` to preview only. Non-interactive stdin without
`--yes` errors out instead of hanging.

Splits `Client.UpdateContent` into `BuildUpdate` + send so the CLI can
render the same payload that will be transmitted.
e0e81bc6 — Eugene Blikh 3 months ago v0.1.0
chore: rename module to go.bigb.es/confluence-md-utilities
5fabfe01 — Eugene Blikh 3 months ago
feat: add verify command, improve round-trip fidelity

Add verify command for XML validation. Merge adjacent <code> elements
during XML→MD conversion. Preserve macro attribute order for round-trip
fidelity. Fix list item trailing whitespace and normalize <hr /> format.

false
0d193103 — Eugene Blikh 4 months ago
feat: add ability for local install
46926399 — Eugene Blikh 4 months ago
Move CLI to cmd/mdcx/, add justfile and CLAUDE.md

Restructure to standard Go project layout: merge package cmd
into package main under cmd/mdcx/. Fix .gitignore to use /mdcx
so it only ignores the binary at repo root. Update install path
in README.md.

false
57679c6f — Eugene Blikh 4 months ago
Rename module, add features, fix round-trip fidelity

- Rename module to sourcecraft.dev/bigbes/confluence-md-utilities
- Add fmt command with syntax highlighting (--color=auto/force/disabled)
- Add shell completions for all commands with file extension hints
- Preserve ac:layout/ac:layout-section/ac:layout-cell through round-trips
- Preserve ac:macro-id on code blocks and TOC macros
- Preserve table class/style attributes and colgroup column widths
- Preserve TOC macro as <!-- ac:toc --> comment
- Fix table cell rendering to preserve bold, italic, code, br, links
- Fix user references (ri:userkey) and attachment images (ri:attachment)
- Fix inline spacing between formatting elements in list items

false
fb67f698 — Eugene Blikh 4 months ago
Initial commit: mdcx — Markdown to Confluence XML converter

Bidirectional converter between Markdown and Confluence storage format XML
with self-hosted Confluence Server/Data Center sync support.

Features:
- convert: Markdown → Confluence XML
- extract: Confluence XML → Markdown
- embed: embed Markdown into Confluence XML template (marker-based)
- pull/push: sync pages with Confluence via REST API + PAT auth
- fmt: pretty-print Confluence XML with sensible indentation
- Round-trip preservation of inline comments, user refs, attachment images

false