confluence-cli 1.33.3 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,6 +82,12 @@ class MacroConverter {
82
82
 
83
83
  storage = storage.replace(/<code>(.*?)<\/code>/g, '<code>$1</code>');
84
84
 
85
+ // **TOC** paragraph → Confluence Table of Contents macro (uses macro defaults)
86
+ storage = storage.replace(
87
+ /<p><strong>TOC<\/strong><\/p>/g,
88
+ '<ac:structured-macro ac:name="toc" />'
89
+ );
90
+
85
91
  storage = storage.replace(/<blockquote>(.*?)<\/blockquote>/gs, (_, content) => {
86
92
  if (content.includes('<strong>INFO</strong>')) {
87
93
  const cleanContent = content.replace(/<p><strong>INFO<\/strong><\/p>\s*/, '');
@@ -112,6 +118,26 @@ class MacroConverter {
112
118
  storage = storage.replace(/<th>(.*?)<\/th>/g, '<th><p>$1</p></th>');
113
119
  storage = storage.replace(/<td>(.*?)<\/td>/g, '<td><p>$1</p></td>');
114
120
 
121
+ // **ANCHOR: id** paragraph → Confluence anchor macro
122
+ storage = storage.replace(
123
+ /<p><strong>ANCHOR: (.*?)<\/strong><\/p>/g,
124
+ '<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">$1</ac:parameter></ac:structured-macro>'
125
+ );
126
+
127
+ // Same-page anchor links (href="#id") → ac:link with ac:anchor. Must run
128
+ // before the general link conversion below so the #id pattern is not
129
+ // consumed by the generic <a href> replacement (and so it works under
130
+ // all linkStyle modes, including "plain" which leaves <a> tags as-is).
131
+ storage = storage.replace(/<a href="#(.*?)">(.*?)<\/a>/gs, (_, anchor, body) => {
132
+ const text = body
133
+ .replace(/&amp;/g, '&')
134
+ .replace(/&lt;/g, '<')
135
+ .replace(/&gt;/g, '>')
136
+ .replace(/&quot;/g, '"')
137
+ .replace(/&#39;/g, '\'');
138
+ return `<ac:link ac:anchor="${anchor}"><ac:plain-text-link-body><![CDATA[${text}]]></ac:plain-text-link-body></ac:link>`;
139
+ });
140
+
115
141
  // Convert links based on linkStyle:
116
142
  // "smart" — Cloud smart links (<a data-card-appearance="inline">)
117
143
  // "plain" — simple <a href>; workaround for "Cannot handle: DefaultLink"
@@ -235,6 +261,14 @@ class MacroConverter {
235
261
  return `[!note]\n${cleanContent}`;
236
262
  });
237
263
 
264
+ // anchor macro → **ANCHOR: id** marker (round-trip with markdownToStorage).
265
+ // Must run before the generic <ac:structured-macro> catch-all below, which
266
+ // would otherwise drop the anchor entirely.
267
+ markdown = markdown.replace(
268
+ /<ac:structured-macro ac:name="anchor"[^>]*>[\s\S]*?<ac:parameter ac:name="">([\s\S]*?)<\/ac:parameter>[\s\S]*?<\/ac:structured-macro>/g,
269
+ '\n**ANCHOR: $1**\n'
270
+ );
271
+
238
272
  markdown = markdown.replace(/<ac:task-list>([\s\S]*?)<\/ac:task-list>/g, (_, content) => {
239
273
  const tasks = [];
240
274
  const taskRegex = /<ac:task>[\s\S]*?<ac:task-status>([^<]*)<\/ac:task-status>[\s\S]*?<ac:task-body>([\s\S]*?)<\/ac:task-body>[\s\S]*?<\/ac:task>/g;
@@ -291,6 +325,14 @@ class MacroConverter {
291
325
 
292
326
  markdown = markdown.replace(/<ac:structured-macro[^>]*>[\s\S]*?<\/ac:structured-macro>/g, '');
293
327
 
328
+ // ac:link with ac:anchor → [text](#id) (round-trip with markdownToStorage).
329
+ // Must run before the <ac:link[^>]*>…</ac:link> catch-all below, which
330
+ // would otherwise drop the anchor link entirely.
331
+ markdown = markdown.replace(
332
+ /<ac:link ac:anchor="([^"]*)">\s*<ac:plain-text-link-body><!\[CDATA\[([\s\S]*?)\]\]><\/ac:plain-text-link-body>\s*<\/ac:link>/g,
333
+ '[$2](#$1)'
334
+ );
335
+
294
336
  markdown = markdown.replace(/<ac:link><ri:url ri:value="([^"]*)" \/><ac:plain-text-link-body><!\[CDATA\[([^\]]*)\]\]><\/ac:plain-text-link-body><\/ac:link>/g, '[$2]($1)');
295
337
 
296
338
  markdown = markdown.replace(/<ac:link>\s*<ri:page[^>]*ri:content-title="([^"]*)"[^>]*\/>\s*<\/ac:link>/g, '[$1]');
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "confluence-cli",
3
- "version": "1.33.3",
3
+ "version": "1.35.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "confluence-cli",
9
- "version": "1.33.3",
9
+ "version": "1.35.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "axios": "^1.15.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "confluence-cli",
3
- "version": "1.33.3",
3
+ "version": "1.35.0",
4
4
  "description": "A command-line interface for Atlassian Confluence with page creation and editing capabilities",
5
5
  "main": "index.js",
6
6
  "bin": {