diff --git a/wf/script.py b/wf/script.py
index 82f4275..21c458d 100755
--- a/wf/script.py
+++ b/wf/script.py
@@ -291,7 +291,7 @@ def simplify_project(project_data, full_data, follow_mirrors=False): # {{{
"name": project_data.get("nm", ""),
"id": project_data.get("id", ""),
"children": [],
- "description": project_data.get("no", ""),
+ "description": project_data.get("no", "").rstrip().replace("\n$", ""),
"format": project_data.get("metadata", {}).get("layoutMode", None)
}
children = project_data.get("ch", [])
@@ -398,8 +398,6 @@ def filter_project_all(project_data, filters, include_headers=False): # {{{
-
-
def replace(project_data, regex, replacement): # {{{
project_data["name"] = re.sub(regex, replacement, project_data["name"])
children = project_data.get("children", [])
@@ -480,7 +478,7 @@ colors2 = {
}
-def recolor(project_data, colors):
+def recolor(project_data, colors): # {{{
for key, value in colors.items():
if key in project_data["name"]:
if key.startswith("x"):
@@ -488,6 +486,10 @@ def recolor(project_data, colors):
else:
project_data["name"] = f"[{value}]{project_data['name'].strip()}[/]"
break
+ # if project_data["format"] == "h1":
+ # project_data["name"] = f"[base3][underline]{project_data['name']}[/]"
+ # if project_data["format"] == "h2":
+ # project_data["name"] = f"[base1][underline]{project_data['name']}[/]"
children = project_data.get("children", [])
for child in children:
recolor(child, colors)
@@ -497,28 +499,210 @@ def recolor(project_data, colors):
def print_pretty(data, indent=0, color="grey", show_description=True, show_id=False): # {{{
try:
- # href = f"https://workflowy.com/#/{data['id'].split('-')[4]}"
for item in data["children"]:
-
- if item["format"] == "h1":
- console.print("")
- console.print(" " * indent + f"[base3]•[/] [base3][underline]{item['name']}[/][/][base01]{' ' + item['id'].split('-')[4] if show_id else ''}[/]")
- elif item["format"] == "h2":
- console.print(" " * indent + f"[base3]•[/] [base1][underline]{item['name']}[/][/][base01]{' ' + item['id'].split('-')[4] if show_id else ''}[/]")
-
- else:
- console.print(" " * indent + f"[base3]•[/] [{color}]{item['name']}[/][base01]{' ' + item['id'].split('-')[4] if show_id else ''}[/]")
-
-
+ console.print(" " * indent + f"[base3]•[/] [{color}]{item['name']}[/][base01]{' ' + item['id'].split('-')[4] if show_id else ''}[/]")
if item["description"] and show_description:
console.print(" " * (indent + 1) + f"[base01]{item['description'].replace('\n', '\n' + ' ' * (indent + 1))}[/]")
-
if item["children"]:
print_pretty(item, indent + 1, color, show_description=show_description, show_id=show_id)
except Exception as e:
console.log(f"Error: {e}")
+
+# }}}
+
+
+def generate_d3_mindmap_html(data, show_description=True, show_id=False): # {{{
+ import json
+ import re
+
+ # Map of Rich tag colors to hex values or CSS color names
+ color_map = {
+ "base3": "#073642",
+ "base2": "#002b36",
+ "base1": "#586e75",
+ "base0": "#657b83",
+ "base00": "#839496",
+ "base01": "#93a1a1",
+ "base02": "#eee8d5",
+ "base03": "#fdf6e3",
+ "yellow": "#b58900",
+ "orange": "#cb4b16",
+ "red": "#dc322f",
+ "magenta": "#d33682",
+ "violet": "#6c71c4",
+ "blue": "#268bd2",
+ "cyan": "#2aa198",
+ "green": "#859900",
+ }
+
+ def parse_rich_tags(text):
+ text = re.sub(r"\[(underline)? ?([a-zA-Z0-9]+)?\](.*?)\[/\]",
+ lambda m: f'