~bigbes/confluence-md-utilities

ref: 3c0272ac2232ee3a0edd0c259b71e9fd3384f211 confluence-md-utilities/confluence/renderer.go -rw-r--r-- 22.4 KiB
3c0272ac — Eugene Blikh a month ago
fix: round-trip fidelity for heading comments, literal tags, and emphasis

Surfaced by `verify` on two real documents that aren't in the justfile set.

- Heading-only HTML comment (a TOC macro marker, `<h1><!-- ac:toc ... --></h1>`)
  was dropped by xml2md — a CommentNode is neither text nor element, so it fell
  through walkChildren and vanished, collapsing `# <!-- ... -->` to `#`.
- Literal angle-bracket text stored as `&lt;table&gt;` (e.g. `box.backup.start(<table>)`)
  round-tripped into a phantom `<table>` element that swallowed the rest of the
  document: xml2md now backslash-escapes a tag-like `<` in both the TextNode and
  walkChildrenInline paths, and renderText unescapes only `\<` (never a blanket
  UnescapePunctuations, which would eat the deliberate `\|` table-pipe escaping).
- `<strong> x </strong>` (whitespace inside the markers) rendered as literal
  `** x **`; writeEmphasis now moves the whitespace outside the markers.
- normalizeForVerify canonicalizes values Markdown can't carry — task ids,
  <ul>/<ol> bullet styling, and a trailing nbsp before </ac:task-body>.

Adds regression tests for each and documents the new gotchas in CLAUDE.md.
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.
5fabfe01 — Eugene Blikh 4 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
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