xmind2markdown 0.0.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.
@@ -0,0 +1,43 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.11"
17
+
18
+ - name: Install build tools
19
+ run: pip install build
20
+
21
+ - name: Build package
22
+ run: python -m build
23
+
24
+ - uses: actions/upload-artifact@v4
25
+ with:
26
+ name: dist
27
+ path: dist/
28
+
29
+ publish:
30
+ needs: build
31
+ runs-on: ubuntu-latest
32
+ environment:
33
+ name: pypi
34
+ url: https://pypi.org/p/xmind2markdown
35
+ permissions:
36
+ id-token: write
37
+ steps:
38
+ - uses: actions/download-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+
43
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .env
4
+ .venv
5
+ .dist/
6
+ build/
7
+ src/xmind2markdown.egg-info/**
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Frithjof Engel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: xmind2markdown
3
+ Version: 0.0.0
4
+ Summary: XMind to Markdown converter
5
+ Author-email: Frithjof Engel <frithjof@fms-engel.de>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ License-File: LICENSE
10
+ Dynamic: license-file
@@ -0,0 +1,21 @@
1
+ # xmind2markdown
2
+
3
+ xmind2markdown converts XMind mindmap files to markdown format. Useful for migrating to PKMS like Obsidian or other markdown-based systems.
4
+
5
+ ## Features
6
+ - converts mindmap leaves to markdown headlines (`#`, `##`, …)
7
+ - (limited) support for XMind icons/markers (e.g. task status, priority, ...)
8
+ - supports the XMmind 2020+ format (JSON)
9
+
10
+ ## Installation
11
+ ```
12
+ pip install xmind2markdown
13
+ ```
14
+
15
+ ## Usage
16
+ ```
17
+ xmind2markdown input.xmind output.md
18
+ ```
19
+
20
+ ## License
21
+ MIT License
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools", "setuptools-scm"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "xmind2markdown"
7
+ authors = [
8
+ { name="Frithjof Engel", email="frithjof@fms-engel.de" },
9
+ ]
10
+ dynamic = ["version"]
11
+ description = "XMind to Markdown converter"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Operating System :: OS Independent",
15
+ ]
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+
19
+ [project.scripts]
20
+ xmind2markdown = "xmind2markdown:main"
21
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: xmind2markdown
3
+ Version: 0.0.0
4
+ Summary: XMind to Markdown converter
5
+ Author-email: Frithjof Engel <frithjof@fms-engel.de>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ License-File: LICENSE
10
+ Dynamic: license-file
@@ -0,0 +1,16 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.md
4
+ pyproject.toml
5
+ .github/workflows/release.yml
6
+ src/xmind2markdown.py
7
+ src/xmind2markdown.egg-info/PKG-INFO
8
+ src/xmind2markdown.egg-info/SOURCES.txt
9
+ src/xmind2markdown.egg-info/dependency_links.txt
10
+ src/xmind2markdown.egg-info/entry_points.txt
11
+ src/xmind2markdown.egg-info/top_level.txt
12
+ tests/test.md
13
+ tests/test_smoke.py
14
+ tests/testfile.md
15
+ tests/testfile.xmind
16
+ tests/xmind2markdown.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ xmind2markdown = xmind2markdown:main
@@ -0,0 +1 @@
1
+ xmind2markdown
@@ -0,0 +1,98 @@
1
+ import zipfile
2
+ import json
3
+ from pathlib import Path
4
+
5
+ MARKER_MAP = {
6
+ "task-start": "○",
7
+ "task-quarter": "◔",
8
+ "task-half": "◑",
9
+ "task-3quar": "◕",
10
+ "task-done": "✔",
11
+
12
+ "task-oct": "○", # TODO: Find unicode symbol for octets
13
+ "task-3oct": "◔", # TODO: Find unicode symbol for octets
14
+ "task-5oct": "◑", # TODO: Find unicode symbol for octets
15
+ "task-7oct": "◕", # TODO: Find unicode symbol for octets
16
+
17
+ "priority-1": "①",
18
+ "priority-2": "②",
19
+ "priority-3": "③",
20
+ "priority-4": "④",
21
+ "priority-5": "⑤",
22
+ "priority-6": "⑥",
23
+ "priority-7": "⑦",
24
+ "priority-8": "⑧",
25
+ "priority-9": "⑨",
26
+
27
+ "symbol-star": "⭐",
28
+ "symbol-exclam": "❗",
29
+ "symbol-wrong" : "❌)",
30
+
31
+ "flag-red": "🚩",
32
+ }
33
+
34
+ def markdown_heading(text: str, level: int) -> str:
35
+ return f"{'#' * level} {text}\n\n"
36
+
37
+ def markdown_note(note: str) -> str:
38
+ return f"> {note.strip()}\n\n"
39
+
40
+ def xmind_to_markdown(zf: zipfile.ZipFile) -> str:
41
+ content = json.loads(zf.read("content.json"))
42
+ markdown = []
43
+
44
+ def extract_markers(topic: dict) -> str:
45
+ markers_str = ""
46
+ for m in topic.get("markers", []):
47
+ marker = m["markerId"]
48
+ if marker in MARKER_MAP:
49
+ markers_str += MARKER_MAP[marker]
50
+ else:
51
+ print("Marker could not be converted: "+marker)
52
+
53
+ return markers_str
54
+
55
+
56
+ def parse_topic(topic, level=1):
57
+ markers = extract_markers(topic)
58
+ title = markers + topic.get("title", "Untitled")
59
+
60
+ markdown.append(markdown_heading(title, level))
61
+
62
+ note = topic.get("notes", {}).get("plain", {}).get("content")
63
+ if note:
64
+ markdown.append(markdown_note(note))
65
+
66
+ for child in topic.get("children", {}).get("attached", []):
67
+ parse_topic(child, level + 1)
68
+
69
+ for sheet in content:
70
+ parse_topic(sheet["rootTopic"])
71
+
72
+ return "".join(markdown)
73
+
74
+ def convert_xmind2markdown(xmind_file: Path, markdown_file: Path):
75
+ with zipfile.ZipFile(xmind_file) as zf:
76
+ if "content.json" in zf.namelist():
77
+ markdown = xmind_to_markdown(zf)
78
+ markdown_file.write_text(markdown, encoding="utf-8")
79
+ else:
80
+ raise RuntimeError("XMind file could not be opened. Only XMind Files in modern format are supported.")
81
+
82
+ # -----------------------------
83
+ # CLI entry point
84
+ # -----------------------------
85
+ def main():
86
+ import sys
87
+
88
+ if len(sys.argv) == 3:
89
+ xmind_file = Path(sys.argv[1])
90
+ markdown_file = Path(sys.argv[2])
91
+ convert_xmind2markdown(xmind_file, markdown_file)
92
+ print("XMind file was converted to "+markdown_file.name)
93
+ else:
94
+ print("Usage: xmind2markdown input.xmind output.md")
95
+ sys.exit(1)
96
+
97
+ if __name__ == '__main__':
98
+ main()
@@ -0,0 +1,14 @@
1
+ # Title
2
+
3
+ ## ◑①H1
4
+
5
+ ### ○H2
6
+
7
+ #### ✔H3
8
+
9
+ ## ○H1-1
10
+
11
+ ### ②H2-1
12
+
13
+ #### ❌)H3-1
14
+
@@ -0,0 +1,16 @@
1
+ def test_import():
2
+ import sys, os
3
+ from pathlib import Path
4
+ import xmind2markdown
5
+ exit_value = 0
6
+ output_md = Path("output.md")
7
+ xmind2markdown.convert_xmind2markdown(Path("testfile.xmind"), output_md)
8
+ testfile_md = Path("testfile.md")
9
+ if output_md.read_text() != testfile_md.read_text():
10
+ exit_value = 1
11
+
12
+ os.remove("output.md")
13
+ sys.exit(exit_value)
14
+
15
+ if __name__ == '__main__':
16
+ test_import()
@@ -0,0 +1,14 @@
1
+ # Title
2
+
3
+ ## ◑①H1
4
+
5
+ ### ○H2
6
+
7
+ #### ✔H3
8
+
9
+ ## ○H1-1
10
+
11
+ ### ②H2-1
12
+
13
+ #### ❌)H3-1
14
+
@@ -0,0 +1,98 @@
1
+ import zipfile
2
+ import json
3
+ from pathlib import Path
4
+
5
+ MARKER_MAP = {
6
+ "task-start": "○",
7
+ "task-quarter": "◔",
8
+ "task-half": "◑",
9
+ "task-3quar": "◕",
10
+ "task-done": "✔",
11
+
12
+ "task-oct": "○", # TODO: Find unicode symbol for octets
13
+ "task-3oct": "◔", # TODO: Find unicode symbol for octets
14
+ "task-5oct": "◑", # TODO: Find unicode symbol for octets
15
+ "task-7oct": "◕", # TODO: Find unicode symbol for octets
16
+
17
+ "priority-1": "①",
18
+ "priority-2": "②",
19
+ "priority-3": "③",
20
+ "priority-4": "④",
21
+ "priority-5": "⑤",
22
+ "priority-6": "⑥",
23
+ "priority-7": "⑦",
24
+ "priority-8": "⑧",
25
+ "priority-9": "⑨",
26
+
27
+ "symbol-star": "⭐",
28
+ "symbol-exclam": "❗",
29
+ "symbol-wrong" : "❌)",
30
+
31
+ "flag-red": "🚩",
32
+ }
33
+
34
+ def markdown_heading(text: str, level: int) -> str:
35
+ return f"{'#' * level} {text}\n\n"
36
+
37
+ def markdown_note(note: str) -> str:
38
+ return f"> {note.strip()}\n\n"
39
+
40
+ def xmind_to_markdown(zf: zipfile.ZipFile) -> str:
41
+ content = json.loads(zf.read("content.json"))
42
+ markdown = []
43
+
44
+ def extract_markers(topic: dict) -> str:
45
+ markers_str = ""
46
+ for m in topic.get("markers", []):
47
+ marker = m["markerId"]
48
+ if marker in MARKER_MAP:
49
+ markers_str += MARKER_MAP[marker]
50
+ else:
51
+ print("Marker could not be converted: "+marker)
52
+
53
+ return markers_str
54
+
55
+
56
+ def parse_topic(topic, level=1):
57
+ markers = extract_markers(topic)
58
+ title = markers + topic.get("title", "Untitled")
59
+
60
+ markdown.append(markdown_heading(title, level))
61
+
62
+ note = topic.get("notes", {}).get("plain", {}).get("content")
63
+ if note:
64
+ markdown.append(markdown_note(note))
65
+
66
+ for child in topic.get("children", {}).get("attached", []):
67
+ parse_topic(child, level + 1)
68
+
69
+ for sheet in content:
70
+ parse_topic(sheet["rootTopic"])
71
+
72
+ return "".join(markdown)
73
+
74
+ def convert_xmind2markdown(xmind_file: Path, markdown_file: Path):
75
+ with zipfile.ZipFile(xmind_file) as zf:
76
+ if "content.json" in zf.namelist():
77
+ markdown = xmind_to_markdown(zf)
78
+ markdown_file.write_text(markdown, encoding="utf-8")
79
+ else:
80
+ raise RuntimeError("XMind file could not be opened. Only XMind Files in modern format are supported.")
81
+
82
+ # -----------------------------
83
+ # CLI entry point
84
+ # -----------------------------
85
+ def main():
86
+ import sys
87
+
88
+ if len(sys.argv) == 3:
89
+ xmind_file = Path(sys.argv[1])
90
+ markdown_file = Path(sys.argv[2])
91
+ convert_xmind2markdown(xmind_file, markdown_file)
92
+ print("XMind file was converted to "+markdown_file.name)
93
+ else:
94
+ print("Usage: xmind2markdown input.xmind output.md")
95
+ sys.exit(1)
96
+
97
+ if __name__ == '__main__':
98
+ main()