Skip to content

Commit 1971558

Browse files
authored
Merge pull request #40 from Spenhouet/reimplement-configuration
Reimplement configuration
2 parents 734d56f + 38b2bad commit 1971558

File tree

12 files changed

+952
-225
lines changed

12 files changed

+952
-225
lines changed

.env.template

Lines changed: 0 additions & 12 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@
7171
"PYTHONPATH": "${workspaceRoot}",
7272
"DEBUG": "true"
7373
}
74+
},
75+
{
76+
"name": "Python: Config (Interactive)",
77+
"type": "debugpy",
78+
"request": "launch",
79+
"program": "${workspaceFolder}/confluence_markdown_exporter/main.py",
80+
"justMyCode": false,
81+
"args": ["config"],
82+
"console": "integratedTerminal",
83+
"cwd": "${workspaceFolder}",
84+
"env": {
85+
"PYTHONPATH": "${workspaceRoot}",
86+
"DEBUG": "true"
87+
}
7488
}
7589
]
7690
}

README.md

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -47,66 +47,58 @@ Install python package via pip.
4747
pip install confluence-markdown-exporter
4848
```
4949

50-
### 2. Configure Authentication
50+
### 2. Exporting
5151

52-
You must set environment variables for **one** of the following authentication options:
52+
Run the exporter with the desired Confluence page ID or space key. Execute the console application by typing `confluence-markdown-exporter` and one of the commands `page`, `page-with-descendants`, `space`, `all-spaces` or `config`. If a command is unclear, you can always add `--help` to get additional information.
5353

54-
1. Username + API Token
55-
56-
- `ATLASSIAN_USERNAME`: Your Atlassian account email address
57-
- `ATLASSIAN_API_TOKEN`: An API token created at
58-
https://id.atlassian.com/manage-profile/security/api-tokens
59-
60-
2. Personal Access Token (PAT)
61-
62-
- `ATLASSIAN_PAT`: A Personal Access Token (used instead of username+token)
63-
64-
In all cases, you must also set:
54+
> [!TIP]
55+
> Instead of `confluence-markdown-exporter` you can also use the shorthand `cf-export`.
6556
66-
- `ATLASSIAN_URL`: Your Atlassian instance URL (e.g. `https://company.atlassian.net`)
57+
#### 2.1. Export Page
6758

68-
Here an example setting the environment variables for the Username + API Token authentication for the current terminal session.
59+
Export a single Confluence page by ID:
6960

7061
```sh
71-
export ATLASSIAN_USERNAME="work mail address"
72-
export ATLASSIAN_API_TOKEN="API token Test"
73-
export ATLASSIAN_URL="https://company.atlassian.net"
62+
confluence-markdown-exporter page <page-id e.g. 645208921> <output path e.g. ./output_path/>
7463
```
7564

76-
If you have separate Confluence and Jira instances or authentication, you can provide them via `CONFLUENCE_` or `JIRA_` prefixed environment variables.
65+
or by URL:
7766

78-
### 3. Exporting
67+
```sh
68+
confluence-markdown-exporter page <page-url e.g. https://company.atlassian.net/MySpace/My+Page+Title> <output path e.g. ./output_path/>
69+
```
7970

80-
Run the exporter with the desired Confluence page ID or space key.
71+
#### 2.2. Export Page with Descendants
8172

82-
Export a single Confluence page by ID or URL:
73+
Export a Confluence page and all its descendant pages by page ID:
8374

8475
```sh
85-
confluence-markdown-exporter page <page-id e.g. 645208921 or page-url e.g. https://company.atlassian.net/MySpace/My+Page+Title> <output path e.g. ./output_path/>
76+
confluence-markdown-exporter page-with-descendants <page-id e.g. 645208921> <output path e.g. ./output_path/>
8677
```
8778

88-
Export a Confluence page and all it's descendants:
79+
or by URL:
8980

9081
```sh
91-
confluence-markdown-exporter page-with-descendants <page-id e.g. 645208921 or page-url e.g. https://company.atlassian.net/MySpace/My+Page+Title> <output path e.g. ./output_path/>
82+
confluence-markdown-exporter page-with-descendants <page-url e.g. https://company.atlassian.net/MySpace/My+Page+Title> <output path e.g. ./output_path/>
9283
```
9384

85+
#### 2.3. Export Space
86+
9487
Export all Confluence pages of a single Space:
9588

9689
```sh
9790
confluence-markdown-exporter space <space-key e.g. MYSPACE> <output path e.g. ./output_path/>
9891
```
9992

93+
#### 2.3. Export all Spaces
94+
10095
Export all Confluence pages across all spaces:
10196

10297
```sh
10398
confluence-markdown-exporter all-spaces <output path e.g. ./output_path/>
10499
```
105100

106-
> [!TIP]
107-
> Instead of `confluence-markdown-exporter` you can also use the shorthand `cf-export`.
108-
109-
### 4. Output
101+
### 3. Output
110102

111103
The exported Markdown file(s) will be saved in the specified `output` directory e.g.:
112104

@@ -121,45 +113,64 @@ output_path/
121113
└── Another one.md
122114
```
123115

124-
## Configuration Options
116+
## Configuration
117+
118+
All configuration and authentication is stored in a single JSON file managed by the application. You do not need to manually edit this file.
119+
120+
### Interactive Configuration
125121

126-
By default the converter uses a GitHub Flavored Markdown (GFM). You can also choose an Obsidian flavored markdown by setting:
122+
To interactively view and change configuration, run:
127123

128124
```sh
129-
export MARKDOWN_STYLE="Obsidian"
125+
confluence-markdown-exporter config
130126
```
131127

132-
Via `PAGE_PATH` and `ATTACHMENT_PATH` you can customize how pages and attachments are organized in the output directory.
128+
This will open a menu where you can:
129+
- See all config options and their current values
130+
- Select a config to change (including authentication)
131+
- Reset all config to defaults
132+
- Navigate directly to any config section (e.g. `auth.confluence`)
133+
134+
### Available Configuration Options
135+
136+
| Key | Description | Default |
137+
|-----|-------------|---------|
138+
| export.markdown_style | Markdown style: GFM or Obsidian | GFM |
139+
| export.page_path | Path template for exported pages | {space_name}/{homepage_title}/{ancestor_titles}/{page_title}.md |
140+
| export.attachment_path | Path template for attachments | {space_name}/attachments/{attachment_file_id}{attachment_extension} |
141+
| retry_config.backoff_and_retry | Enable automatic retry with exponential backoff | True |
142+
| retry_config.backoff_factor | Multiplier for exponential backoff | 2 |
143+
| retry_config.max_backoff_seconds | Maximum seconds to wait between retries | 60 |
144+
| retry_config.max_backoff_retries | Maximum number of retry attempts | 5 |
145+
| retry_config.retry_status_codes | HTTP status codes that trigger a retry | [413, 429, 502, 503, 504] |
146+
| auth.confluence.url | Confluence instance URL | "" |
147+
| auth.confluence.username | Confluence username/email | "" |
148+
| auth.confluence.api_token | Confluence API token | "" |
149+
| auth.confluence.pat | Confluence Personal Access Token | "" |
150+
| auth.jira.url | Jira instance URL | "" |
151+
| auth.jira.username | Jira username/email | "" |
152+
| auth.jira.api_token | Jira API token | "" |
153+
| auth.jira.pat | Jira Personal Access Token | "" |
154+
155+
You can always view and change the current config with the interactive menu above.
156+
157+
### Custom Config File Location
158+
159+
By default, configuration is stored in a platform-specific application directory. You can override the config file location by setting the `CME_CONFIG_PATH` environment variable to the desired file path. If set, the application will read and write config from this file instead. Example:
133160

134-
By default, pages are stored at:
135161
```sh
136-
export PAGE_PATH="{space_name}/{homepage_title}/{ancestor_titles}/{page_title}.md"
162+
export CME_CONFIG_PATH=/path/to/your/custom_config.json
137163
```
138-
Available variables:
139-
- `{space_key}`: The key of the Confluence space.
140-
- `{space_name}`: The name of the Confluence space.
141-
- `{homepage_id}`: The ID of the homepage of the Confluence space.
142-
- `{homepage_title}`: The title of the homepage of the Confluence space.
143-
- `{ancestor_ids}`: A slash-separated list of ancestor page IDs.
144-
- `{ancestor_titles}`: A slash-separated list of ancestor page titles.
145-
- `{page_id}`: The unique ID of the Confluence page.
146-
- `{page_title}`: The title of the Confluence page.
147-
148-
By default, attachments are stored at:
164+
165+
This is useful for using different configs for different environments or for scripting.
166+
167+
## Update
168+
169+
Update python package via pip.
170+
149171
```sh
150-
export ATTACHMENT_PATH="{space_name}/attachments/{attachment_file_id}{attachment_extension}"
172+
pip install confluence-markdown-exporter --upgrade
151173
```
152-
Available variables:
153-
- `{space_key}`: The key of the Confluence space.
154-
- `{space_name}`: The name of the Confluence space.
155-
- `{homepage_id}`: The ID of the homepage of the Confluence space.
156-
- `{homepage_title}`: The title of the homepage of the Confluence space.
157-
- `{ancestor_ids}`: A slash-separated list of ancestor page IDs.
158-
- `{ancestor_titles}`: A slash-separated list of ancestor page titles.
159-
- `{attachment_id}`: The unique ID of the attachment.
160-
- `{attachment_title}`: The title of the attachment.
161-
- `{attachment_file_id}`: The file ID of the attachment.
162-
- `{attachment_extension}`: The file extension of the attachment, including the leading dot.
163174

164175
## Compatibility
165176

@@ -168,6 +179,10 @@ It generally was tested on:
168179
- Confluence Cloud 1000.0.0-b5426ab8524f (2025-05-28)
169180
- Confluence Server 8.5.20
170181

182+
## Known Issues
183+
1. **Missing Attachment File ID on Server**: For some Confluence Server version/configuration the attachment file ID might not be provided (https://github.com/Spenhouet/confluence-markdown-exporter/issues/39). In the default configuration, this is used for the export path. Solution: Adjust the attachment path in the export config and use the `{attachment_id}` or `{attachment_title}` instead.
184+
2. **Connection Issues when behind Proxy or VPN**: There might be connection issues if your Confluence Server is behind a proxy or VPN (https://github.com/Spenhouet/confluence-markdown-exporter/issues/38). If you experience issues, help to fix this is appreciated.
185+
171186
## Contributing
172187

173188
If you would like to contribute, please read [our contribution guideline](CONTRIBUTING.md).

0 commit comments

Comments
 (0)