Skip to content

Walker emits malformed marker text for empty/missing macro parameters #140

@pchuri

Description

@pchuri

Summary

When a macro is missing the parameter the handler reads, the walker emits a marker with an empty interpolation slot, producing visibly broken markdown.

Cases

  1. Anchor without <ac:parameter>:

    • Input: <ac:structured-macro ac:name="anchor"></ac:structured-macro>
    • Output: **ANCHOR: ** (literal trailing space + empty id)
    • Expected: drop the macro entirely.
  2. Panel without title parameter:

    • Input: <ac:structured-macro ac:name="panel"><ac:rich-text-body><p>body</p></ac:rich-text-body></ac:structured-macro>
    • Output: > ****\n>\n> body
    • Expected: skip the title bold (> body only) or fall back to a default label.
  3. Code with neither language nor body:

    • Lower-priority cosmetic edge.

Why it matters

Real Confluence pages occasionally contain partially-authored macros (e.g. someone deleted a panel title in the editor). The walker should gracefully degrade rather than emit literally **** or **ANCHOR: **.

Proposed fix

Each handler that reads a parameter should guard explicitly:

```js
handleAnchor(node) {
const param = this.findParamByName(node, '');
const id = param ? this.getTextContent(param) : '';
if (!id) return ''; // Skip the macro instead of emitting an empty marker
return `\nANCHOR: ${id}\n`;
}
```

Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions