Repository navigation
Expand file tree
/
Copy pathbasic.py
More file actions
95 lines (74 loc) · 1.61 KB
/
Copy pathbasic.py
File metadata and controls
95 lines (74 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
"""
Basic clickmd usage - no Click dependency required.
Run: python examples/basic.py
"""
import sys
from pathlib import Path
if __name__ == "__main__":
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from clickmd import md, echo
# Simple markdown rendering
md("""
# Welcome to clickmd! 🎨
This is a **beautiful** markdown renderer for your CLI applications.
## Features
- Syntax highlighting for code blocks
- Markdown formatting (bold, headers, links)
- Zero dependencies for core functionality
- Works with or without Click
""")
# Code block example
md("""
## Python Code Example
```python
def greet(name: str) -> str:
\"\"\"Generate a greeting.\"\"\"
return f"Hello, {name}!"
if __name__ == "__main__":
print(greet("World"))
```
""")
# JSON example
md("""
## JSON Data
```json
{
"name": "clickmd",
"version": "1.0.0",
"features": ["highlighting", "markdown", "colors"],
"stable": true,
"downloads": 12345
}
```
""")
# YAML example
md("""
## YAML Configuration
```yaml
# Application configuration
app:
name: clickmd
version: "1.0.0"
debug: false
dependencies:
- click>=8.0
- pytest>=7.0
```
""")
# Smart echo - auto-detects markdown
print("\n--- Using echo() ---\n")
echo("## This is detected as markdown")
echo("Regular text without markdown markers")
echo("**Bold text** is also detected")
# Log-style output
md("""
## Status Log
```log
🚀 Starting application...
📦 Loading dependencies...
✅ All systems ready!
⚠️ Warning: Using development mode
🛑 Error: Connection timeout (example)
```
""")