markdown-to-confluence 0.2.0__tar.gz → 0.2.2__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.
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/PKG-INFO +35 -12
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/README.md +34 -11
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/PKG-INFO +35 -12
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/SOURCES.txt +3 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/__init__.py +1 -1
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/__main__.py +44 -2
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/api.py +32 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/application.py +108 -39
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/converter.py +131 -34
- markdown_to_confluence-0.2.2/md2conf/matcher.py +83 -0
- markdown_to_confluence-0.2.2/md2conf/mermaid.py +76 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/processor.py +45 -20
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/properties.py +4 -3
- markdown_to_confluence-0.2.2/md2conf/puppeteer-config.json +8 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/setup.cfg +2 -1
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/tests/test_conversion.py +6 -1
- markdown_to_confluence-0.2.2/tests/test_matcher.py +43 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/tests/test_processor.py +2 -2
- markdown_to_confluence-0.2.0/md2conf/mermaid.py +0 -54
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/LICENSE +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/dependency_links.txt +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/entry_points.txt +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/requires.txt +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/top_level.txt +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/markdown_to_confluence.egg-info/zip-safe +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/entities.dtd +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/md2conf/py.typed +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/pyproject.toml +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/setup.py +0 -0
- {markdown_to_confluence-0.2.0 → markdown_to_confluence-0.2.2}/tests/test_mermaid.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-to-confluence
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Publish Markdown files to Confluence wiki
|
|
5
5
|
Home-page: https://github.com/hunyadi/md2conf
|
|
6
6
|
Author: Levente Hunyadi
|
|
@@ -51,7 +51,7 @@ This Python package
|
|
|
51
51
|
* Image references (uploaded as Confluence page attachments)
|
|
52
52
|
* Tables
|
|
53
53
|
* [Table of contents](https://docs.gitlab.com/ee/user/markdown.html#table-of-contents)
|
|
54
|
-
* [Admonitions](https://python-markdown.github.io/extensions/admonition/) and [
|
|
54
|
+
* [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)
|
|
55
55
|
* [Collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections)
|
|
56
56
|
* [Mermaid diagrams](https://mermaid.live/) in code blocks (converted to images)
|
|
57
57
|
|
|
@@ -144,21 +144,28 @@ Provide generated-by prompt text in the Markdown file with a tag:
|
|
|
144
144
|
|
|
145
145
|
Alternatively, use the `--generated-by GENERATED_BY` option. The tag takes precedence.
|
|
146
146
|
|
|
147
|
+
### Ignoring files
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
Files that don't have the extension `*.md` are skipped automatically. Hidden directories (whose name starts with `.`) are not recursed into.
|
|
152
|
+
|
|
147
153
|
### Running the tool
|
|
148
154
|
|
|
149
155
|
You execute the command-line tool `md2conf` to synchronize the Markdown file with Confluence:
|
|
150
156
|
|
|
151
157
|
```sh
|
|
152
|
-
$ python3 -m md2conf sample/
|
|
158
|
+
$ python3 -m md2conf sample/index.md
|
|
153
159
|
```
|
|
154
160
|
|
|
155
161
|
Use the `--help` switch to get a full list of supported command-line options:
|
|
156
162
|
|
|
157
163
|
```console
|
|
158
164
|
$ python3 -m md2conf --help
|
|
159
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
160
|
-
[
|
|
161
|
-
[--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
165
|
+
usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
166
|
+
[-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY] [--no-generated-by]
|
|
167
|
+
[--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
168
|
+
[--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
|
|
162
169
|
mdpath
|
|
163
170
|
|
|
164
171
|
positional arguments:
|
|
@@ -166,6 +173,7 @@ positional arguments:
|
|
|
166
173
|
|
|
167
174
|
options:
|
|
168
175
|
-h, --help show this help message and exit
|
|
176
|
+
--version show program's version number and exit
|
|
169
177
|
-d DOMAIN, --domain DOMAIN
|
|
170
178
|
Confluence organization domain.
|
|
171
179
|
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
@@ -188,20 +196,35 @@ options:
|
|
|
188
196
|
--heading-anchors Place an anchor at each section heading with GitHub-style same-page identifiers.
|
|
189
197
|
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
190
198
|
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
199
|
+
--headers [KEY=VALUE ...]
|
|
200
|
+
Apply custom headers to all Confluence API requests.
|
|
201
|
+
--webui-links Enable Confluence Web UI links.
|
|
191
202
|
```
|
|
192
203
|
|
|
193
|
-
### Using the
|
|
204
|
+
### Using the Docker container
|
|
205
|
+
|
|
206
|
+
You can run the Docker container via `docker run` or via `Dockerfile`. Either can accept the environment variables or arguments similar to the Python options. The final argument `./` corresponds to `mdpath` in the command-line utility.
|
|
207
|
+
|
|
208
|
+
With `docker run`, you can pass Confluence domain, user, API and space key directly to `docker run`:
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
```sh
|
|
211
|
+
docker run --rm --name md2conf -v $(pwd):/data leventehunyadi/md2conf -d instructure.atlassian.net -u levente.hunyadi@instructure.com -a 0123456789abcdef -s DAP ./
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Alternatively, you can use a separate file `.env` to pass these parameters as environment variables:
|
|
196
215
|
|
|
197
216
|
```sh
|
|
198
|
-
docker run --rm --
|
|
217
|
+
docker run --rm --env-file .env --name md2conf -v $(pwd):/data leventehunyadi/md2conf ./
|
|
199
218
|
```
|
|
200
219
|
|
|
201
|
-
|
|
220
|
+
In each case, `-v $(pwd):/data` maps the current directory to Docker container's `WORKDIR` such *md2conf* can scan files and directories in the local file system.
|
|
221
|
+
|
|
222
|
+
Note that the entry point for the Docker container's base image is `ENTRYPOINT ["python3", "-m", "md2conf"]`.
|
|
223
|
+
|
|
224
|
+
With the `Dockerfile` approach, you can extend the base image:
|
|
202
225
|
|
|
203
226
|
```Dockerfile
|
|
204
|
-
FROM
|
|
227
|
+
FROM leventehunyadi/md2conf:latest
|
|
205
228
|
|
|
206
229
|
ENV CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
207
230
|
ENV CONFLUENCE_PATH='/wiki/'
|
|
@@ -215,7 +238,7 @@ CMD ["./"]
|
|
|
215
238
|
Alternatively,
|
|
216
239
|
|
|
217
240
|
```Dockerfile
|
|
218
|
-
FROM
|
|
241
|
+
FROM leventehunyadi/md2conf:latest
|
|
219
242
|
|
|
220
243
|
CMD ["-d", "instructure.atlassian.net", "-u", "levente.hunyadi@instructure.com", "-a", "0123456789abcdef", "-s", "DAP", "./"]
|
|
221
244
|
```
|
|
@@ -20,7 +20,7 @@ This Python package
|
|
|
20
20
|
* Image references (uploaded as Confluence page attachments)
|
|
21
21
|
* Tables
|
|
22
22
|
* [Table of contents](https://docs.gitlab.com/ee/user/markdown.html#table-of-contents)
|
|
23
|
-
* [Admonitions](https://python-markdown.github.io/extensions/admonition/) and [
|
|
23
|
+
* [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)
|
|
24
24
|
* [Collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections)
|
|
25
25
|
* [Mermaid diagrams](https://mermaid.live/) in code blocks (converted to images)
|
|
26
26
|
|
|
@@ -113,21 +113,28 @@ Provide generated-by prompt text in the Markdown file with a tag:
|
|
|
113
113
|
|
|
114
114
|
Alternatively, use the `--generated-by GENERATED_BY` option. The tag takes precedence.
|
|
115
115
|
|
|
116
|
+
### Ignoring files
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
Files that don't have the extension `*.md` are skipped automatically. Hidden directories (whose name starts with `.`) are not recursed into.
|
|
121
|
+
|
|
116
122
|
### Running the tool
|
|
117
123
|
|
|
118
124
|
You execute the command-line tool `md2conf` to synchronize the Markdown file with Confluence:
|
|
119
125
|
|
|
120
126
|
```sh
|
|
121
|
-
$ python3 -m md2conf sample/
|
|
127
|
+
$ python3 -m md2conf sample/index.md
|
|
122
128
|
```
|
|
123
129
|
|
|
124
130
|
Use the `--help` switch to get a full list of supported command-line options:
|
|
125
131
|
|
|
126
132
|
```console
|
|
127
133
|
$ python3 -m md2conf --help
|
|
128
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
129
|
-
[
|
|
130
|
-
[--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
134
|
+
usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
135
|
+
[-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY] [--no-generated-by]
|
|
136
|
+
[--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
137
|
+
[--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
|
|
131
138
|
mdpath
|
|
132
139
|
|
|
133
140
|
positional arguments:
|
|
@@ -135,6 +142,7 @@ positional arguments:
|
|
|
135
142
|
|
|
136
143
|
options:
|
|
137
144
|
-h, --help show this help message and exit
|
|
145
|
+
--version show program's version number and exit
|
|
138
146
|
-d DOMAIN, --domain DOMAIN
|
|
139
147
|
Confluence organization domain.
|
|
140
148
|
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
@@ -157,20 +165,35 @@ options:
|
|
|
157
165
|
--heading-anchors Place an anchor at each section heading with GitHub-style same-page identifiers.
|
|
158
166
|
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
159
167
|
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
168
|
+
--headers [KEY=VALUE ...]
|
|
169
|
+
Apply custom headers to all Confluence API requests.
|
|
170
|
+
--webui-links Enable Confluence Web UI links.
|
|
160
171
|
```
|
|
161
172
|
|
|
162
|
-
### Using the
|
|
173
|
+
### Using the Docker container
|
|
174
|
+
|
|
175
|
+
You can run the Docker container via `docker run` or via `Dockerfile`. Either can accept the environment variables or arguments similar to the Python options. The final argument `./` corresponds to `mdpath` in the command-line utility.
|
|
176
|
+
|
|
177
|
+
With `docker run`, you can pass Confluence domain, user, API and space key directly to `docker run`:
|
|
163
178
|
|
|
164
|
-
|
|
179
|
+
```sh
|
|
180
|
+
docker run --rm --name md2conf -v $(pwd):/data leventehunyadi/md2conf -d instructure.atlassian.net -u levente.hunyadi@instructure.com -a 0123456789abcdef -s DAP ./
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Alternatively, you can use a separate file `.env` to pass these parameters as environment variables:
|
|
165
184
|
|
|
166
185
|
```sh
|
|
167
|
-
docker run --rm --
|
|
186
|
+
docker run --rm --env-file .env --name md2conf -v $(pwd):/data leventehunyadi/md2conf ./
|
|
168
187
|
```
|
|
169
188
|
|
|
170
|
-
|
|
189
|
+
In each case, `-v $(pwd):/data` maps the current directory to Docker container's `WORKDIR` such *md2conf* can scan files and directories in the local file system.
|
|
190
|
+
|
|
191
|
+
Note that the entry point for the Docker container's base image is `ENTRYPOINT ["python3", "-m", "md2conf"]`.
|
|
192
|
+
|
|
193
|
+
With the `Dockerfile` approach, you can extend the base image:
|
|
171
194
|
|
|
172
195
|
```Dockerfile
|
|
173
|
-
FROM
|
|
196
|
+
FROM leventehunyadi/md2conf:latest
|
|
174
197
|
|
|
175
198
|
ENV CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
176
199
|
ENV CONFLUENCE_PATH='/wiki/'
|
|
@@ -184,7 +207,7 @@ CMD ["./"]
|
|
|
184
207
|
Alternatively,
|
|
185
208
|
|
|
186
209
|
```Dockerfile
|
|
187
|
-
FROM
|
|
210
|
+
FROM leventehunyadi/md2conf:latest
|
|
188
211
|
|
|
189
212
|
CMD ["-d", "instructure.atlassian.net", "-u", "levente.hunyadi@instructure.com", "-a", "0123456789abcdef", "-s", "DAP", "./"]
|
|
190
213
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-to-confluence
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Publish Markdown files to Confluence wiki
|
|
5
5
|
Home-page: https://github.com/hunyadi/md2conf
|
|
6
6
|
Author: Levente Hunyadi
|
|
@@ -51,7 +51,7 @@ This Python package
|
|
|
51
51
|
* Image references (uploaded as Confluence page attachments)
|
|
52
52
|
* Tables
|
|
53
53
|
* [Table of contents](https://docs.gitlab.com/ee/user/markdown.html#table-of-contents)
|
|
54
|
-
* [Admonitions](https://python-markdown.github.io/extensions/admonition/) and [
|
|
54
|
+
* [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)
|
|
55
55
|
* [Collapsed sections](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections)
|
|
56
56
|
* [Mermaid diagrams](https://mermaid.live/) in code blocks (converted to images)
|
|
57
57
|
|
|
@@ -144,21 +144,28 @@ Provide generated-by prompt text in the Markdown file with a tag:
|
|
|
144
144
|
|
|
145
145
|
Alternatively, use the `--generated-by GENERATED_BY` option. The tag takes precedence.
|
|
146
146
|
|
|
147
|
+
### Ignoring files
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
Files that don't have the extension `*.md` are skipped automatically. Hidden directories (whose name starts with `.`) are not recursed into.
|
|
152
|
+
|
|
147
153
|
### Running the tool
|
|
148
154
|
|
|
149
155
|
You execute the command-line tool `md2conf` to synchronize the Markdown file with Confluence:
|
|
150
156
|
|
|
151
157
|
```sh
|
|
152
|
-
$ python3 -m md2conf sample/
|
|
158
|
+
$ python3 -m md2conf sample/index.md
|
|
153
159
|
```
|
|
154
160
|
|
|
155
161
|
Use the `--help` switch to get a full list of supported command-line options:
|
|
156
162
|
|
|
157
163
|
```console
|
|
158
164
|
$ python3 -m md2conf --help
|
|
159
|
-
usage: md2conf [-h] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
160
|
-
[
|
|
161
|
-
[--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
165
|
+
usage: md2conf [-h] [--version] [-d DOMAIN] [-p PATH] [-u USERNAME] [-a APIKEY] [-s SPACE]
|
|
166
|
+
[-l {debug,info,warning,error,critical}] [-r ROOT_PAGE] [--generated-by GENERATED_BY] [--no-generated-by]
|
|
167
|
+
[--render-mermaid] [--no-render-mermaid] [--render-mermaid-format {png,svg}] [--heading-anchors]
|
|
168
|
+
[--ignore-invalid-url] [--local] [--headers [KEY=VALUE ...]] [--webui-links]
|
|
162
169
|
mdpath
|
|
163
170
|
|
|
164
171
|
positional arguments:
|
|
@@ -166,6 +173,7 @@ positional arguments:
|
|
|
166
173
|
|
|
167
174
|
options:
|
|
168
175
|
-h, --help show this help message and exit
|
|
176
|
+
--version show program's version number and exit
|
|
169
177
|
-d DOMAIN, --domain DOMAIN
|
|
170
178
|
Confluence organization domain.
|
|
171
179
|
-p PATH, --path PATH Base path for Confluence (default: '/wiki/').
|
|
@@ -188,20 +196,35 @@ options:
|
|
|
188
196
|
--heading-anchors Place an anchor at each section heading with GitHub-style same-page identifiers.
|
|
189
197
|
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
|
|
190
198
|
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
|
|
199
|
+
--headers [KEY=VALUE ...]
|
|
200
|
+
Apply custom headers to all Confluence API requests.
|
|
201
|
+
--webui-links Enable Confluence Web UI links.
|
|
191
202
|
```
|
|
192
203
|
|
|
193
|
-
### Using the
|
|
204
|
+
### Using the Docker container
|
|
205
|
+
|
|
206
|
+
You can run the Docker container via `docker run` or via `Dockerfile`. Either can accept the environment variables or arguments similar to the Python options. The final argument `./` corresponds to `mdpath` in the command-line utility.
|
|
207
|
+
|
|
208
|
+
With `docker run`, you can pass Confluence domain, user, API and space key directly to `docker run`:
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
```sh
|
|
211
|
+
docker run --rm --name md2conf -v $(pwd):/data leventehunyadi/md2conf -d instructure.atlassian.net -u levente.hunyadi@instructure.com -a 0123456789abcdef -s DAP ./
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Alternatively, you can use a separate file `.env` to pass these parameters as environment variables:
|
|
196
215
|
|
|
197
216
|
```sh
|
|
198
|
-
docker run --rm --
|
|
217
|
+
docker run --rm --env-file .env --name md2conf -v $(pwd):/data leventehunyadi/md2conf ./
|
|
199
218
|
```
|
|
200
219
|
|
|
201
|
-
|
|
220
|
+
In each case, `-v $(pwd):/data` maps the current directory to Docker container's `WORKDIR` such *md2conf* can scan files and directories in the local file system.
|
|
221
|
+
|
|
222
|
+
Note that the entry point for the Docker container's base image is `ENTRYPOINT ["python3", "-m", "md2conf"]`.
|
|
223
|
+
|
|
224
|
+
With the `Dockerfile` approach, you can extend the base image:
|
|
202
225
|
|
|
203
226
|
```Dockerfile
|
|
204
|
-
FROM
|
|
227
|
+
FROM leventehunyadi/md2conf:latest
|
|
205
228
|
|
|
206
229
|
ENV CONFLUENCE_DOMAIN='instructure.atlassian.net'
|
|
207
230
|
ENV CONFLUENCE_PATH='/wiki/'
|
|
@@ -215,7 +238,7 @@ CMD ["./"]
|
|
|
215
238
|
Alternatively,
|
|
216
239
|
|
|
217
240
|
```Dockerfile
|
|
218
|
-
FROM
|
|
241
|
+
FROM leventehunyadi/md2conf:latest
|
|
219
242
|
|
|
220
243
|
CMD ["-d", "instructure.atlassian.net", "-u", "levente.hunyadi@instructure.com", "-a", "0123456789abcdef", "-s", "DAP", "./"]
|
|
221
244
|
```
|
|
@@ -16,10 +16,13 @@ md2conf/api.py
|
|
|
16
16
|
md2conf/application.py
|
|
17
17
|
md2conf/converter.py
|
|
18
18
|
md2conf/entities.dtd
|
|
19
|
+
md2conf/matcher.py
|
|
19
20
|
md2conf/mermaid.py
|
|
20
21
|
md2conf/processor.py
|
|
21
22
|
md2conf/properties.py
|
|
23
|
+
md2conf/puppeteer-config.json
|
|
22
24
|
md2conf/py.typed
|
|
23
25
|
tests/test_conversion.py
|
|
26
|
+
tests/test_matcher.py
|
|
24
27
|
tests/test_mermaid.py
|
|
25
28
|
tests/test_processor.py
|
|
@@ -5,7 +5,7 @@ Parses Markdown files, converts Markdown content into the Confluence Storage For
|
|
|
5
5
|
Confluence API endpoints to upload images and content.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "0.2.
|
|
8
|
+
__version__ = "0.2.2"
|
|
9
9
|
__author__ = "Levente Hunyadi"
|
|
10
10
|
__copyright__ = "Copyright 2022-2024, Levente Hunyadi"
|
|
11
11
|
__license__ = "MIT"
|
|
@@ -2,11 +2,13 @@ import argparse
|
|
|
2
2
|
import logging
|
|
3
3
|
import os.path
|
|
4
4
|
import sys
|
|
5
|
+
import typing
|
|
5
6
|
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
7
|
+
from typing import Any, Literal, Optional, Sequence, Union
|
|
7
8
|
|
|
8
9
|
import requests
|
|
9
10
|
|
|
11
|
+
from . import __version__
|
|
10
12
|
from .api import ConfluenceAPI
|
|
11
13
|
from .application import Application
|
|
12
14
|
from .converter import ConfluenceDocumentOptions
|
|
@@ -24,12 +26,37 @@ class Arguments(argparse.Namespace):
|
|
|
24
26
|
loglevel: str
|
|
25
27
|
ignore_invalid_url: bool
|
|
26
28
|
heading_anchors: bool
|
|
29
|
+
root_page: Optional[str]
|
|
27
30
|
generated_by: Optional[str]
|
|
31
|
+
render_mermaid: bool
|
|
32
|
+
diagram_output_format: Literal["png", "svg"]
|
|
33
|
+
webui_links: bool
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class KwargsAppendAction(argparse.Action):
|
|
37
|
+
"""Append key-value pairs to a dictionary"""
|
|
38
|
+
|
|
39
|
+
def __call__(
|
|
40
|
+
self,
|
|
41
|
+
parser: argparse.ArgumentParser,
|
|
42
|
+
namespace: argparse.Namespace,
|
|
43
|
+
values: Union[None, str, Sequence[Any]],
|
|
44
|
+
option_string: Optional[str] = None,
|
|
45
|
+
) -> None:
|
|
46
|
+
try:
|
|
47
|
+
d = dict(map(lambda x: x.split("="), typing.cast(Sequence[str], values)))
|
|
48
|
+
except ValueError:
|
|
49
|
+
raise argparse.ArgumentError(
|
|
50
|
+
self,
|
|
51
|
+
f'Could not parse argument "{values}". It should follow the format: k1=v1 k2=v2 ...',
|
|
52
|
+
)
|
|
53
|
+
setattr(namespace, self.dest, d)
|
|
28
54
|
|
|
29
55
|
|
|
30
56
|
def main() -> None:
|
|
31
57
|
parser = argparse.ArgumentParser()
|
|
32
58
|
parser.prog = os.path.basename(os.path.dirname(__file__))
|
|
59
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
33
60
|
parser.add_argument(
|
|
34
61
|
"mdpath", help="Path to Markdown file or directory to convert and publish."
|
|
35
62
|
)
|
|
@@ -119,6 +146,20 @@ def main() -> None:
|
|
|
119
146
|
default=False,
|
|
120
147
|
help="Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.",
|
|
121
148
|
)
|
|
149
|
+
parser.add_argument(
|
|
150
|
+
"--headers",
|
|
151
|
+
nargs="*",
|
|
152
|
+
required=False,
|
|
153
|
+
action=KwargsAppendAction,
|
|
154
|
+
metavar="KEY=VALUE",
|
|
155
|
+
help="Apply custom headers to all Confluence API requests.",
|
|
156
|
+
)
|
|
157
|
+
parser.add_argument(
|
|
158
|
+
"--webui-links",
|
|
159
|
+
action="store_true",
|
|
160
|
+
default=False,
|
|
161
|
+
help="Enable Confluence Web UI links.",
|
|
162
|
+
)
|
|
122
163
|
|
|
123
164
|
args = Arguments()
|
|
124
165
|
parser.parse_args(namespace=args)
|
|
@@ -139,9 +180,10 @@ def main() -> None:
|
|
|
139
180
|
root_page_id=args.root_page,
|
|
140
181
|
render_mermaid=args.render_mermaid,
|
|
141
182
|
diagram_output_format=args.diagram_output_format,
|
|
183
|
+
webui_links=args.webui_links,
|
|
142
184
|
)
|
|
143
185
|
properties = ConfluenceProperties(
|
|
144
|
-
args.domain, args.path, args.username, args.apikey, args.space
|
|
186
|
+
args.domain, args.path, args.username, args.apikey, args.space, args.headers
|
|
145
187
|
)
|
|
146
188
|
if args.local:
|
|
147
189
|
Processor(options, properties).process(args.mdpath)
|
|
@@ -98,6 +98,10 @@ class ConfluenceAPI:
|
|
|
98
98
|
session.headers.update(
|
|
99
99
|
{"Authorization": f"Bearer {self.properties.api_key}"}
|
|
100
100
|
)
|
|
101
|
+
|
|
102
|
+
if self.properties.headers:
|
|
103
|
+
session.headers.update(self.properties.headers)
|
|
104
|
+
|
|
101
105
|
self.session = ConfluenceSession(
|
|
102
106
|
session,
|
|
103
107
|
self.properties.domain,
|
|
@@ -352,6 +356,34 @@ class ConfluenceSession:
|
|
|
352
356
|
content=typing.cast(str, storage["value"]),
|
|
353
357
|
)
|
|
354
358
|
|
|
359
|
+
def get_page_ancestors(
|
|
360
|
+
self, page_id: str, *, space_key: Optional[str] = None
|
|
361
|
+
) -> Dict[str, str]:
|
|
362
|
+
"""
|
|
363
|
+
Retrieve Confluence wiki page ancestors.
|
|
364
|
+
|
|
365
|
+
:param page_id: The Confluence page ID.
|
|
366
|
+
:param space_key: The Confluence space key (unless the default space is to be used).
|
|
367
|
+
:returns: Dictionary of ancestor page ID to title, with topmost ancestor first.
|
|
368
|
+
"""
|
|
369
|
+
|
|
370
|
+
path = f"/content/{page_id}"
|
|
371
|
+
query = {
|
|
372
|
+
"spaceKey": space_key or self.space_key,
|
|
373
|
+
"expand": "ancestors",
|
|
374
|
+
}
|
|
375
|
+
data = typing.cast(Dict[str, JsonType], self._invoke(path, query))
|
|
376
|
+
ancestors = typing.cast(List[JsonType], data["ancestors"])
|
|
377
|
+
|
|
378
|
+
# from the JSON array of ancestors, extract the "id" and "title"
|
|
379
|
+
results: Dict[str, str] = {}
|
|
380
|
+
for node in ancestors:
|
|
381
|
+
ancestor = typing.cast(Dict[str, JsonType], node)
|
|
382
|
+
id = typing.cast(str, ancestor["id"])
|
|
383
|
+
title = typing.cast(str, ancestor["title"])
|
|
384
|
+
results[id] = title
|
|
385
|
+
return results
|
|
386
|
+
|
|
355
387
|
def get_page_version(
|
|
356
388
|
self,
|
|
357
389
|
page_id: str,
|