xmind2markdown 0.0.0__py3-none-any.whl

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,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,7 @@
1
+ xmind2markdown.py,sha256=vz7efktfz7DHwLz7UVPBQW__7J-yTJStoXnQw-GpdyY,2866
2
+ xmind2markdown-0.0.0.dist-info/licenses/LICENSE,sha256=86XC26qqBYxhYYXHDIZdMILbYiAHgs7Zzu7NC5Q8tck,1071
3
+ xmind2markdown-0.0.0.dist-info/METADATA,sha256=Ela5qmKo1HfeuFL9ToDY6EuHc9D0h_JHlF41S9N1GUw,311
4
+ xmind2markdown-0.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ xmind2markdown-0.0.0.dist-info/entry_points.txt,sha256=X1_Hr0jmr2Rwz1dByXsKxJ0zkGQcRh6vZ2GOWZV4Hx0,55
6
+ xmind2markdown-0.0.0.dist-info/top_level.txt,sha256=k5xSje_aCumVqTx4jGYp6LzU1ArZQ4m0Potxg4eUjCI,15
7
+ xmind2markdown-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ xmind2markdown = xmind2markdown:main
@@ -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 @@
1
+ xmind2markdown
xmind2markdown.py ADDED
@@ -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()