markdown-to-confluence 0.3.4__tar.gz → 0.4.0__tar.gz

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.
Files changed (39) hide show
  1. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/PKG-INFO +131 -14
  2. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/README.md +122 -7
  3. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/PKG-INFO +131 -14
  4. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/SOURCES.txt +5 -1
  5. markdown_to_confluence-0.4.0/markdown_to_confluence.egg-info/requires.txt +13 -0
  6. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/__init__.py +1 -1
  7. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/__main__.py +18 -7
  8. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/api.py +492 -187
  9. markdown_to_confluence-0.4.0/md2conf/application.py +225 -0
  10. markdown_to_confluence-0.4.0/md2conf/collection.py +31 -0
  11. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/converter.py +51 -112
  12. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/emoji.py +28 -3
  13. markdown_to_confluence-0.4.0/md2conf/extra.py +14 -0
  14. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/local.py +33 -45
  15. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/matcher.py +54 -13
  16. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/mermaid.py +10 -4
  17. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/metadata.py +1 -3
  18. markdown_to_confluence-0.4.0/md2conf/processor.py +312 -0
  19. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/properties.py +24 -5
  20. markdown_to_confluence-0.4.0/md2conf/scanner.py +149 -0
  21. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/setup.cfg +8 -6
  22. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/tests/test_conversion.py +20 -16
  23. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/tests/test_matcher.py +6 -0
  24. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/tests/test_mermaid.py +3 -0
  25. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/tests/test_processor.py +7 -1
  26. markdown_to_confluence-0.4.0/tests/test_scanner.py +58 -0
  27. markdown_to_confluence-0.3.4/markdown_to_confluence.egg-info/requires.txt +0 -9
  28. markdown_to_confluence-0.3.4/md2conf/application.py +0 -208
  29. markdown_to_confluence-0.3.4/md2conf/processor.py +0 -218
  30. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/LICENSE +0 -0
  31. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/dependency_links.txt +0 -0
  32. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/entry_points.txt +0 -0
  33. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/top_level.txt +0 -0
  34. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/markdown_to_confluence.egg-info/zip-safe +0 -0
  35. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/entities.dtd +0 -0
  36. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/puppeteer-config.json +0 -0
  37. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/md2conf/py.typed +0 -0
  38. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/pyproject.toml +0 -0
  39. {markdown_to_confluence-0.3.4 → markdown_to_confluence-0.4.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-to-confluence
3
- Version: 0.3.4
3
+ Version: 0.4.0
4
4
  Summary: Publish Markdown files to Confluence wiki
5
5
  Home-page: https://github.com/hunyadi/md2conf
6
6
  Author: Levente Hunyadi
@@ -21,15 +21,17 @@ Classifier: Typing :: Typed
21
21
  Requires-Python: >=3.9
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: lxml>=5.3
25
- Requires-Dist: types-lxml>=2024.12.13
26
- Requires-Dist: markdown>=3.7
27
- Requires-Dist: types-markdown>=3.7
28
- Requires-Dist: pymdown-extensions>=10.14
29
- Requires-Dist: pyyaml>=6.0
24
+ Requires-Dist: json_strong_typing>=0.3.9
25
+ Requires-Dist: lxml>=5.4
26
+ Requires-Dist: types-lxml>=2025.3.30
27
+ Requires-Dist: markdown>=3.8
28
+ Requires-Dist: types-markdown>=3.8
29
+ Requires-Dist: pymdown-extensions>=10.16
30
+ Requires-Dist: PyYAML>=6.0
30
31
  Requires-Dist: types-PyYAML>=6.0
31
32
  Requires-Dist: requests>=2.32
32
33
  Requires-Dist: types-requests>=2.32
34
+ Requires-Dist: typing_extensions>=4.14; python_version < "3.12"
33
35
  Dynamic: license-file
34
36
 
35
37
  # Publish Markdown files to Confluence wiki
@@ -49,7 +51,10 @@ This Python package
49
51
  * Sections and subsections
50
52
  * Text with **bold**, *italic*, `monospace`, <ins>underline</ins> and ~~strikethrough~~
51
53
  * Link to [sections on the same page](#getting-started) or [external locations](http://example.com/)
54
+ * Subscript and superscript (with HTML tags `<sub>` and `<sup>`)
55
+ * Emoji
52
56
  * Ordered and unordered lists
57
+ * Block quotes
53
58
  * Code blocks (e.g. Python, JSON, XML)
54
59
  * Images (uploaded as Confluence page attachments or hosted externally)
55
60
  * Tables
@@ -95,7 +100,7 @@ In order to get started, you will need
95
100
 
96
101
  Confluence organization domain, base path, username, API token and space key can be specified at runtime or set as Confluence environment variables (e.g. add to your `~/.profile` on Linux, or `~/.bash_profile` or `~/.zshenv` on MacOS):
97
102
 
98
- ```bash
103
+ ```sh
99
104
  export CONFLUENCE_DOMAIN='example.atlassian.net'
100
105
  export CONFLUENCE_PATH='/wiki/'
101
106
  export CONFLUENCE_USER_NAME='levente.hunyadi@instructure.com'
@@ -105,10 +110,29 @@ export CONFLUENCE_SPACE_KEY='SPACE'
105
110
 
106
111
  On Windows, these can be set via system properties.
107
112
 
113
+ If you use Atlassian scoped API tokens, you should set API URL, substituting `CLOUD_ID` with your own Cloud ID:
114
+
115
+ ```sh
116
+ export CONFLUENCE_API_URL='https://api.atlassian.com/ex/confluence/CLOUD_ID/'
117
+ ```
118
+
119
+ In this case, *md2conf* can automatically determine `CONFLUENCE_DOMAIN` and `CONFLUENCE_PATH`.
120
+
108
121
  ### Permissions
109
122
 
110
123
  The tool requires appropriate permissions in Confluence in order to invoke endpoints.
111
124
 
125
+ Required scopes for scoped API tokens are as follows:
126
+
127
+ * `read:page:confluence`
128
+ * `write:page:confluence`
129
+ * `read:space:confluence`
130
+ * `write:space:confluence`
131
+ * `read:attachment:confluence`
132
+ * `write:attachment:confluence`
133
+ * `read:label:confluence`
134
+ * `write:label:confluence`
135
+
112
136
  If a Confluence username is set, the tool uses HTTP *Basic* authentication to pass the username and the API key to Confluence REST API endpoints. If no username is provided, the tool authenticates with HTTP *Bearer*, and passes the API key as the bearer token.
113
137
 
114
138
  If you lack appropriate permissions, you will get an *Unauthorized* response from Confluence. The tool will emit a message that looks as follows:
@@ -198,30 +222,110 @@ root
198
222
  └── Mean vs. median
199
223
  ```
200
224
 
225
+ ### Emoji
226
+
227
+ The short name notation `:smile:` in a Markdown document is converted into the corresponding emoji 😄 when publishing to Confluence.
228
+
229
+ *md2conf* relies on the [Emoji extension](https://facelessuser.github.io/pymdown-extensions/extensions/emoji/) of [PyMdown Extensions](https://facelessuser.github.io/pymdown-extensions/) to parse the short name notation with colons, and generate Confluence Storage Format output such as
230
+
231
+ ```xml
232
+ <ac:emoticon ac:name="smile" ac:emoji-shortname=":smile:" ac:emoji-id="1f604" ac:emoji-fallback="&#128516;"/>
233
+ ```
234
+
235
+ ### Colors
236
+
237
+ Confluence allows setting text color and highlight color. Even though Markdown doesn't directly support colors, it is possible to set text and highlight color via the HTML element `<span>` and the CSS attributes `color` and `background-color`, respectively:
238
+
239
+ Text in <span style="color: rgb(255,86,48);">red</span>, <span style="color: rgb(54,179,126);">green</span> and <span style="color: rgb(76,154,255);">blue</span>:
240
+
241
+ ```markdown
242
+ Text in <span style="color: rgb(255,86,48);">red</span>, <span style="color: rgb(54,179,126);">green</span> and <span style="color: rgb(76,154,255);">blue</span>.
243
+ ```
244
+
245
+ Highlight in <span style="background-color: rgb(198,237,251);">teal</span>, <span style="background-color: rgb(211,241,167);">lime</span> and <span style="background-color: rgb(254,222,200);">yellow</span>:
246
+
247
+ ```markdown
248
+ Highlight in <span style="background-color: rgb(198,237,251);">teal</span>, <span style="background-color: rgb(211,241,167);">lime</span> and <span style="background-color: rgb(254,222,200);">yellow</span>.
249
+ ```
250
+
251
+ The following table shows standard text colors (CSS `color`) that are available via Confluence UI:
252
+
253
+ | Color name | CSS attribute value |
254
+ | ------------- | ------------------- |
255
+ | bold blue | rgb(7,71,166) |
256
+ | blue | rgb(76,154,255) |
257
+ | subtle blue | rgb(179,212,255) |
258
+ | bold teal | rgb(0,141,166) |
259
+ | teal | rgb(0,184,217) |
260
+ | subtle teal | rgb(179,245,255) |
261
+ | bold green | rgb(0,102,68) |
262
+ | green | rgb(54,179,126) |
263
+ | subtle green | rgb(171,245,209) |
264
+ | bold orange | rgb(255,153,31) |
265
+ | yellow | rgb(255,196,0) |
266
+ | subtle yellow | rgb(255,240,179) |
267
+ | bold red | rgb(191,38,0) |
268
+ | red | rgb(255,86,48) |
269
+ | subtle red | rgb(255,189,173) |
270
+ | bold purple | rgb(64,50,148) |
271
+ | purple | rgb(101,84,192) |
272
+ | subtle purple | rgb(234,230,255) |
273
+
274
+ The following table shows standard highlight colors (CSS `background-color`) that are available via Confluence UI:
275
+
276
+ | Color name | CSS attribute value |
277
+ | ------------- | ------------------- |
278
+ | teal | rgb(198,237,251) |
279
+ | lime | rgb(211,241,167) |
280
+ | yellow | rgb(254,222,200) |
281
+ | magenta | rgb(253,208,236) |
282
+ | purple | rgb(223,216,253) |
283
+
284
+ ### Lists and tables
285
+
286
+ If your Markdown lists or tables don't appear in Confluence as expected, verify that the list or table is delimited by a blank line both before and after, as per strict Markdown syntax. While some previewers accept a more lenient syntax (e.g. an itemized list immediately following a paragraph), *md2conf* uses [Python-Markdown](https://python-markdown.github.io/) internally to convert Markdown into XHTML, which expects the Markdown document to adhere to the stricter syntax.
287
+
201
288
  ### Publishing images
202
289
 
203
290
  Local images referenced in a Markdown file are automatically published to Confluence as attachments to the page.
204
291
 
205
- Unfortunately, Confluence struggles with SVG images, e.g. they may only show in *edit* mode, display in a wrong size or text labels in the image may be truncated. In order to mitigate the issue, whenever *md2conf* encounters a reference to an SVG image in a Markdown file, it checks whether a corresponding PNG image also exists in the same directory, and if a PNG image is found, it is published instead.
292
+ Unfortunately, Confluence struggles with SVG images, e.g. they may only show in *edit* mode, display in a wrong size or text labels in the image may be truncated. (This seems to be a known issue in Confluence.) In order to mitigate the issue, whenever *md2conf* encounters a reference to an SVG image in a Markdown file, it checks whether a corresponding PNG image also exists in the same directory, and if a PNG image is found, it is published instead.
206
293
 
207
294
  External images referenced with an absolute URL retain the original URL.
208
295
 
209
296
  ### Ignoring files
210
297
 
211
- Skip files in a directory with rules defined in `.mdignore`. Each rule should occupy a single line. Rules follow the syntax of [fnmatch](https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch). Specifically, `?` matches any single character, and `*` matches zero or more characters. For example, use `up-*.md` to exclude Markdown files that start with `up-`. Lines that start with `#` are treated as comments.
298
+ Skip files in a directory with rules defined in `.mdignore`. Each rule should occupy a single line. Rules follow the syntax (and constraints) of [fnmatch](https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch). Specifically, `?` matches any single character, and `*` matches zero or more characters. For example, use `up-*.md` to exclude Markdown files that start with `up-`. Lines that start with `#` are treated as comments.
212
299
 
213
300
  Files that don't have the extension `*.md` are skipped automatically. Hidden directories (whose name starts with `.`) are not recursed into.
214
301
 
302
+ Relative paths to items in a nested directory are not supported. You must put `.mdignore` in the same directory where the items to be skipped reside.
303
+
215
304
  ### Page title
216
305
 
217
306
  *md2conf* makes a best-effort attempt at setting the Confluence wiki page title when it publishes a Markdown document the first time. The following are probed in this order:
218
307
 
219
- 1. The `title` attribute set in the [front-matter](https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/). Front-matter is a block delimited by `---` at the beginning of a Markdown document. Currently, only YAML syntax is supported.
308
+ 1. The `title` attribute set in the [front-matter](https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/). Front-matter is a block delimited by `---` at the beginning of a Markdown document. Both JSON and YAML syntax are supported.
220
309
  2. The text of the topmost unique Markdown heading (`#`). For example, if a document has a single first-level heading (e.g. `# My document`), its text is used. However, if there are multiple first-level headings, this step is skipped.
221
310
  3. The file name (without the extension `.md`).
222
311
 
223
312
  If a matching Confluence page already exists for a Markdown file, the page title in Confluence is left unchanged.
224
313
 
314
+ ### Labels
315
+
316
+ If a Markdown document has the front-matter attribute `tags`, *md2conf* assigns the specified tags to the Confluence page as labels.
317
+
318
+ ```yaml
319
+ ---
320
+ title: "Example document"
321
+ tags: ["markdown", "md", "wiki"]
322
+ ---
323
+ ```
324
+
325
+ Any previously assigned labels are discarded. As per Confluence terminology, new labels have the `prefix` of `global`.
326
+
327
+ If a document has no `tags` attribute, existing Confluence labels are left intact.
328
+
225
329
  ### Converting diagrams
226
330
 
227
331
  You can include [Mermaid diagrams](https://mermaid.js.org/) in your Markdown documents to create visual representations of systems, processes, and relationships. When a Markdown document contains a code block with the language specifier `mermaid`, *md2conf* offers two options to publish the diagram:
@@ -229,6 +333,18 @@ You can include [Mermaid diagrams](https://mermaid.js.org/) in your Markdown doc
229
333
  1. Pre-render into an image. The code block is interpreted by and converted into a PNG or SVG image with the Mermaid diagram utility [mermaid-cli](https://github.com/mermaid-js/mermaid-cli). The generated image is then uploaded to Confluence as an attachment to the page. This is the approach we use and support.
230
334
  2. Render on demand. The code block is transformed into a [diagram macro](https://atlasauthority.atlassian.net/wiki/spaces/MARKDOWNCLOUD/pages/2946826241/Diagram+Macro), which is processed by Confluence. You need a [Confluence plugin](https://marketplace.atlassian.com/apps/1211438/markdown-html-plantuml-latex-diagrams-open-api-mermaid) to turn macro definitions into images when a Confluence page is visited. This is a contributed feature. As authors of *md2conf*, we don't endorse or support any particular Confluence plugin.
231
335
 
336
+ If you are running into issues with the pre-rendering approach (e.g. misaligned labels in the generated image), verify if `mermaid-cli` can process the Mermaid source:
337
+
338
+ ```sh
339
+ mmdc -i sample.mmd -o sample.png -b transparent --scale 2
340
+ ```
341
+
342
+ Ensure that `mermaid-cli` is set up, refer to *Installation* for instructions.
343
+
344
+ ### Local output
345
+
346
+ *md2conf* supports local output, in which the tool doesn't communicate with the Confluence REST API. Instead, it reads a single Markdown file or a directory of Markdown files, and writes Confluence Storage Format (`*.csf`) output for each document. (Confluence Storage Format is a derivative of XHTML with Confluence-specific tags for complex elements such as images with captions, code blocks, info panels, collapsed sections, etc.) You can push the generated output to Confluence by invoking the API (e.g. with `curl`).
347
+
232
348
  ### Running the tool
233
349
 
234
350
  You execute the command-line tool `md2conf` to synchronize the Markdown file with Confluence:
@@ -241,8 +357,8 @@ Use the `--help` switch to get a full list of supported command-line options:
241
357
 
242
358
  ```console
243
359
  $ python3 -m md2conf --help
244
- usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--keep-hierarchy] [--generated-by GENERATED_BY] [--no-generated-by]
245
- [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
360
+ usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [--api-url API_URL] [-u USERNAME] [-a API_KEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--keep-hierarchy] [--generated-by GENERATED_BY]
361
+ [--no-generated-by] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
246
362
  mdpath
247
363
 
248
364
  positional arguments:
@@ -254,9 +370,10 @@ options:
254
370
  -d DOMAIN, --domain DOMAIN
255
371
  Confluence organization domain.
256
372
  -p PATH, --path PATH Base path for Confluence (default: '/wiki/').
373
+ --api-url API_URL Confluence API URL. Required for scoped tokens. Refer to documentation how to obtain one.
257
374
  -u USERNAME, --username USERNAME
258
375
  Confluence user name.
259
- -a APIKEY, --apikey APIKEY
376
+ -a API_KEY, --apikey API_KEY, --api-key API_KEY
260
377
  Confluence API key. Refer to documentation how to obtain one.
261
378
  -s SPACE, --space SPACE
262
379
  Confluence space key for pages to be published. If omitted, will default to user space.
@@ -15,7 +15,10 @@ This Python package
15
15
  * Sections and subsections
16
16
  * Text with **bold**, *italic*, `monospace`, <ins>underline</ins> and ~~strikethrough~~
17
17
  * Link to [sections on the same page](#getting-started) or [external locations](http://example.com/)
18
+ * Subscript and superscript (with HTML tags `<sub>` and `<sup>`)
19
+ * Emoji
18
20
  * Ordered and unordered lists
21
+ * Block quotes
19
22
  * Code blocks (e.g. Python, JSON, XML)
20
23
  * Images (uploaded as Confluence page attachments or hosted externally)
21
24
  * Tables
@@ -61,7 +64,7 @@ In order to get started, you will need
61
64
 
62
65
  Confluence organization domain, base path, username, API token and space key can be specified at runtime or set as Confluence environment variables (e.g. add to your `~/.profile` on Linux, or `~/.bash_profile` or `~/.zshenv` on MacOS):
63
66
 
64
- ```bash
67
+ ```sh
65
68
  export CONFLUENCE_DOMAIN='example.atlassian.net'
66
69
  export CONFLUENCE_PATH='/wiki/'
67
70
  export CONFLUENCE_USER_NAME='levente.hunyadi@instructure.com'
@@ -71,10 +74,29 @@ export CONFLUENCE_SPACE_KEY='SPACE'
71
74
 
72
75
  On Windows, these can be set via system properties.
73
76
 
77
+ If you use Atlassian scoped API tokens, you should set API URL, substituting `CLOUD_ID` with your own Cloud ID:
78
+
79
+ ```sh
80
+ export CONFLUENCE_API_URL='https://api.atlassian.com/ex/confluence/CLOUD_ID/'
81
+ ```
82
+
83
+ In this case, *md2conf* can automatically determine `CONFLUENCE_DOMAIN` and `CONFLUENCE_PATH`.
84
+
74
85
  ### Permissions
75
86
 
76
87
  The tool requires appropriate permissions in Confluence in order to invoke endpoints.
77
88
 
89
+ Required scopes for scoped API tokens are as follows:
90
+
91
+ * `read:page:confluence`
92
+ * `write:page:confluence`
93
+ * `read:space:confluence`
94
+ * `write:space:confluence`
95
+ * `read:attachment:confluence`
96
+ * `write:attachment:confluence`
97
+ * `read:label:confluence`
98
+ * `write:label:confluence`
99
+
78
100
  If a Confluence username is set, the tool uses HTTP *Basic* authentication to pass the username and the API key to Confluence REST API endpoints. If no username is provided, the tool authenticates with HTTP *Bearer*, and passes the API key as the bearer token.
79
101
 
80
102
  If you lack appropriate permissions, you will get an *Unauthorized* response from Confluence. The tool will emit a message that looks as follows:
@@ -164,30 +186,110 @@ root
164
186
  └── Mean vs. median
165
187
  ```
166
188
 
189
+ ### Emoji
190
+
191
+ The short name notation `:smile:` in a Markdown document is converted into the corresponding emoji 😄 when publishing to Confluence.
192
+
193
+ *md2conf* relies on the [Emoji extension](https://facelessuser.github.io/pymdown-extensions/extensions/emoji/) of [PyMdown Extensions](https://facelessuser.github.io/pymdown-extensions/) to parse the short name notation with colons, and generate Confluence Storage Format output such as
194
+
195
+ ```xml
196
+ <ac:emoticon ac:name="smile" ac:emoji-shortname=":smile:" ac:emoji-id="1f604" ac:emoji-fallback="&#128516;"/>
197
+ ```
198
+
199
+ ### Colors
200
+
201
+ Confluence allows setting text color and highlight color. Even though Markdown doesn't directly support colors, it is possible to set text and highlight color via the HTML element `<span>` and the CSS attributes `color` and `background-color`, respectively:
202
+
203
+ Text in <span style="color: rgb(255,86,48);">red</span>, <span style="color: rgb(54,179,126);">green</span> and <span style="color: rgb(76,154,255);">blue</span>:
204
+
205
+ ```markdown
206
+ Text in <span style="color: rgb(255,86,48);">red</span>, <span style="color: rgb(54,179,126);">green</span> and <span style="color: rgb(76,154,255);">blue</span>.
207
+ ```
208
+
209
+ Highlight in <span style="background-color: rgb(198,237,251);">teal</span>, <span style="background-color: rgb(211,241,167);">lime</span> and <span style="background-color: rgb(254,222,200);">yellow</span>:
210
+
211
+ ```markdown
212
+ Highlight in <span style="background-color: rgb(198,237,251);">teal</span>, <span style="background-color: rgb(211,241,167);">lime</span> and <span style="background-color: rgb(254,222,200);">yellow</span>.
213
+ ```
214
+
215
+ The following table shows standard text colors (CSS `color`) that are available via Confluence UI:
216
+
217
+ | Color name | CSS attribute value |
218
+ | ------------- | ------------------- |
219
+ | bold blue | rgb(7,71,166) |
220
+ | blue | rgb(76,154,255) |
221
+ | subtle blue | rgb(179,212,255) |
222
+ | bold teal | rgb(0,141,166) |
223
+ | teal | rgb(0,184,217) |
224
+ | subtle teal | rgb(179,245,255) |
225
+ | bold green | rgb(0,102,68) |
226
+ | green | rgb(54,179,126) |
227
+ | subtle green | rgb(171,245,209) |
228
+ | bold orange | rgb(255,153,31) |
229
+ | yellow | rgb(255,196,0) |
230
+ | subtle yellow | rgb(255,240,179) |
231
+ | bold red | rgb(191,38,0) |
232
+ | red | rgb(255,86,48) |
233
+ | subtle red | rgb(255,189,173) |
234
+ | bold purple | rgb(64,50,148) |
235
+ | purple | rgb(101,84,192) |
236
+ | subtle purple | rgb(234,230,255) |
237
+
238
+ The following table shows standard highlight colors (CSS `background-color`) that are available via Confluence UI:
239
+
240
+ | Color name | CSS attribute value |
241
+ | ------------- | ------------------- |
242
+ | teal | rgb(198,237,251) |
243
+ | lime | rgb(211,241,167) |
244
+ | yellow | rgb(254,222,200) |
245
+ | magenta | rgb(253,208,236) |
246
+ | purple | rgb(223,216,253) |
247
+
248
+ ### Lists and tables
249
+
250
+ If your Markdown lists or tables don't appear in Confluence as expected, verify that the list or table is delimited by a blank line both before and after, as per strict Markdown syntax. While some previewers accept a more lenient syntax (e.g. an itemized list immediately following a paragraph), *md2conf* uses [Python-Markdown](https://python-markdown.github.io/) internally to convert Markdown into XHTML, which expects the Markdown document to adhere to the stricter syntax.
251
+
167
252
  ### Publishing images
168
253
 
169
254
  Local images referenced in a Markdown file are automatically published to Confluence as attachments to the page.
170
255
 
171
- Unfortunately, Confluence struggles with SVG images, e.g. they may only show in *edit* mode, display in a wrong size or text labels in the image may be truncated. In order to mitigate the issue, whenever *md2conf* encounters a reference to an SVG image in a Markdown file, it checks whether a corresponding PNG image also exists in the same directory, and if a PNG image is found, it is published instead.
256
+ Unfortunately, Confluence struggles with SVG images, e.g. they may only show in *edit* mode, display in a wrong size or text labels in the image may be truncated. (This seems to be a known issue in Confluence.) In order to mitigate the issue, whenever *md2conf* encounters a reference to an SVG image in a Markdown file, it checks whether a corresponding PNG image also exists in the same directory, and if a PNG image is found, it is published instead.
172
257
 
173
258
  External images referenced with an absolute URL retain the original URL.
174
259
 
175
260
  ### Ignoring files
176
261
 
177
- Skip files in a directory with rules defined in `.mdignore`. Each rule should occupy a single line. Rules follow the syntax of [fnmatch](https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch). Specifically, `?` matches any single character, and `*` matches zero or more characters. For example, use `up-*.md` to exclude Markdown files that start with `up-`. Lines that start with `#` are treated as comments.
262
+ Skip files in a directory with rules defined in `.mdignore`. Each rule should occupy a single line. Rules follow the syntax (and constraints) of [fnmatch](https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch). Specifically, `?` matches any single character, and `*` matches zero or more characters. For example, use `up-*.md` to exclude Markdown files that start with `up-`. Lines that start with `#` are treated as comments.
178
263
 
179
264
  Files that don't have the extension `*.md` are skipped automatically. Hidden directories (whose name starts with `.`) are not recursed into.
180
265
 
266
+ Relative paths to items in a nested directory are not supported. You must put `.mdignore` in the same directory where the items to be skipped reside.
267
+
181
268
  ### Page title
182
269
 
183
270
  *md2conf* makes a best-effort attempt at setting the Confluence wiki page title when it publishes a Markdown document the first time. The following are probed in this order:
184
271
 
185
- 1. The `title` attribute set in the [front-matter](https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/). Front-matter is a block delimited by `---` at the beginning of a Markdown document. Currently, only YAML syntax is supported.
272
+ 1. The `title` attribute set in the [front-matter](https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/). Front-matter is a block delimited by `---` at the beginning of a Markdown document. Both JSON and YAML syntax are supported.
186
273
  2. The text of the topmost unique Markdown heading (`#`). For example, if a document has a single first-level heading (e.g. `# My document`), its text is used. However, if there are multiple first-level headings, this step is skipped.
187
274
  3. The file name (without the extension `.md`).
188
275
 
189
276
  If a matching Confluence page already exists for a Markdown file, the page title in Confluence is left unchanged.
190
277
 
278
+ ### Labels
279
+
280
+ If a Markdown document has the front-matter attribute `tags`, *md2conf* assigns the specified tags to the Confluence page as labels.
281
+
282
+ ```yaml
283
+ ---
284
+ title: "Example document"
285
+ tags: ["markdown", "md", "wiki"]
286
+ ---
287
+ ```
288
+
289
+ Any previously assigned labels are discarded. As per Confluence terminology, new labels have the `prefix` of `global`.
290
+
291
+ If a document has no `tags` attribute, existing Confluence labels are left intact.
292
+
191
293
  ### Converting diagrams
192
294
 
193
295
  You can include [Mermaid diagrams](https://mermaid.js.org/) in your Markdown documents to create visual representations of systems, processes, and relationships. When a Markdown document contains a code block with the language specifier `mermaid`, *md2conf* offers two options to publish the diagram:
@@ -195,6 +297,18 @@ You can include [Mermaid diagrams](https://mermaid.js.org/) in your Markdown doc
195
297
  1. Pre-render into an image. The code block is interpreted by and converted into a PNG or SVG image with the Mermaid diagram utility [mermaid-cli](https://github.com/mermaid-js/mermaid-cli). The generated image is then uploaded to Confluence as an attachment to the page. This is the approach we use and support.
196
298
  2. Render on demand. The code block is transformed into a [diagram macro](https://atlasauthority.atlassian.net/wiki/spaces/MARKDOWNCLOUD/pages/2946826241/Diagram+Macro), which is processed by Confluence. You need a [Confluence plugin](https://marketplace.atlassian.com/apps/1211438/markdown-html-plantuml-latex-diagrams-open-api-mermaid) to turn macro definitions into images when a Confluence page is visited. This is a contributed feature. As authors of *md2conf*, we don't endorse or support any particular Confluence plugin.
197
299
 
300
+ If you are running into issues with the pre-rendering approach (e.g. misaligned labels in the generated image), verify if `mermaid-cli` can process the Mermaid source:
301
+
302
+ ```sh
303
+ mmdc -i sample.mmd -o sample.png -b transparent --scale 2
304
+ ```
305
+
306
+ Ensure that `mermaid-cli` is set up, refer to *Installation* for instructions.
307
+
308
+ ### Local output
309
+
310
+ *md2conf* supports local output, in which the tool doesn't communicate with the Confluence REST API. Instead, it reads a single Markdown file or a directory of Markdown files, and writes Confluence Storage Format (`*.csf`) output for each document. (Confluence Storage Format is a derivative of XHTML with Confluence-specific tags for complex elements such as images with captions, code blocks, info panels, collapsed sections, etc.) You can push the generated output to Confluence by invoking the API (e.g. with `curl`).
311
+
198
312
  ### Running the tool
199
313
 
200
314
  You execute the command-line tool `md2conf` to synchronize the Markdown file with Confluence:
@@ -207,8 +321,8 @@ Use the `--help` switch to get a full list of supported command-line options:
207
321
 
208
322
  ```console
209
323
  $ python3 -m md2conf --help
210
- usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--keep-hierarchy] [--generated-by GENERATED_BY] [--no-generated-by]
211
- [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
324
+ usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [--api-url API_URL] [-u USERNAME] [-a API_KEY] [-s SPACE] [-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--keep-hierarchy] [--generated-by GENERATED_BY]
325
+ [--no-generated-by] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
212
326
  mdpath
213
327
 
214
328
  positional arguments:
@@ -220,9 +334,10 @@ options:
220
334
  -d DOMAIN, --domain DOMAIN
221
335
  Confluence organization domain.
222
336
  -p PATH, --path PATH Base path for Confluence (default: '/wiki/').
337
+ --api-url API_URL Confluence API URL. Required for scoped tokens. Refer to documentation how to obtain one.
223
338
  -u USERNAME, --username USERNAME
224
339
  Confluence user name.
225
- -a APIKEY, --apikey APIKEY
340
+ -a API_KEY, --apikey API_KEY, --api-key API_KEY
226
341
  Confluence API key. Refer to documentation how to obtain one.
227
342
  -s SPACE, --space SPACE
228
343
  Confluence space key for pages to be published. If omitted, will default to user space.