Skip to content

Commit a19af40

Browse files
authored
Merge pull request #25 from gamosoft/features/mermaid-support
Features/mermaid support
2 parents 861b850 + 8cb62ea commit a19af40

File tree

14 files changed

+748
-44
lines changed

14 files changed

+748
-44
lines changed

backend/themes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77
import re
88

99

10+
def parse_theme_metadata(theme_path: Path) -> Dict[str, str]:
11+
"""Parse theme metadata from CSS file comments"""
12+
metadata = {
13+
"type": "dark" # Default to dark for backward compatibility
14+
}
15+
16+
try:
17+
with open(theme_path, 'r', encoding='utf-8') as f:
18+
# Read first few lines to find metadata
19+
for i, line in enumerate(f):
20+
if i > 10: # Only check first 10 lines
21+
break
22+
23+
# Look for @theme-type metadata
24+
if '@theme-type:' in line:
25+
# Extract the value (light or dark)
26+
match = re.search(r'@theme-type:\s*(light|dark)', line)
27+
if match:
28+
metadata["type"] = match.group(1)
29+
break
30+
except Exception as e:
31+
print(f"Error parsing theme metadata from {theme_path}: {e}")
32+
33+
return metadata
34+
35+
1036
def get_available_themes(themes_dir: str) -> List[Dict[str, str]]:
1137
"""Get all available themes from the themes directory"""
1238
themes_path = Path(themes_dir)
@@ -30,9 +56,13 @@ def get_available_themes(themes_dir: str) -> List[Dict[str, str]]:
3056
theme_name = theme_file.stem.replace("-", " ").replace("_", " ").title()
3157
icon = theme_icons.get(theme_file.stem, "🎨")
3258

59+
# Parse theme metadata
60+
metadata = parse_theme_metadata(theme_file)
61+
3362
themes.append({
3463
"id": theme_file.stem,
3564
"name": f"{icon} {theme_name}",
65+
"type": metadata["type"], # Add theme type (light/dark)
3666
"builtin": False
3767
})
3868

documentation/FEATURES.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
- **Undo/Redo** - Ctrl+Z / Ctrl+Y support
1010
- **Syntax highlighting** for code blocks (50+ languages)
1111
- **Copy code blocks** - One-click copy button on hover
12-
- **LaTeX/Math rendering** - Beautiful mathematical equations with MathJax
12+
- **LaTeX/Math rendering** - Beautiful mathematical equations with MathJax (see [MATHJAX.md](MATHJAX.md))
13+
- **Mermaid diagrams** - Create flowcharts, sequence diagrams, and more (see [MERMAID.md](MERMAID.md))
1314
- **HTML Export** - Export notes as standalone HTML files
1415

1516
### Organization
@@ -106,6 +107,31 @@ $$
106107

107108
📄 **See the [MATHJAX](MATHJAX.md) note for more examples and syntax reference.**
108109

110+
## 📊 Mermaid Diagrams
111+
112+
### Visual Diagrams
113+
- **Flowcharts** - Process flows and decision trees
114+
- **Sequence diagrams** - System interactions over time
115+
- **Class diagrams** - UML class relationships
116+
- **State diagrams** - State machines and transitions
117+
- **Gantt charts** - Project timelines
118+
- **Pie charts** - Data visualization
119+
- **Git graphs** - Branch and commit history
120+
- **Theme support** - Adapts to your theme
121+
122+
### Example
123+
````markdown
124+
```mermaid
125+
graph TD
126+
A[Start] --> B{Is it working?}
127+
B -->|Yes| C[Great!]
128+
B -->|No| D[Debug]
129+
D --> B
130+
```
131+
````
132+
133+
📄 **See the [MERMAID](MERMAID.md) note for diagram examples and syntax reference.**
134+
109135
## ⚡ Keyboard Shortcuts
110136

111137
| Windows/Linux | Mac | Action |

0 commit comments

Comments
 (0)