markdown-to-confluence 0.4.1__tar.gz → 0.4.3__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 (85) hide show
  1. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/MANIFEST.in +1 -0
  2. {markdown_to_confluence-0.4.1/markdown_to_confluence.egg-info → markdown_to_confluence-0.4.3}/PKG-INFO +96 -32
  3. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/README.md +95 -31
  4. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3/markdown_to_confluence.egg-info}/PKG-INFO +96 -32
  5. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/SOURCES.txt +14 -0
  6. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/__init__.py +1 -1
  7. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/__main__.py +94 -15
  8. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/api.py +84 -94
  9. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/application.py +18 -2
  10. markdown_to_confluence-0.4.3/md2conf/collection.py +37 -0
  11. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/converter.py +456 -168
  12. markdown_to_confluence-0.4.3/md2conf/domain.py +46 -0
  13. markdown_to_confluence-0.4.3/md2conf/drawio.py +271 -0
  14. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/local.py +10 -4
  15. markdown_to_confluence-0.4.3/md2conf/markdown.py +108 -0
  16. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/matcher.py +63 -4
  17. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/metadata.py +2 -0
  18. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/processor.py +39 -29
  19. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/scanner.py +7 -0
  20. markdown_to_confluence-0.4.3/md2conf/xml.py +70 -0
  21. markdown_to_confluence-0.4.3/tests/source/figure/diagram.drawio +19 -0
  22. markdown_to_confluence-0.4.3/tests/source/figure/diagram.drawio.png +0 -0
  23. markdown_to_confluence-0.4.3/tests/source/figure/diagram.drawio.svg +4 -0
  24. markdown_to_confluence-0.4.3/tests/source/footnote.md +8 -0
  25. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/images.md +4 -0
  26. markdown_to_confluence-0.4.3/tests/source/math.md +15 -0
  27. markdown_to_confluence-0.4.3/tests/source/table.md +28 -0
  28. markdown_to_confluence-0.4.3/tests/target/footnote.xml +18 -0
  29. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/images.xml +12 -0
  30. markdown_to_confluence-0.4.3/tests/target/math.xml +17 -0
  31. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/mermaid.xml +6 -6
  32. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/missing.xml +6 -6
  33. markdown_to_confluence-0.4.3/tests/target/table.xml +81 -0
  34. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/test_conversion.py +8 -2
  35. markdown_to_confluence-0.4.3/tests/test_drawio.py +53 -0
  36. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/test_matcher.py +28 -6
  37. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/test_processor.py +1 -1
  38. markdown_to_confluence-0.4.3/tests/test_unit.py +49 -0
  39. markdown_to_confluence-0.4.1/md2conf/collection.py +0 -31
  40. markdown_to_confluence-0.4.1/tests/test_unit.py +0 -33
  41. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/LICENSE +0 -0
  42. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/dependency_links.txt +0 -0
  43. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/entry_points.txt +0 -0
  44. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/requires.txt +0 -0
  45. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/top_level.txt +0 -0
  46. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/markdown_to_confluence.egg-info/zip-safe +0 -0
  47. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/emoji.py +0 -0
  48. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/entities.dtd +0 -0
  49. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/extra.py +0 -0
  50. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/mermaid.py +0 -0
  51. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/properties.py +0 -0
  52. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/puppeteer-config.json +0 -0
  53. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/md2conf/py.typed +0 -0
  54. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/pyproject.toml +0 -0
  55. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/setup.cfg +0 -0
  56. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/setup.py +0 -0
  57. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/__init__.py +0 -0
  58. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/admonition.md +0 -0
  59. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/alert.md +0 -0
  60. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/anchors.md +0 -0
  61. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/basic.md +0 -0
  62. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/code.md +0 -0
  63. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/collapsed.md +0 -0
  64. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/fenced.md +0 -0
  65. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/figure/raster.png +0 -0
  66. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/figure/vector.svg +0 -0
  67. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/ignore.md +0 -0
  68. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/images/images.md +0 -0
  69. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/mermaid.md +0 -0
  70. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/missing.md +0 -0
  71. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/sections.md +0 -0
  72. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/tags.md +0 -0
  73. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/source/title.md +0 -0
  74. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/admonition.xml +0 -0
  75. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/alert.xml +0 -0
  76. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/anchors.xml +0 -0
  77. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/basic.xml +0 -0
  78. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/code.xml +0 -0
  79. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/collapsed.xml +0 -0
  80. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/fenced.xml +0 -0
  81. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/images/images.xml +0 -0
  82. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/sections.xml +0 -0
  83. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/target/tags.xml +0 -0
  84. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/test_mermaid.py +0 -0
  85. {markdown_to_confluence-0.4.1 → markdown_to_confluence-0.4.3}/tests/test_scanner.py +0 -0
@@ -1,5 +1,6 @@
1
1
  recursive-include tests *.py
2
2
  recursive-include tests *.md
3
+ recursive-include tests *.drawio
3
4
  recursive-include tests *.png
4
5
  recursive-include tests *.svg
5
6
  recursive-include tests *.xml
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-to-confluence
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Publish Markdown files to Confluence wiki
5
5
  Author-email: Levente Hunyadi <hunyadi@gmail.com>
6
6
  Maintainer-email: Levente Hunyadi <hunyadi@gmail.com>
@@ -58,15 +58,18 @@ This Python package
58
58
  * Text with **bold**, *italic*, `monospace`, <ins>underline</ins> and ~~strikethrough~~
59
59
  * Link to [sections on the same page](#getting-started) or [external locations](http://example.com/)
60
60
  * Subscript and superscript (with HTML tags `<sub>` and `<sup>`)
61
+ * Math formulas with LaTeX notation
61
62
  * Emoji
62
63
  * Ordered and unordered lists
63
64
  * Block quotes
64
65
  * Code blocks (e.g. Python, JSON, XML)
65
66
  * Images (uploaded as Confluence page attachments or hosted externally)
66
67
  * Tables
68
+ * Footnotes
67
69
  * [Table of contents](https://docs.gitlab.com/ee/user/markdown.html#table-of-contents)
68
70
  * [Admonitions](https://python-markdown.github.io/extensions/admonition/) and alert boxes in [GitHub](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) and [GitLab](https://docs.gitlab.com/ee/development/documentation/styleguide/#alert-boxes)
69
71
  * [Collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections)
72
+ * draw\.io diagrams
70
73
  * [Mermaid diagrams](https://mermaid.live/) in code blocks (converted to images)
71
74
 
72
75
  Whenever possible, the implementation uses [Confluence REST API v2](https://developer.atlassian.com/cloud/confluence/rest/v2/) to fetch space properties, and get, create or update page content.
@@ -79,12 +82,26 @@ Whenever possible, the implementation uses [Confluence REST API v2](https://deve
79
82
  pip install markdown-to-confluence
80
83
  ```
81
84
 
82
- **Optional.** Converting code blocks of Mermaid diagrams into Confluence image attachments requires [mermaid-cli](https://github.com/mermaid-js/mermaid-cli):
85
+ ### Command-line utilities
86
+
87
+ **Optional.** Converting `*.drawio` diagrams to PNG or SVG images before uploading to Confluence as attachments requires installing [draw.io](https://www.drawio.com/). (Refer to `--render-drawio`.)
88
+
89
+ **Optional.** Converting code blocks of Mermaid diagrams to PNG or SVG images before uploading to Confluence as attachments requires [mermaid-cli](https://github.com/mermaid-js/mermaid-cli). (Refer to `--render-mermaid`.)
83
90
 
84
91
  ```sh
85
92
  npm install -g @mermaid-js/mermaid-cli
86
93
  ```
87
94
 
95
+ ### Marketplace apps
96
+
97
+ As authors of *md2conf*, we don't endorse or support any particular Confluence marketplace apps.
98
+
99
+ **Optional.** Editable draw\.io diagrams require [draw.io Diagrams marketplace app](https://marketplace.atlassian.com/apps/1210933/draw-io-diagrams-uml-bpmn-aws-erd-flowcharts). (Refer to `--no-render-drawio`.)
100
+
101
+ **Optional.** Displaying Mermaid diagrams in Confluence without pre-rendering in the synchronization phase requires a marketplace app. (Refer to `--no-render-mermaid`.)
102
+
103
+ **Optional.** Displaying formulas and equations in Confluence requires [marketplace app](https://marketplace.atlassian.com/apps/1226109/latex-math-for-confluence-math-formula-equations), refer to [LaTeX Math for Confluence - Math Formula & Equations](https://help.narva.net/latex-math-for-confluence/).
104
+
88
105
  ## Getting started
89
106
 
90
107
  In order to get started, you will need
@@ -152,7 +169,7 @@ If you lack appropriate permissions, you will get an *Unauthorized* response fro
152
169
  Each Markdown file is associated with a Confluence wiki page with a Markdown comment:
153
170
 
154
171
  ```markdown
155
- <!-- confluence-page-id: 85668266616 -->
172
+ <!-- confluence-page-id: 20250001023 -->
156
173
  ```
157
174
 
158
175
  The above tells the tool to synchronize the Markdown file with the given Confluence page ID. This implies that the Confluence wiki page must exist such that it has an ID. The comment can be placed anywhere in the source file.
@@ -193,24 +210,28 @@ First, *md2conf* builds an index of pages in the directory hierarchy. The index
193
210
 
194
211
  If a Markdown file doesn't yet pair up with a Confluence page, *md2conf* creates a new page and assigns a parent. Parent-child relationships are reflected in the navigation panel in Confluence. You can set a root page ID with the command-line option `-r`, which constitutes the topmost parent. (This could correspond to the landing page of your Confluence space. The Confluence page ID is always revealed when you edit a page.) Whenever a directory contains the file `index.md` or `README.md`, this page becomes the future parent page, and all Markdown files in this directory (and possibly nested directories) become its child pages (unless they already have a page ID). However, if an `index.md` or `README.md` file is subsequently found in one of the nested directories, it becomes the parent page of that directory, and any of its subdirectories.
195
212
 
213
+ The top-level directory to be synchronized must always have an `index.md` or `README.md`, which maps to the root of the corresponding sub-tree in Confluence (specified with `-r`).
214
+
196
215
  The concepts above are illustrated in the following sections.
197
216
 
198
217
  #### File-system directory hierarchy
199
218
 
200
- The title of each Markdown file (either the text of the topmost unique heading (`#`), or the title specified in front-matter) is shown next to the file name.
219
+ The title of each Markdown file (either the text of the topmost unique heading (`#`), or the title specified in front-matter) is shown next to the file name. `docs` is the top-level directory to be synchronized.
201
220
 
202
221
  ```
203
- .
222
+ docs
223
+ ├── index.md: Root page
204
224
  ├── computer-science
205
225
  │ ├── index.md: Introduction to computer science
206
226
  │ ├── algebra.md: Linear algebra
207
227
  │ └── algorithms.md: Theory of algorithms
208
- └── machine-learning
209
- ├── README.md: AI and ML
210
- ├── awareness.md: Consciousness and intelligence
211
- └── statistics
212
- ├── index.md: Introduction to statistics
213
- └── median.md: Mean vs. median
228
+ ├── machine-learning
229
+ ├── README.md: AI and ML
230
+ ├── awareness.md: Consciousness and intelligence
231
+ └── statistics
232
+ ├── index.md: Introduction to statistics
233
+ └── median.md: Mean vs. median
234
+ └── ethics.md: Ethical considerations
214
235
  ```
215
236
 
216
237
  #### Page hierarchy in Confluence
@@ -218,14 +239,15 @@ The title of each Markdown file (either the text of the topmost unique heading (
218
239
  Observe how `index.md` and `README.md` files have assumed parent (or ancestor) role for any Markdown files in the same directory (or below).
219
240
 
220
241
  ```
221
- root
242
+ Root page
222
243
  ├── Introduction to computer science
223
244
  │ ├── Linear algebra
224
245
  │ └── Theory of algorithms
225
- └── AI and ML
226
- ├── Consciousness and intelligence
227
- └── Introduction to statistics
228
- └── Mean vs. median
246
+ ├── AI and ML
247
+ ├── Consciousness and intelligence
248
+ └── Introduction to statistics
249
+ └── Mean vs. median
250
+ └── Ethical considerations
229
251
  ```
230
252
 
231
253
  ### Emoji
@@ -299,6 +321,25 @@ Unfortunately, Confluence struggles with SVG images, e.g. they may only show in
299
321
 
300
322
  External images referenced with an absolute URL retain the original URL.
301
323
 
324
+ ### LaTeX math formulas
325
+
326
+ Inline formulas can be enclosed with `$` signs, or delimited with `\(` and `\)`, i.e.
327
+
328
+ * the code `$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$` is shown as $\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$,
329
+ * and `\(\lim _{x\rightarrow \infty }\frac{1}{x}=0\)` is shown as $\lim _{x\rightarrow \infty }\frac{1}{x}=0$.
330
+
331
+ Block formulas can be enclosed with `$$`, or wrapped in code blocks specifying the language `math`:
332
+
333
+ ```md
334
+ $$\int _{a}^{b}f(x)dx=F(b)-F(a)$$
335
+ ```
336
+
337
+ is shown as
338
+
339
+ $$\int _{a}^{b}f(x)dx=F(b)-F(a)$$
340
+
341
+ Displaying math formulas in Confluence requires the extension [LaTeX Math for Confluence - Math Formula & Equations](https://help.narva.net/latex-math-for-confluence/).
342
+
302
343
  ### Ignoring files
303
344
 
304
345
  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.
@@ -307,6 +348,20 @@ Files that don't have the extension `*.md` are skipped automatically. Hidden dir
307
348
 
308
349
  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.
309
350
 
351
+ If you add the `synchronized` attribute to JSON or YAML front-matter with the value `false`, the document content (including attachments) and metadata (e.g. tags) will not be synchronized with Confluence:
352
+
353
+ ```yaml
354
+ ---
355
+ title: "Collaborating with other teams"
356
+ page_id: "19830101"
357
+ synchronized: false
358
+ ---
359
+
360
+ This Markdown document is neither parsed, nor synchronized with Confluence.
361
+ ```
362
+
363
+ This is useful if you have a page in a hierarchy that participates in parent-child relationships but whose content is edited directly in Confluence. Specifically, these documents can be referenced with relative links from other Markdown documents in the file system tree.
364
+
310
365
  ### Page title
311
366
 
312
367
  *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:
@@ -348,12 +403,18 @@ properties:
348
403
 
349
404
  The attribute `properties` is parsed as a dictionary with keys of type string and values of type JSON. *md2conf* passes JSON values to Confluence REST API unchanged.
350
405
 
351
- ### Converting diagrams
406
+ ### draw\.io diagrams
407
+
408
+ With the command-line option `--no-render-drawio` (default), editable diagram data is extracted from images with embedded draw\.io diagrams (`*.drawio.png` and `*.drawio.svg`), and uploaded to Confluence as attachments. `*.drawio` and `*.drawio.xml` files are uploaded as-is. You need a [marketplace app](https://marketplace.atlassian.com/apps/1210933/draw-io-diagrams-uml-bpmn-aws-erd-flowcharts) to view and edit these diagrams on a Confluence page.
409
+
410
+ With the command-line option `--render-drawio`, images with embedded draw\.io diagrams (`*.drawio.png` and `*.drawio.svg`) are uploaded unchanged, and shown on the Confluence page as images. These diagrams are not editable in Confluence. When both an SVG and a PNG image is available, PNG is preferred. `*.drawio` and `*.drawio.xml` files are converted into PNG or SVG images by invoking draw\.io as a command-line utility, and the generated images are uploaded to Confluence as attachments, and shown as images.
411
+
412
+ ### Mermaid diagrams
352
413
 
353
414
  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:
354
415
 
355
- 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.
356
- 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.
416
+ 1. Pre-render into an image (command-line option `--render-mermaid`). 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.
417
+ 2. Display on demand (command-line option `--no-render-mermaid`). 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 [marketplace app](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.
357
418
 
358
419
  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:
359
420
 
@@ -379,8 +440,9 @@ Use the `--help` switch to get a full list of supported command-line options:
379
440
 
380
441
  ```console
381
442
  $ python3 -m md2conf --help
382
- 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]
383
- [--no-generated-by] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
443
+ 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] [--flatten-hierarchy]
444
+ [--generated-by GENERATED_BY] [--no-generated-by] [--render-drawio] [--no-render-drawio] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors]
445
+ [--no-heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
384
446
  mdpath
385
447
 
386
448
  positional arguments:
@@ -389,28 +451,30 @@ positional arguments:
389
451
  options:
390
452
  -h, --help show this help message and exit
391
453
  --version show program's version number and exit
392
- -d DOMAIN, --domain DOMAIN
393
- Confluence organization domain.
394
- -p PATH, --path PATH Base path for Confluence (default: '/wiki/').
454
+ -d, --domain DOMAIN Confluence organization domain.
455
+ -p, --path PATH Base path for Confluence (default: '/wiki/').
395
456
  --api-url API_URL Confluence API URL. Required for scoped tokens. Refer to documentation how to obtain one.
396
- -u USERNAME, --username USERNAME
457
+ -u, --username USERNAME
397
458
  Confluence user name.
398
- -a API_KEY, --apikey API_KEY, --api-key API_KEY
459
+ -a, --apikey, --api-key API_KEY
399
460
  Confluence API key. Refer to documentation how to obtain one.
400
- -s SPACE, --space SPACE
401
- Confluence space key for pages to be published. If omitted, will default to user space.
402
- -l {debug,info,warning,error,critical}, --loglevel {debug,info,warning,error,critical}
461
+ -s, --space SPACE Confluence space key for pages to be published. If omitted, will default to user space.
462
+ -l, --loglevel {debug,info,warning,error,critical}
403
463
  Use this option to set the log verbosity.
404
464
  -r ROOT_PAGE Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.
405
465
  --keep-hierarchy Maintain source directory structure when exporting to Confluence.
466
+ --flatten-hierarchy Flatten directories with no index.md or README.md when exporting to Confluence.
406
467
  --generated-by GENERATED_BY
407
468
  Add prompt to pages (default: 'This page has been generated with a tool.').
408
469
  --no-generated-by Do not add 'generated by a tool' prompt to pages.
409
- --render-mermaid Render Mermaid diagrams as image files and add as attachments.
410
- --no-render-mermaid Inline Mermaid diagram in Confluence page.
470
+ --render-drawio Render draw.io diagrams as image files and add as attachments. (Converter required.)
471
+ --no-render-drawio Inline draw.io diagram in Confluence page. (Marketplace app required.)
472
+ --render-mermaid Render Mermaid diagrams as image files and add as attachments. (Converter required.)
473
+ --no-render-mermaid Inline Mermaid diagram in Confluence page. (Marketplace app required.)
411
474
  --render-mermaid-format {png,svg}
412
- Format for rendering Mermaid diagrams (default: 'png').
475
+ Format for rendering Mermaid and draw.io diagrams (default: 'png').
413
476
  --heading-anchors Place an anchor at each section heading with GitHub-style same-page identifiers.
477
+ --no-heading-anchors Don't place an anchor at each section heading.
414
478
  --ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
415
479
  --local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
416
480
  --headers [KEY=VALUE ...]
@@ -16,15 +16,18 @@ This Python package
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
18
  * Subscript and superscript (with HTML tags `<sub>` and `<sup>`)
19
+ * Math formulas with LaTeX notation
19
20
  * Emoji
20
21
  * Ordered and unordered lists
21
22
  * Block quotes
22
23
  * Code blocks (e.g. Python, JSON, XML)
23
24
  * Images (uploaded as Confluence page attachments or hosted externally)
24
25
  * Tables
26
+ * Footnotes
25
27
  * [Table of contents](https://docs.gitlab.com/ee/user/markdown.html#table-of-contents)
26
28
  * [Admonitions](https://python-markdown.github.io/extensions/admonition/) and alert boxes in [GitHub](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) and [GitLab](https://docs.gitlab.com/ee/development/documentation/styleguide/#alert-boxes)
27
29
  * [Collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections)
30
+ * draw\.io diagrams
28
31
  * [Mermaid diagrams](https://mermaid.live/) in code blocks (converted to images)
29
32
 
30
33
  Whenever possible, the implementation uses [Confluence REST API v2](https://developer.atlassian.com/cloud/confluence/rest/v2/) to fetch space properties, and get, create or update page content.
@@ -37,12 +40,26 @@ Whenever possible, the implementation uses [Confluence REST API v2](https://deve
37
40
  pip install markdown-to-confluence
38
41
  ```
39
42
 
40
- **Optional.** Converting code blocks of Mermaid diagrams into Confluence image attachments requires [mermaid-cli](https://github.com/mermaid-js/mermaid-cli):
43
+ ### Command-line utilities
44
+
45
+ **Optional.** Converting `*.drawio` diagrams to PNG or SVG images before uploading to Confluence as attachments requires installing [draw.io](https://www.drawio.com/). (Refer to `--render-drawio`.)
46
+
47
+ **Optional.** Converting code blocks of Mermaid diagrams to PNG or SVG images before uploading to Confluence as attachments requires [mermaid-cli](https://github.com/mermaid-js/mermaid-cli). (Refer to `--render-mermaid`.)
41
48
 
42
49
  ```sh
43
50
  npm install -g @mermaid-js/mermaid-cli
44
51
  ```
45
52
 
53
+ ### Marketplace apps
54
+
55
+ As authors of *md2conf*, we don't endorse or support any particular Confluence marketplace apps.
56
+
57
+ **Optional.** Editable draw\.io diagrams require [draw.io Diagrams marketplace app](https://marketplace.atlassian.com/apps/1210933/draw-io-diagrams-uml-bpmn-aws-erd-flowcharts). (Refer to `--no-render-drawio`.)
58
+
59
+ **Optional.** Displaying Mermaid diagrams in Confluence without pre-rendering in the synchronization phase requires a marketplace app. (Refer to `--no-render-mermaid`.)
60
+
61
+ **Optional.** Displaying formulas and equations in Confluence requires [marketplace app](https://marketplace.atlassian.com/apps/1226109/latex-math-for-confluence-math-formula-equations), refer to [LaTeX Math for Confluence - Math Formula & Equations](https://help.narva.net/latex-math-for-confluence/).
62
+
46
63
  ## Getting started
47
64
 
48
65
  In order to get started, you will need
@@ -110,7 +127,7 @@ If you lack appropriate permissions, you will get an *Unauthorized* response fro
110
127
  Each Markdown file is associated with a Confluence wiki page with a Markdown comment:
111
128
 
112
129
  ```markdown
113
- <!-- confluence-page-id: 85668266616 -->
130
+ <!-- confluence-page-id: 20250001023 -->
114
131
  ```
115
132
 
116
133
  The above tells the tool to synchronize the Markdown file with the given Confluence page ID. This implies that the Confluence wiki page must exist such that it has an ID. The comment can be placed anywhere in the source file.
@@ -151,24 +168,28 @@ First, *md2conf* builds an index of pages in the directory hierarchy. The index
151
168
 
152
169
  If a Markdown file doesn't yet pair up with a Confluence page, *md2conf* creates a new page and assigns a parent. Parent-child relationships are reflected in the navigation panel in Confluence. You can set a root page ID with the command-line option `-r`, which constitutes the topmost parent. (This could correspond to the landing page of your Confluence space. The Confluence page ID is always revealed when you edit a page.) Whenever a directory contains the file `index.md` or `README.md`, this page becomes the future parent page, and all Markdown files in this directory (and possibly nested directories) become its child pages (unless they already have a page ID). However, if an `index.md` or `README.md` file is subsequently found in one of the nested directories, it becomes the parent page of that directory, and any of its subdirectories.
153
170
 
171
+ The top-level directory to be synchronized must always have an `index.md` or `README.md`, which maps to the root of the corresponding sub-tree in Confluence (specified with `-r`).
172
+
154
173
  The concepts above are illustrated in the following sections.
155
174
 
156
175
  #### File-system directory hierarchy
157
176
 
158
- The title of each Markdown file (either the text of the topmost unique heading (`#`), or the title specified in front-matter) is shown next to the file name.
177
+ The title of each Markdown file (either the text of the topmost unique heading (`#`), or the title specified in front-matter) is shown next to the file name. `docs` is the top-level directory to be synchronized.
159
178
 
160
179
  ```
161
- .
180
+ docs
181
+ ├── index.md: Root page
162
182
  ├── computer-science
163
183
  │ ├── index.md: Introduction to computer science
164
184
  │ ├── algebra.md: Linear algebra
165
185
  │ └── algorithms.md: Theory of algorithms
166
- └── machine-learning
167
- ├── README.md: AI and ML
168
- ├── awareness.md: Consciousness and intelligence
169
- └── statistics
170
- ├── index.md: Introduction to statistics
171
- └── median.md: Mean vs. median
186
+ ├── machine-learning
187
+ ├── README.md: AI and ML
188
+ ├── awareness.md: Consciousness and intelligence
189
+ └── statistics
190
+ ├── index.md: Introduction to statistics
191
+ └── median.md: Mean vs. median
192
+ └── ethics.md: Ethical considerations
172
193
  ```
173
194
 
174
195
  #### Page hierarchy in Confluence
@@ -176,14 +197,15 @@ The title of each Markdown file (either the text of the topmost unique heading (
176
197
  Observe how `index.md` and `README.md` files have assumed parent (or ancestor) role for any Markdown files in the same directory (or below).
177
198
 
178
199
  ```
179
- root
200
+ Root page
180
201
  ├── Introduction to computer science
181
202
  │ ├── Linear algebra
182
203
  │ └── Theory of algorithms
183
- └── AI and ML
184
- ├── Consciousness and intelligence
185
- └── Introduction to statistics
186
- └── Mean vs. median
204
+ ├── AI and ML
205
+ ├── Consciousness and intelligence
206
+ └── Introduction to statistics
207
+ └── Mean vs. median
208
+ └── Ethical considerations
187
209
  ```
188
210
 
189
211
  ### Emoji
@@ -257,6 +279,25 @@ Unfortunately, Confluence struggles with SVG images, e.g. they may only show in
257
279
 
258
280
  External images referenced with an absolute URL retain the original URL.
259
281
 
282
+ ### LaTeX math formulas
283
+
284
+ Inline formulas can be enclosed with `$` signs, or delimited with `\(` and `\)`, i.e.
285
+
286
+ * the code `$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$` is shown as $\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$,
287
+ * and `\(\lim _{x\rightarrow \infty }\frac{1}{x}=0\)` is shown as $\lim _{x\rightarrow \infty }\frac{1}{x}=0$.
288
+
289
+ Block formulas can be enclosed with `$$`, or wrapped in code blocks specifying the language `math`:
290
+
291
+ ```md
292
+ $$\int _{a}^{b}f(x)dx=F(b)-F(a)$$
293
+ ```
294
+
295
+ is shown as
296
+
297
+ $$\int _{a}^{b}f(x)dx=F(b)-F(a)$$
298
+
299
+ Displaying math formulas in Confluence requires the extension [LaTeX Math for Confluence - Math Formula & Equations](https://help.narva.net/latex-math-for-confluence/).
300
+
260
301
  ### Ignoring files
261
302
 
262
303
  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.
@@ -265,6 +306,20 @@ Files that don't have the extension `*.md` are skipped automatically. Hidden dir
265
306
 
266
307
  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
308
 
309
+ If you add the `synchronized` attribute to JSON or YAML front-matter with the value `false`, the document content (including attachments) and metadata (e.g. tags) will not be synchronized with Confluence:
310
+
311
+ ```yaml
312
+ ---
313
+ title: "Collaborating with other teams"
314
+ page_id: "19830101"
315
+ synchronized: false
316
+ ---
317
+
318
+ This Markdown document is neither parsed, nor synchronized with Confluence.
319
+ ```
320
+
321
+ This is useful if you have a page in a hierarchy that participates in parent-child relationships but whose content is edited directly in Confluence. Specifically, these documents can be referenced with relative links from other Markdown documents in the file system tree.
322
+
268
323
  ### Page title
269
324
 
270
325
  *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:
@@ -306,12 +361,18 @@ properties:
306
361
 
307
362
  The attribute `properties` is parsed as a dictionary with keys of type string and values of type JSON. *md2conf* passes JSON values to Confluence REST API unchanged.
308
363
 
309
- ### Converting diagrams
364
+ ### draw\.io diagrams
365
+
366
+ With the command-line option `--no-render-drawio` (default), editable diagram data is extracted from images with embedded draw\.io diagrams (`*.drawio.png` and `*.drawio.svg`), and uploaded to Confluence as attachments. `*.drawio` and `*.drawio.xml` files are uploaded as-is. You need a [marketplace app](https://marketplace.atlassian.com/apps/1210933/draw-io-diagrams-uml-bpmn-aws-erd-flowcharts) to view and edit these diagrams on a Confluence page.
367
+
368
+ With the command-line option `--render-drawio`, images with embedded draw\.io diagrams (`*.drawio.png` and `*.drawio.svg`) are uploaded unchanged, and shown on the Confluence page as images. These diagrams are not editable in Confluence. When both an SVG and a PNG image is available, PNG is preferred. `*.drawio` and `*.drawio.xml` files are converted into PNG or SVG images by invoking draw\.io as a command-line utility, and the generated images are uploaded to Confluence as attachments, and shown as images.
369
+
370
+ ### Mermaid diagrams
310
371
 
311
372
  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:
312
373
 
313
- 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.
314
- 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.
374
+ 1. Pre-render into an image (command-line option `--render-mermaid`). 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.
375
+ 2. Display on demand (command-line option `--no-render-mermaid`). 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 [marketplace app](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.
315
376
 
316
377
  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:
317
378
 
@@ -337,8 +398,9 @@ Use the `--help` switch to get a full list of supported command-line options:
337
398
 
338
399
  ```console
339
400
  $ python3 -m md2conf --help
340
- 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]
341
- [--no-generated-by] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
401
+ 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] [--flatten-hierarchy]
402
+ [--generated-by GENERATED_BY] [--no-generated-by] [--render-drawio] [--no-render-drawio] [--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors]
403
+ [--no-heading-anchors] [--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
342
404
  mdpath
343
405
 
344
406
  positional arguments:
@@ -347,28 +409,30 @@ positional arguments:
347
409
  options:
348
410
  -h, --help show this help message and exit
349
411
  --version show program's version number and exit
350
- -d DOMAIN, --domain DOMAIN
351
- Confluence organization domain.
352
- -p PATH, --path PATH Base path for Confluence (default: '/wiki/').
412
+ -d, --domain DOMAIN Confluence organization domain.
413
+ -p, --path PATH Base path for Confluence (default: '/wiki/').
353
414
  --api-url API_URL Confluence API URL. Required for scoped tokens. Refer to documentation how to obtain one.
354
- -u USERNAME, --username USERNAME
415
+ -u, --username USERNAME
355
416
  Confluence user name.
356
- -a API_KEY, --apikey API_KEY, --api-key API_KEY
417
+ -a, --apikey, --api-key API_KEY
357
418
  Confluence API key. Refer to documentation how to obtain one.
358
- -s SPACE, --space SPACE
359
- Confluence space key for pages to be published. If omitted, will default to user space.
360
- -l {debug,info,warning,error,critical}, --loglevel {debug,info,warning,error,critical}
419
+ -s, --space SPACE Confluence space key for pages to be published. If omitted, will default to user space.
420
+ -l, --loglevel {debug,info,warning,error,critical}
361
421
  Use this option to set the log verbosity.
362
422
  -r ROOT_PAGE Root Confluence page to create new pages. If omitted, will raise exception when creating new pages.
363
423
  --keep-hierarchy Maintain source directory structure when exporting to Confluence.
424
+ --flatten-hierarchy Flatten directories with no index.md or README.md when exporting to Confluence.
364
425
  --generated-by GENERATED_BY
365
426
  Add prompt to pages (default: 'This page has been generated with a tool.').
366
427
  --no-generated-by Do not add 'generated by a tool' prompt to pages.
367
- --render-mermaid Render Mermaid diagrams as image files and add as attachments.
368
- --no-render-mermaid Inline Mermaid diagram in Confluence page.
428
+ --render-drawio Render draw.io diagrams as image files and add as attachments. (Converter required.)
429
+ --no-render-drawio Inline draw.io diagram in Confluence page. (Marketplace app required.)
430
+ --render-mermaid Render Mermaid diagrams as image files and add as attachments. (Converter required.)
431
+ --no-render-mermaid Inline Mermaid diagram in Confluence page. (Marketplace app required.)
369
432
  --render-mermaid-format {png,svg}
370
- Format for rendering Mermaid diagrams (default: 'png').
433
+ Format for rendering Mermaid and draw.io diagrams (default: 'png').
371
434
  --heading-anchors Place an anchor at each section heading with GitHub-style same-page identifiers.
435
+ --no-heading-anchors Don't place an anchor at each section heading.
372
436
  --ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
373
437
  --local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
374
438
  --headers [KEY=VALUE ...]